brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.9 KiB · 83e7f7c Raw
177 lines · plain
1# RUN: rm -rf %t && mkdir -p %t2# RUN: llvm-mc -triple=x86_64-unknown-linux -position-independent \3# RUN:     -filetype=obj -o %t/elf_sm_pic_reloc.o %s4# RUN: llvm-jitlink -noexec \5# RUN:     -slab-allocate 100Kb -slab-address 0xfff00000 -slab-page-size 4096 \6# RUN:     -abs external_data=0x1 \7# RUN:     -abs extern_out_of_range32=0x7fff00000000 \8# RUN:     -check %s %t/elf_sm_pic_reloc.o9#10# Test ELF small/PIC relocations.11 12        .text13        .file   "testcase.c"14 15# Empty main entry point.16        .globl  main17        .p2align        4, 0x9018        .type   main,@function19main:20        retq21 22        .size   main, .-main23 24# Test PCRel32 / R_X86_64_PC32 handling.25# jitlink-check: decode_operand(test_pcrel32, 4) = named_data - next_pc(test_pcrel32)26        .globl  test_pcrel3227        .p2align       4, 0x9028        .type   test_pcrel32,@function29test_pcrel32:30        movl    named_data(%rip), %eax31 32         .size   test_pcrel32, .-test_pcrel3233 34        .globl  named_func35        .p2align       4, 0x9036        .type   named_func,@function37named_func:38        xorq    %rax, %rax39 40        .size   named_func, .-named_func41 42# Check R_X86_64_PLT32 handling with a call to a local function in the text43# section. This produces a Branch32 edge that is resolved like a regular44# PCRel32 (no PLT entry created).45#46# jitlink-check: decode_operand(test_call_local, 0) = \47# jitlink-check:   named_func - next_pc(test_call_local)48        .globl  test_call_local49        .p2align       4, 0x9050        .type   test_call_local,@function51test_call_local:52        callq   named_func53 54        .size   test_call_local, .-test_call_local55 56# Check R_X86_64_PLT32 handling with a call to a local linkage function in a57# different text section and at a non-zero offset. This produces a Branch32 edge58# that is resolved like a regular PCRel32 (no PLT entry created). The non-zero59# offset requires us to handle addends for branch relocations correctly.60#61# jitlink-check: decode_operand(test_call_alt_sec_at_offset, 0) = \62# jitlink-check:   (section_addr(elf_sm_pic_reloc.o, .text.alt) + 16) - \63# jitlink-check:   next_pc(test_call_alt_sec_at_offset)64        .globl  test_call_alt_sec_at_offset65        .p2align       4, 0x9066        .type   test_call_alt_sec_at_offset,@function67test_call_alt_sec_at_offset:68        callq   named_func_alt_sec_at_offset69 70        .size   test_call_alt_sec_at_offset, .-test_call_alt_sec_at_offset71 72# Check R_X86_64_PLT32 handling with a call to an external via PLT. This73# produces a Branch32ToStub edge, because externals are not defined locally.74# As the target is out-of-range from the callsite, the edge keeps using its PLT75# entry.76#77# jitlink-check: decode_operand(test_call_extern_plt, 0) = \78# jitlink-check:     stub_addr(elf_sm_pic_reloc.o, extern_out_of_range32) - \79# jitlink-check:        next_pc(test_call_extern_plt)80# jitlink-check: *{8}(got_addr(elf_sm_pic_reloc.o, extern_out_of_range32)) = \81# jitlink-check:     extern_out_of_range3282        .globl  test_call_extern_plt83        .p2align       4, 0x9084        .type   test_call_extern_plt,@function85test_call_extern_plt:86        callq   extern_out_of_range32@plt87 88        .size   test_call_extern_plt, .-test_call_extern_plt89 90# Test GOTPCREL handling. We want to check both the offset to the GOT entry and its91# contents. "movl" will be optimized to "leal" and a non-got access if the pc relative92# offset to named_data is in range of 32 bits signed immediate. So use "leal" here to93# suppress optimization94# jitlink-check: decode_operand(test_gotpcrel, 4) = \95# jitlink-check:     got_addr(elf_sm_pic_reloc.o, named_data) - next_pc(test_gotpcrel)96# jitlink-check: *{8}(got_addr(elf_sm_pic_reloc.o, named_data)) = named_data97 98        .globl test_gotpcrel99        .p2align      4, 0x90100        .type   test_gotpcrel,@function101test_gotpcrel:102	leal    named_data@GOTPCREL(%rip), %eax103 104        .size   test_gotpcrel, .-test_gotpcrel105 106# Test REX_GOTPCRELX handling. We want to check both the offset to the GOT entry and its107# contents.108# jitlink-check: decode_operand(test_rex_gotpcrelx, 4) = \109# jitlink-check:   got_addr(elf_sm_pic_reloc.o, external_data) - next_pc(test_rex_gotpcrelx)110 111        .globl test_rex_gotpcrelx112        .p2align      4, 0x90113        .type   test_rex_gotpcrelx,@function114test_rex_gotpcrelx:115	movq    external_data@GOTPCREL(%rip), %rax116 117        .size   test_rex_gotpcrelx, .-test_rex_gotpcrelx118 119# Test GOTOFF64 handling.120# jitlink-check: decode_operand(test_gotoff64, 1) = named_func - _GLOBAL_OFFSET_TABLE_121        .globl test_gotoff64122        .p2align     4, 0x90123        .type  test_gotoff64,@function124test_gotoff64:125        movabsq $named_func@GOTOFF, %rax126 127        .size   test_gotoff64, .-test_gotoff64128 129# Test that relocations to anonymous constant pool entries work.130        .globl  test_anchor_LCPI131        .p2align        4, 0x90132        .type   test_anchor_LCPI,@function133test_anchor_LCPI:134        movq    .LCPI0_0(%rip), %rax135 136        .size   test_anchor_LCPI, .-test_anchor_LCPI137 138        .data139 140        .type   named_data,@object141        .p2align        3142named_data:143        .quad   42144        .size   named_data, 8145 146# Test BSS / zero-fill section handling.147# llvm-jitlink: *{4}bss_variable = 0148 149	.type	bss_variable,@object150	.bss151	.globl	bss_variable152	.p2align	2153bss_variable:154	.long	0155	.size	bss_variable, 4156 157# Named functions in a separate section.158	.section	.text.alt,"ax",@progbits159# .byte plus alignment of 16 should put named_func_alt_sec_at_offset at offset160# 16 within .text.alt.161	.byte   7162	.p2align	4, 0x90163	.type	named_func_alt_sec_at_offset,@function164named_func_alt_sec_at_offset:165	retq166	.size	named_func_alt_sec_at_offset, .-named_func_alt_sec_at_offset167 168# Constant pool entry with type STT_NOTYPE.169        .section        .rodata.cst8,"aM",@progbits,8170        .p2align        3171.LCPI0_0:172        .quad   0x400921fb54442d18173 174        .ident  "clang version 10.0.0-4ubuntu1 "175        .section        ".note.GNU-stack","",@progbits176        .addrsig177