1 // RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | elf-dump --dump-section-data | FileCheck %s
3 // Test that PIC relocations with local symbols in a mergeable section are done
4 // with a reference to the symbol. Not sure if this is a linker limitation,
5 // but this matches the behavior of gas.
7 // Non-PIC relocations with 0 offset don't use the symbol.
10 movsd .Lfoo(%rip), %xmm1
14 movq foo@GOTPCREL, %rax
17 .section .sec1,"aM",@progbits,16
22 .section bar,"ax",@progbits
25 // Relocation 0 refers to symbol 1
26 // CHECK: ('_relocations', [
27 // CHECK-NEXT: # Relocation 0
28 // CHECK-NEXT: (('r_offset',
29 // CHECK-NEXT: ('r_sym', 0x00000001)
30 // CHECK-NEXT: ('r_type', 0x00000002
31 // CHECK-NEXT: ('r_addend',
34 // Relocation 1 refers to symbol 6
35 // CHECK-NEXT: # Relocation 1
36 // CHECK-NEXT: (('r_offset',
37 // CHECK-NEXT: ('r_sym', 0x00000006)
38 // CHECK-NEXT: ('r_type', 0x0000000a)
39 // CHECK-NEXT: ('r_addend',
42 // Relocation 2 refers to symbol 1
43 // CHECK-NEXT: # Relocation 2
44 // CHECK-NEXT: (('r_offset',
45 // CHECK-NEXT: ('r_sym', 0x00000001)
46 // CHECK-NEXT: ('r_type', 0x0000000a
47 // CHECK-NEXT: ('r_addend',
50 // Relocation 3 refers to symbol 2
51 // CHECK-NEXT: # Relocation 3
52 // CHECK-NEXT: (('r_offset',
53 // CHECK-NEXT: ('r_sym', 0x00000002)
54 // CHECK-NEXT: ('r_type', 0x00000004
55 // CHECK-NEXT: ('r_addend',
58 // Relocation 4 refers to symbol 2
59 // CHECK-NEXT: # Relocation 4
60 // CHECK-NEXT: (('r_offset',
61 // CHECK-NEXT: ('r_sym', 0x00000002)
62 // CHECK-NEXT: ('r_type', 0x00000009
63 // CHECK-NEXT: ('r_addend',
66 // Relocation 5 refers to symbol 8
67 // CHECK-NEXT: # Relocation 5
68 // CHECK-NEXT: (('r_offset', 0x0000000000000023)
69 // CHECK-NEXT: ('r_sym', 0x00000008)
70 // CHECK-NEXT: ('r_type', 0x0000000b)
71 // CHECK-NEXT: ('r_addend', 0x0000000000000000)
75 // Section 5 is "sec1"
77 // CHECK-NEXT: (('sh_name', 0x00000035) # '.sec1'
79 // Symbol number 1 is .Lfoo
81 // CHECK-NEXT: (('st_name', 0x00000001) # '.Lfoo'
83 // Symbol number 2 is foo
85 // CHECK-NEXT: (('st_name', 0x00000007) # 'foo'
87 // Symbol number 6 is section 5
89 // CHECK-NEXT: (('st_name', 0x00000000) # ''
90 // CHECK-NEXT: ('st_bind', 0x0)
91 // CHECK-NEXT: ('st_type', 0x3)
92 // CHECK-NEXT: ('st_other', 0x00)
93 // CHECK-NEXT: ('st_shndx', 0x0005)
95 // Symbol number 8 is zed
97 // CHECK-NEXT: (('st_name', 0x0000000b) # 'zed'