Recommit "rL366894: [yaml2obj] - Allow custom fields for the SHT_UNDEF sections."
[llvm-complete.git] / test / tools / llvm-readobj / elf-packed-relocs.test
blob4de725d130a7d6a6e9b3d654dbdbe950032d45a5
1 # The binary blobs in this file were created like this:
2 # llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu Inputs/elf-packed-relocs1.s -o - | obj2yaml | grep Content:
4 # RUN: yaml2obj -docnum 1 %s | llvm-readobj --relocations - | FileCheck --check-prefix=LLVM1 %s
5 # LLVM1:      Section (1) .rela.dyn {
6 # LLVM1-NEXT:   0x1100 R_X86_64_RELATIVE - 0x0
7 # LLVM1-NEXT:   0x1180 R_X86_64_RELATIVE - 0x0
8 # LLVM1-NEXT:   0x1188 R_X86_64_64 sym1 0x0
9 # LLVM1-NEXT:   0x1190 R_X86_64_64 sym2 0x0
10 # LLVM1-NEXT:   0x1191 R_X86_64_64 sym1 0x8
11 # LLVM1-NEXT:   0x1193 R_X86_64_64 sym2 0xC
12 # LLVM1-NEXT:   0x1197 R_X86_64_64 sym1 0xA
13 # LLVM1-NEXT:   0x119F R_X86_64_64 sym2 0xA
14 # LLVM1-NEXT: }
16 # RUN: yaml2obj -docnum 1 %s | llvm-readelf -relocations - | FileCheck --check-prefix=GNU1 %s
17 # GNU1:      Relocation section '.rela.dyn' at offset 0x180 contains 8 entries:
18 # GNU1:      0000000000001100  0000000000000008 R_X86_64_RELATIVE                 0
19 # GNU1-NEXT: 0000000000001180  0000000000000008 R_X86_64_RELATIVE                 0
20 # GNU1-NEXT: 0000000000001188  0000000100000001 R_X86_64_64            0000000000000000 sym1 + 0
21 # GNU1-NEXT: 0000000000001190  0000000200000001 R_X86_64_64            0000000000000000 sym2 + 0
22 # GNU1-NEXT: 0000000000001191  0000000100000001 R_X86_64_64            0000000000000000 sym1 + 8
23 # GNU1-NEXT: 0000000000001193  0000000200000001 R_X86_64_64            0000000000000000 sym2 + c
24 # GNU1-NEXT: 0000000000001197  0000000100000001 R_X86_64_64            0000000000000000 sym1 + a
25 # GNU1-NEXT: 000000000000119f  0000000200000001 R_X86_64_64            0000000000000000 sym2 + a
27 # elf-packed-relocs1.s
28 --- !ELF
29 FileHeader:
30   Class:           ELFCLASS64
31   Data:            ELFDATA2LSB
32   Type:            ET_DYN
33   Machine:         EM_X86_64
34   Entry:           0x0000000000001000
35 Sections:
36   - Name:            .rela.dyn
37     Type:            SHT_ANDROID_RELA
38     Flags:           [ SHF_ALLOC ]
39     Address:         0x00000000000001C8
40     Link:            .symtab
41     AddressAlign:    0x0000000000000001
42     Content:         41505332088020020108800280010202088180808010818080802002080181808080100802818080802004020C7E048180808010088180808020
43 Symbols:
44   - Name:            sym1
45     Binding:         STB_GLOBAL
46   - Name:            sym2
47     Binding:         STB_GLOBAL
48 ...
50 # RUN: yaml2obj -docnum 2 %s | llvm-readobj --relocations - | FileCheck --check-prefix=LLVM2 %s
51 # LLVM2:      Section (1) .rel.dyn {
52 # LLVM2-NEXT:   0x1008 R_386_32 sym1 0x0
53 # LLVM2-NEXT:   0x1010 R_386_GOT32 sym2 0x0
54 # LLVM2-NEXT:   0x100C R_386_RELATIVE - 0x0
55 # LLVM2-NEXT:   0x1008 R_386_RELATIVE - 0x0
56 # LLVM2-NEXT:   0x1004 R_386_RELATIVE - 0x0
57 # LLVM2-NEXT:   0x1000 R_386_RELATIVE - 0x0
58 # LLVM2-NEXT:   0xFFC R_386_RELATIVE - 0x0
59 # LLVM2-NEXT:   0xFF8 R_386_RELATIVE - 0x0
60 # LLVM2-NEXT:   0xFF4 R_386_RELATIVE - 0x0
61 # LLVM2-NEXT:   0xFF0 R_386_RELATIVE - 0x0
62 # LLVM2-NEXT: }
64 # RUN: yaml2obj -docnum 2 %s | llvm-readelf -relocations - | FileCheck --check-prefix=GNU2 %s
65 # GNU2:      Relocation section '.rel.dyn' at offset 0xfc contains 10 entries:
66 # GNU2:      00001008  00000101 R_386_32               00000000   sym1
67 # GNU2-NEXT: 00001010  00000203 R_386_GOT32            00000000   sym2
68 # GNU2-NEXT: 0000100c  00000008 R_386_RELATIVE
69 # GNU2-NEXT: 00001008  00000008 R_386_RELATIVE
70 # GNU2-NEXT: 00001004  00000008 R_386_RELATIVE
71 # GNU2-NEXT: 00001000  00000008 R_386_RELATIVE
72 # GNU2-NEXT: 00000ffc  00000008 R_386_RELATIVE
73 # GNU2-NEXT: 00000ff8  00000008 R_386_RELATIVE
74 # GNU2-NEXT: 00000ff4  00000008 R_386_RELATIVE
75 # GNU2-NEXT: 00000ff0  00000008 R_386_RELATIVE
77 # elf-packed-relocs2.s
78 --- !ELF
79 FileHeader:
80   Class:           ELFCLASS32
81   Data:            ELFDATA2LSB
82   Type:            ET_DYN
83   Machine:         EM_386
84   Entry:           0x0000000000001000
85 Sections:
86   - Name:            .rel.dyn
87     Type:            SHT_ANDROID_REL
88     Flags:           [ SHF_ALLOC ]
89     Address:         0x00000000000001C8
90     Link:            .symtab
91     AddressAlign:    0x0000000000000001
92     Content:         415053320A80200202088102830408037C08
93 Symbols:
94   - Name:            sym1
95     Binding:         STB_GLOBAL
96   - Name:            sym2
97     Binding:         STB_GLOBAL
98 ...
100 # RUN: yaml2obj -docnum 3 %s | llvm-readobj --relocations - | FileCheck --check-prefix=LLVM3 %s
102 # LLVM3:      Section (1) .rela.dyn {
103 # LLVM3-NEXT:   0x1100 R_X86_64_RELATIVE - 0x0
104 # LLVM3-NEXT:   0x1180 R_X86_64_RELATIVE - 0x8
105 # LLVM3-NEXT:   0x1200 R_X86_64_64 sym1 0x0
106 # LLVM3-NEXT:   0x1208 R_X86_64_64 sym2 0x0
107 # LLVM3-NEXT:   0x1210 R_X86_64_64 sym1 0x0
108 # LLVM3-NEXT:   0x1218 R_X86_64_64 sym2 0x8
109 # LLVM3-NEXT: }
111 # RUN: yaml2obj -docnum 3 %s | llvm-readelf -relocations - | FileCheck --check-prefix=GNU3 %s
112 # GNU3:      Relocation section '.rela.dyn' at offset 0x180 contains 6 entries:
113 # GNU3: 0000000000001100  0000000000000008 R_X86_64_RELATIVE                 0
114 # GNU3-NEXT: 0000000000001180  0000000000000008 R_X86_64_RELATIVE                 8
115 # GNU3-NEXT: 0000000000001200  0000000100000001 R_X86_64_64            0000000000000000 sym1 + 0
116 # GNU3-NEXT: 0000000000001208  0000000200000001 R_X86_64_64            0000000000000000 sym2 + 0
117 # GNU3-NEXT: 0000000000001210  0000000100000001 R_X86_64_64            0000000000000000 sym1 + 0
118 # GNU3-NEXT: 0000000000001218  0000000200000001 R_X86_64_64            0000000000000000 sym2 + 8
120 # elf-packed-relocs3.s
121 --- !ELF
122 FileHeader:
123   Class:           ELFCLASS64
124   Data:            ELFDATA2LSB
125   Type:            ET_DYN
126   Machine:         EM_X86_64
127   Entry:           0x0000000000001000
128 Sections:
129   - Name:            .rela.dyn
130     Type:            SHT_ANDROID_RELA
131     Flags:           [ SHF_ALLOC ]
132     Address:         0x00000000000001C8
133     Link:            .symtab
134     AddressAlign:    0x0000000000000001
135     Content:         415053320680200208800208008001080802008001818080801008818080802002080881808080100008818080802008
136 Symbols:
137   - Name:            sym1
138     Binding:         STB_GLOBAL
139   - Name:            sym2
140     Binding:         STB_GLOBAL