brintos

brintos / llvm-project-archived public Read only

0
0
Text · 7.1 KiB · fce15c2 Raw
316 lines · plain
1# RUN: llvm-mc -triple=powerpc64le-unknown-linux-gnu -filetype=obj -o %t %s \2# RUN:   --defsym LE=13# RUN: llvm-jitlink -abs external_var=0xffff0000 -abs puts=0xffff6400 -abs \4# RUN:   foo=0xffff8800 -abs low_addr=0x0320 -noexec %t5# RUN: llvm-mc -triple=powerpc64-unknown-linux-gnu -filetype=obj -o %t %s6# RUN: llvm-jitlink -abs external_var=0xffff0000 -abs puts=0xffff6400 -abs \7# RUN:   foo=0xffff8800 -abs low_addr=0x0320 -noexec %t8#9# Check typical relocations involving external function call, external variable10# reference, local function call and referencing global variable defined in the11# same CU. This test serves as smoke test, `llvm-jitlink -check` is not used.12 13	.text14	.abiversion 215	.file	"ppc64-relocs.c"16	.globl	main17	.p2align	418	.type	main,@function19main:20.Lfunc_begin0:21	li 3, 022	blr23	.long	024	.quad	025.Lfunc_end0:26	.size	main, .Lfunc_end0-.Lfunc_begin027 28	.globl	id29	.p2align	430	.type	id,@function31id:32.Lfunc_begin1:33.Lfunc_gep1:34	addis 2, 12, .TOC.-.Lfunc_gep1@ha35	addi 2, 2, .TOC.-.Lfunc_gep1@l36.Lfunc_lep1:37	.localentry	id, .Lfunc_lep1-.Lfunc_gep138	addis 4, 2, .LC0@toc@ha39	ld 4, .LC0@toc@l(4)40	lwz 4, 0(4)41	sub	3, 4, 342	extsw 3, 343	blr44	.long	045	.quad	046.Lfunc_end1:47	.size	id, .Lfunc_end1-.Lfunc_begin148 49# Test referencing external data via R_PPC64_TOC16HA and R_PPC64_TOC16LO.50	.globl	test_reference_external_data51	.p2align	452	.type	test_reference_external_data,@function53test_reference_external_data:54.Lfunc_begin2:55.Lfunc_gep2:56	addis 2, 12, .TOC.-.Lfunc_gep2@ha57	addi 2, 2, .TOC.-.Lfunc_gep2@l58.Lfunc_lep2:59	.localentry	test_reference_external_data, .Lfunc_lep2-.Lfunc_gep260	addis 3, 2, .LC0@toc@ha61	ld 3, .LC0@toc@l(3)62	blr63	.long	064	.quad	065.Lfunc_end2:66	.size	test_reference_external_data, .Lfunc_end2-.Lfunc_begin267 68# Test referencing global variable defined in the same CU.69	.globl	test_reference_local_data70	.p2align	471	.type	test_reference_local_data,@function72test_reference_local_data:73.Lfunc_begin3:74.Lfunc_gep3:75	addis 2, 12, .TOC.-.Lfunc_gep3@ha76	addi 2, 2, .TOC.-.Lfunc_gep3@l77.Lfunc_lep3:78	.localentry	test_reference_local_data, .Lfunc_lep3-.Lfunc_gep379	addis 3, 2, .LC1@toc@ha80	ld 3, .LC1@toc@l(3)81	blr82	.long	083	.quad	084.Lfunc_end3:85	.size	test_reference_local_data, .Lfunc_end3-.Lfunc_begin386 87# Test external function call with R_PPC64_REL24, which requires PLT88# call stub.89	.globl	test_external_call90	.p2align	491	.type	test_external_call,@function92test_external_call:93.Lfunc_begin4:94.Lfunc_gep4:95	addis 2, 12, .TOC.-.Lfunc_gep4@ha96	addi 2, 2, .TOC.-.Lfunc_gep4@l97.Lfunc_lep4:98	.localentry	test_external_call, .Lfunc_lep4-.Lfunc_gep499	mflr 0100	stdu 1, -32(1)101	addis 3, 2, .L.str@toc@ha102	std 0, 48(1)103	addi 3, 3, .L.str@toc@l104	bl puts105	nop106	addi 1, 1, 32107	ld 0, 16(1)108	mtlr 0109	blr110	.long	0111	.quad	0112.Lfunc_end4:113	.size	test_external_call, .Lfunc_end4-.Lfunc_begin4114 115# Test local calls with R_PPC64_REL24.116# Calling to `id` has a nop followed, while there is no117# nop after calling `id1`.118	.globl	test_local_call119	.p2align	4120	.type	test_local_call,@function121test_local_call:122.Lfunc_begin5:123.Lfunc_gep5:124	addis 2, 12, .TOC.-.Lfunc_gep5@ha125	addi 2, 2, .TOC.-.Lfunc_gep5@l126.Lfunc_lep5:127	.localentry	test_local_call, .Lfunc_lep5-.Lfunc_gep5128	mflr 0129	std 29, -24(1)130	std 30, -16(1)131	stdu 1, -64(1)132	std 0, 80(1)133	mr	30, 3134# A local call, with a nop followed.135	bl id136	nop137	mr	29, 3138	mr	3, 30139# A local call, without nop followed.140	bl id1141	add 3, 3, 29142	extsw 3, 3143	addi 1, 1, 64144	ld 0, 16(1)145	ld 30, -16(1)146	ld 29, -24(1)147	mtlr 0148	blr149	.long	0150	.quad	0151.Lfunc_end5:152	.size	test_local_call, .Lfunc_end5-.Lfunc_begin5153 154	.p2align	4155	.type	id1,@function156id1:157.Lfunc_begin6:158.Lfunc_gep6:159	addis 2, 12, .TOC.-.Lfunc_gep6@ha160	addi 2, 2, .TOC.-.Lfunc_gep6@l161.Lfunc_lep6:162	.localentry	id1, .Lfunc_lep6-.Lfunc_gep6163	addis 4, 2, .LC1@toc@ha164	ld 4, .LC1@toc@l(4)165	lwz 4, 0(4)166	sub	3, 4, 3167	extsw 3, 3168	blr169	.long	0170	.quad	0171.Lfunc_end6:172	.size	id1, .Lfunc_end6-.Lfunc_begin6173 174# Test external function call with R_PPC64_REL24_NOTOC, which requires PLT175# call stub, however no saving of r2 is required and there's no nop after176# the branch instruction.177	.globl	bar178	.p2align	4179	.type	bar,@function180bar:181.Lfunc_begin7:182	.localentry	bar, 1183	b foo@notoc184	#TC_RETURNd8 foo@notoc 0185	.long	0186	.quad	0187.Lfunc_end7:188	.size	bar, .Lfunc_end7-.Lfunc_begin7189 190  .global foobar191  .p2align 4192  .type foobar,@function193foobar:194.Lfunc_begin8:195  .localentry foobar, 1196  paddi 3, 0, .L.str@PCREL, 1197  blr198.Lfunc_end8:199  .size foobar, .Lfunc_end8-.Lfunc_begin8200 201  .global reloc_addr14202  .p2align 4203  .type reloc_addr14,@function204reloc_addr14:205.Lfunc_begin9:206  bca 21, 30, low_addr207.Lfunc_end9:208  .size reloc_addr14, .Lfunc_end9-.Lfunc_begin9209 210  .global reloc_half16211  .p2align 4212  .type reloc_half16,@function213reloc_half16:214.Lfunc_begin10:215.ifdef LE216  li 3, 0217  .reloc .Lfunc_begin10, R_PPC64_ADDR16_DS, low_addr218  li 3, 0219  .reloc .Lfunc_begin10+4, R_PPC64_ADDR16_LO, low_addr220  li 3, 0221  .reloc .Lfunc_begin10+8, R_PPC64_ADDR16_LO_DS, low_addr222  li 3, 0223  .reloc .Lfunc_begin10+12, R_PPC64_ADDR16, low_addr224  li 3, 0225  .reloc .Lfunc_begin10+16, R_PPC64_ADDR16_HI, low_addr226.else227  li 3, 0228  .reloc .Lfunc_begin10+2, R_PPC64_ADDR16_DS, low_addr229  li 3, 0230  .reloc .Lfunc_begin10+6, R_PPC64_ADDR16_LO, low_addr231  li 3, 0232  .reloc .Lfunc_begin10+10, R_PPC64_ADDR16_LO_DS, low_addr233  li 3, 0234  .reloc .Lfunc_begin10+14, R_PPC64_ADDR16, low_addr235  li 3, 0236  .reloc .Lfunc_begin10+18, R_PPC64_ADDR16_HI, low_addr237.endif238  li 3, low_addr@ha239  li 3, low_addr@high240  li 3, low_addr@higha241  li 3, low_addr@higher242  li 3, low_addr@highera243  li 3, low_addr@highest244  li 3, low_addr@highesta245.Ldelta16:246.ifdef LE247  li 3, 0248  .reloc .Ldelta16, R_PPC64_REL16, reloc_half16249  li 3, 0250  .reloc .Ldelta16+4, R_PPC64_REL16_HI, reloc_half16251  li 3, 0252  .reloc .Ldelta16+8, R_PPC64_REL16_HA, reloc_half16253  li 3, 0254  .reloc .Ldelta16+12, R_PPC64_REL16_LO, reloc_half16255.else256  li 3, 0257  .reloc .Ldelta16+2, R_PPC64_REL16, reloc_half16258  li 3, 0259  .reloc .Ldelta16+6, R_PPC64_REL16_HI, reloc_half16260  li 3, 0261  .reloc .Ldelta16+10, R_PPC64_REL16_HA, reloc_half16262  li 3, 0263  .reloc .Ldelta16+14, R_PPC64_REL16_LO, reloc_half16264.endif265.Ltocdetal16:266.ifdef LE267  li 3, 0268  .reloc .Ltocdetal16, R_PPC64_TOC16, .L.str269  li 3, 0270  .reloc .Ltocdetal16+4, R_PPC64_TOC16_HI, .L.str271  li 3, 0272  .reloc .Ltocdetal16+8, R_PPC64_TOC16_DS, .L.str273  li 3, 0274  .reloc .Ltocdetal16+12, R_PPC64_TOC16_HA, .L.str275  li 3, 0276  .reloc .Ltocdetal16+16, R_PPC64_TOC16_LO, .L.str277  li 3, 0278  .reloc .Ltocdetal16+20, R_PPC64_TOC16_LO_DS, .L.str279.else280  li 3, 0281  .reloc .Ltocdetal16+2, R_PPC64_TOC16, .L.str282  li 3, 0283  .reloc .Ltocdetal16+6, R_PPC64_TOC16_HI, .L.str284  li 3, 0285  .reloc .Ltocdetal16+10, R_PPC64_TOC16_DS, .L.str286  li 3, 0287  .reloc .Ltocdetal16+14, R_PPC64_TOC16_HA, .L.str288  li 3, 0289  .reloc .Ltocdetal16+18, R_PPC64_TOC16_LO, .L.str290  li 3, 0291  .reloc .Ltocdetal16+22, R_PPC64_TOC16_LO_DS, .L.str292.endif293  blr294.Lfunc_end10:295  .size reloc_half16, .Lfunc_end10-.Lfunc_begin10296 297	.type	local_var,@object298	.section	.bss,"aw",@nobits299	.globl	local_var300	.p2align	2, 0x0301local_var:302	.long	0303	.size	local_var, 4304 305	.type	.L.str,@object306	.section	.rodata.str1.1,"aMS",@progbits,1307.L.str:308	.asciz	"Hey!"309	.size	.L.str, 5310 311	.section	.toc,"aw",@progbits312.LC0:313	.tc external_var[TC],external_var314.LC1:315	.tc local_var[TC],local_var316