c5cf0697a3491d251986e4942b256519b78c4e2b
[oota-llvm.git] / test / MC / ELF / merge.s
1 // RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | elf-dump  --dump-section-data | FileCheck  %s
2
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.
6
7 // 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
13         jmp     foo@PLT
14         movq    foo@GOTPCREL, %rax
15         movq    zed, %rax
16
17         .section        .sec1,"aM",@progbits,16
18 .Lfoo:
19 zed:
20         .global zed
21
22         .section        bar,"ax",@progbits
23 foo:
24
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',
32 // CHECK-NEXT:   ),
33
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',
40 // CHECK-NEXT: ),
41
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',
48 // CHECK-NEXT:   ),
49
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',
56 // CHECK-NEXT:   ),
57
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',
64 // CHECK-NEXT:   ),
65
66 // Relocation 5 refers to symbol 8
67 // CHECK-NEXT:   # Relocation 5
68 // CHECK-NEXT:   (('r_offset', 0x00000023)
69 // CHECK-NEXT:    ('r_sym', 0x00000008)
70 // CHECK-NEXT:    ('r_type', 0x0000000b)
71 // CHECK-NEXT:    ('r_addend', 0x0000000000000000)
72 // CHECK-NEXT:   ),
73 // CHECK-NEXT:  ])
74
75 // Section 5 is "sec1"
76 // CHECK: # Section 5
77 // CHECK-NEXT:  (('sh_name', 0x00000035) # '.sec1'
78
79 // Symbol number 1 is .Lfoo
80 // CHECK:      # Symbol 1
81 // CHECK-NEXT: (('st_name', 0x00000001) # '.Lfoo'
82
83 // Symbol number 2 is foo
84 // CHECK:      # Symbol 2
85 // CHECK-NEXT: (('st_name', 0x00000007) # 'foo'
86
87 // Symbol number 6 is section 5
88 // CHECK:        # Symbol 6
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)
94
95 // Symbol number 8 is zed
96 // CHECK:        # Symbol 8
97 // CHECK-NEXT:    (('st_name', 0x0000000b) # 'zed'