1 // RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | llvm-readobj -s -sr -t | FileCheck %s 2 3 // Test that we produce the correct relocation. 4 5 bar: 6 movl $bar, %edx # R_X86_64_32 7 movq $bar, %rdx # R_X86_64_32S 8 movq $bar, bar(%rip) # R_X86_64_32S 9 movl bar, %edx # R_X86_64_32S 10 movq bar, %rdx # R_X86_64_32S 11 .long bar # R_X86_64_32 12 leaq foo@GOTTPOFF(%rip), %rax # R_X86_64_GOTTPOFF 13 leaq foo@TLSGD(%rip), %rax # R_X86_64_TLSGD 14 leaq foo@TPOFF(%rax), %rax # R_X86_64_TPOFF32 15 leaq foo@TLSLD(%rip), %rdi # R_X86_64_TLSLD 16 leaq foo@dtpoff(%rax), %rcx # R_X86_64_DTPOFF32 17 movabs foo@GOT, %rax # R_X86_64_GOT64 18 movabs foo@GOTOFF, %rax # R_X86_64_GOTOFF64 19 pushq $bar 20 movq foo(%rip), %rdx 21 leaq foo-bar(%r14),%r14 22 addq $bar,%rax # R_X86_64_32S 23 .quad foo@DTPOFF 24 movabsq $baz@TPOFF, %rax 25 .word foo-bar 26 .byte foo-bar 27 28 # this should probably be an error... 29 zed = foo +2 30 call zed@PLT 31 32 leaq -1+foo(%rip), %r11 33 34 movl $_GLOBAL_OFFSET_TABLE_, %eax 35 movabs $_GLOBAL_OFFSET_TABLE_, %rax 36 37 // CHECK: Section { 38 // CHECK: Name: .rela.text 39 // CHECK: Relocations [ 40 // CHECK-NEXT: 0x1 R_X86_64_32 .text 41 // CHECK-NEXT: 0x8 R_X86_64_32S .text 42 // CHECK-NEXT: 0x13 R_X86_64_32S .text 43 // CHECK-NEXT: 0x1A R_X86_64_32S .text 44 // CHECK-NEXT: 0x22 R_X86_64_32S .text 45 // CHECK-NEXT: 0x26 R_X86_64_32 .text 46 // CHECK-NEXT: 0x2D R_X86_64_GOTTPOFF foo 0xFFFFFFFFFFFFFFFC 47 // CHECK-NEXT: 0x34 R_X86_64_TLSGD foo 0xFFFFFFFFFFFFFFFC 48 // CHECK-NEXT: 0x3B R_X86_64_TPOFF32 foo 0x0 49 // CHECK-NEXT: 0x42 R_X86_64_TLSLD foo 0xFFFFFFFFFFFFFFFC 50 // CHECK-NEXT: 0x49 R_X86_64_DTPOFF32 foo 0x0 51 // CHECK-NEXT: 0x4F R_X86_64_GOT64 foo 0x0 52 // CHECK-NEXT: 0x59 R_X86_64_GOTOFF64 foo 0x0 53 // CHECK-NEXT: 0x62 R_X86_64_32S .text 0x0 54 // CHECK-NEXT: 0x69 R_X86_64_PC32 foo 0xFFFFFFFFFFFFFFFC 55 // CHECK-NEXT: 0x70 R_X86_64_PC32 foo 0x70 56 // CHECK-NEXT: 0x77 R_X86_64_32S .text 0x0 57 // CHECK-NEXT: 0x7B R_X86_64_DTPOFF64 foo 0x0 58 // CHECK-NEXT: 0x85 R_X86_64_TPOFF64 baz 0x0 59 // CHECK-NEXT: 0x8D R_X86_64_PC16 foo 0x8D 60 // CHECK-NEXT: 0x8F R_X86_64_PC8 foo 0x8F 61 // CHECK-NEXT: 0x91 R_X86_64_PLT32 zed 0xFFFFFFFFFFFFFFFC 62 // CHECK-NEXT: 0x98 R_X86_64_PC32 foo 0xFFFFFFFFFFFFFFFB 63 // CHECK-NEXT: 0x9D R_X86_64_GOTPC32 _GLOBAL_OFFSET_TABLE_ 0x1 64 // CHECK-NEXT: 0xA3 R_X86_64_GOTPC64 _GLOBAL_OFFSET_TABLE_ 0x2 65 // CHECK-NEXT: ] 66 // CHECK-NEXT: } 67 68 // CHECK: Symbol { 69 // CHECK: Name: .text (0) 70 // CHECK-NEXT: Value: 71 // CHECK-NEXT: Size: 72 // CHECK-NEXT: Binding: Local 73 // CHECK-NEXT: Type: Section 74 // CHECK-NEXT: Other: 0 75 // CHECK-NEXT: Section: .text (0x1) 76 // CHECK-NEXT: } 77