blob: 311327ebcea43b02f2dc1557b2254ab87b0db7f0 [file] [log] [blame]
Rafael Espindola75d65b92010-09-25 05:42:19 +00001// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | elf-dump --dump-section-data | FileCheck %s
2
Rafael Espindola259bcda2010-10-05 15:43:32 +00003// Test that PIC relocations with local symbols in a mergeable section are done
Rafael Espindola75d65b92010-09-25 05:42:19 +00004// with a reference to the symbol. Not sure if this is a linker limitation,
5// but this matches the behavior of gas.
6
Rafael Espindola259bcda2010-10-05 15:43:32 +00007// Non-PIC relocations with 0 offset don't use the symbol.
8
9
10 movsd .Lfoo(%rip), %xmm1
11 movl $.Lfoo, %edi
12 movl $.Lfoo+2, %edi
Rafael Espindolad7565c32010-10-05 23:57:26 +000013 jmp foo@PLT
Rafael Espindola8f3d2c92010-10-06 16:23:36 +000014 movq foo@GOTPCREL, %rax
Rafael Espindola259bcda2010-10-05 15:43:32 +000015
Rafael Espindola75d65b92010-09-25 05:42:19 +000016 .section .sec1,"aM",@progbits,16
17.Lfoo:
Rafael Espindola259bcda2010-10-05 15:43:32 +000018
Rafael Espindolad7565c32010-10-05 23:57:26 +000019 .section bar,"ax",@progbits
20foo:
21
Rafael Espindola259bcda2010-10-05 15:43:32 +000022// Section 4 is "sec1"
23// CHECK: # Section 4
24// CHECK-NEXT: (('sh_name', 18) # '.sec1'
Rafael Espindola75d65b92010-09-25 05:42:19 +000025
Rafael Espindola96bfb502010-09-27 22:04:54 +000026// Symbol number 1 is .Lfoo
Rafael Espindola96bfb502010-09-27 22:04:54 +000027// CHECK: # Symbol 1
28// CHECK-NEXT: (('st_name', 1) # '.Lfoo'
29
Rafael Espindolad7565c32010-10-05 23:57:26 +000030// Symbol number 2 is foo
31// CHECK: # Symbol 2
32// CHECK-NEXT: (('st_name', 7) # 'foo'
33
34// Symbol number 6 is section 4
35// CHECK: # Symbol 6
Rafael Espindola259bcda2010-10-05 15:43:32 +000036// CHECK-NEXT: (('st_name', 0) # ''
37// CHECK-NEXT: ('st_bind', 0)
38// CHECK-NEXT: ('st_type', 3)
39// CHECK-NEXT: ('st_other', 0)
40// CHECK-NEXT: ('st_shndx', 4)
Rafael Espindola75d65b92010-09-25 05:42:19 +000041
Rafael Espindola259bcda2010-10-05 15:43:32 +000042// Relocation 0 refers to symbol 1
Rafael Espindola75d65b92010-09-25 05:42:19 +000043// CHECK: ('_relocations', [
44// CHECK-NEXT: # Relocation 0
45// CHECK-NEXT: (('r_offset',
46// CHECK-NEXT: ('r_sym', 1)
Rafael Espindola259bcda2010-10-05 15:43:32 +000047// CHECK-NEXT: ('r_type', 2
48// CHECK-NEXT: ('r_addend',
49// CHECK-NEXT: ),
50
Rafael Espindolad7565c32010-10-05 23:57:26 +000051// Relocation 1 refers to symbol 6
Rafael Espindola259bcda2010-10-05 15:43:32 +000052// CHECK-NEXT: # Relocation 1
53// CHECK-NEXT: (('r_offset',
Rafael Espindolad7565c32010-10-05 23:57:26 +000054// CHECK-NEXT: ('r_sym', 6)
Rafael Espindola259bcda2010-10-05 15:43:32 +000055// CHECK-NEXT: ('r_type', 10)
56// CHECK-NEXT: ('r_addend',
57// CHECK-NEXT: ),
58
59// Relocation 2 refers to symbol 1
60// CHECK-NEXT: # Relocation 2
61// CHECK-NEXT: (('r_offset',
62// CHECK-NEXT: ('r_sym', 1)
63// CHECK-NEXT: ('r_type', 10
Rafael Espindola75d65b92010-09-25 05:42:19 +000064// CHECK-NEXT: ('r_addend',
65// CHECK-NEXT: ),
Rafael Espindolad7565c32010-10-05 23:57:26 +000066
67// Relocation 3 refers to symbol 2
68// CHECK-NEXT: # Relocation 3
69// CHECK-NEXT: (('r_offset',
70// CHECK-NEXT: ('r_sym', 2)
71// CHECK-NEXT: ('r_type', 4
72// CHECK-NEXT: ('r_addend',
73// CHECK-NEXT: ),
Rafael Espindola8f3d2c92010-10-06 16:23:36 +000074
75// Relocation 4 refers to symbol 2
76// CHECK-NEXT: # Relocation 4
77// CHECK-NEXT: (('r_offset',
78// CHECK-NEXT: ('r_sym', 2)
79// CHECK-NEXT: ('r_type', 9
80// CHECK-NEXT: ('r_addend',
81// CHECK-NEXT: ),
Rafael Espindola75d65b92010-09-25 05:42:19 +000082// CHECK-NEXT: ])