Fixed version of 121434 with no new memory leaks.
[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 // Section 4 is "sec1"
26 // CHECK: # Section 0x00000004
27 // CHECK-NEXT:  (('sh_name', 0x00000012) # '.sec1'
28
29 // Symbol number 1 is .Lfoo
30 // CHECK:      # Symbol 0x00000001
31 // CHECK-NEXT: (('st_name', 0x00000001) # '.Lfoo'
32
33 // Symbol number 2 is foo
34 // CHECK:      # Symbol 0x00000002
35 // CHECK-NEXT: (('st_name', 0x00000007) # 'foo'
36
37 // Symbol number 6 is section 4
38 // CHECK:        # Symbol 0x00000006
39 // CHECK-NEXT:    (('st_name', 0x00000000) # ''
40 // CHECK-NEXT:     ('st_bind', 0x00000000)
41 // CHECK-NEXT:     ('st_type', 0x00000003)
42 // CHECK-NEXT:     ('st_other', 0x00000000)
43 // CHECK-NEXT:     ('st_shndx', 0x00000004)
44
45 // Symbol number 8 is zed
46 // CHECK:        # Symbol 0x00000008
47 // CHECK-NEXT:    (('st_name', 0x0000000b) # 'zed'
48
49 // Relocation 0 refers to symbol 1
50 // CHECK:       ('_relocations', [
51 // CHECK-NEXT:   # Relocation 0
52 // CHECK-NEXT:   (('r_offset',
53 // CHECK-NEXT:    ('r_sym', 0x00000001)
54 // CHECK-NEXT:    ('r_type', 0x00000002
55 // CHECK-NEXT:    ('r_addend',
56 // CHECK-NEXT:   ),
57
58 // Relocation 1 refers to symbol 6
59 // CHECK-NEXT:  # Relocation 0x00000001
60 // CHECK-NEXT: (('r_offset',
61 // CHECK-NEXT:  ('r_sym', 0x00000006)
62 // CHECK-NEXT:  ('r_type', 0x0000000a)
63 // CHECK-NEXT:  ('r_addend',
64 // CHECK-NEXT: ),
65
66 // Relocation 2 refers to symbol 1
67 // CHECK-NEXT:   # Relocation 0x00000002
68 // CHECK-NEXT:   (('r_offset',
69 // CHECK-NEXT:    ('r_sym', 0x00000001)
70 // CHECK-NEXT:    ('r_type', 0x0000000a
71 // CHECK-NEXT:    ('r_addend',
72 // CHECK-NEXT:   ),
73
74 // Relocation 3 refers to symbol 2
75 // CHECK-NEXT:   # Relocation 0x00000003
76 // CHECK-NEXT:   (('r_offset',
77 // CHECK-NEXT:    ('r_sym', 0x00000002)
78 // CHECK-NEXT:    ('r_type', 0x00000004
79 // CHECK-NEXT:    ('r_addend',
80 // CHECK-NEXT:   ),
81
82 // Relocation 4 refers to symbol 2
83 // CHECK-NEXT:   # Relocation 0x00000004
84 // CHECK-NEXT:   (('r_offset',
85 // CHECK-NEXT:    ('r_sym', 0x00000002)
86 // CHECK-NEXT:    ('r_type', 0x00000009
87 // CHECK-NEXT:    ('r_addend',
88 // CHECK-NEXT:   ),
89
90 // Relocation 5 refers to symbol 8
91 // CHECK-NEXT:   # Relocation 0x00000005
92 // CHECK-NEXT:   (('r_offset', 0x00000023)
93 // CHECK-NEXT:    ('r_sym', 0x00000008)
94 // CHECK-NEXT:    ('r_type', 0x0000000b)
95 // CHECK-NEXT:    ('r_addend', 0x00000000)
96 // CHECK-NEXT:   ),
97 // CHECK-NEXT:  ])