xref: /llvm-project/llvm/test/Object/objdump-relocations.test (revision ecd6d7254e6452bd4663a473f46bd13bcf2bfeec)
1# RUN: llvm-objdump -r %p/Inputs/trivial-object-test.coff-i386 \
2# RUN:              | FileCheck %s -check-prefix COFF-i386
3# RUN: llvm-objdump -r %p/Inputs/trivial-object-test.coff-x86-64 \
4# RUN:              | FileCheck %s -check-prefix COFF-x86-64
5
6# RUN: yaml2obj --docnum=1 %s -o %t-i386
7# RUN: llvm-objdump -r %t-i386 | FileCheck %s --check-prefix=ELF-i386
8
9# ELF-i386: .text
10# ELF-i386: R_386_32 .section
11# ELF-i386: R_386_PC32 symbol
12
13--- !ELF
14FileHeader:
15  Class:   ELFCLASS32
16  Data:    ELFDATA2LSB
17  Type:    ET_REL
18  Machine: EM_386
19Sections:
20  - Name: .text
21    Type: SHT_PROGBITS
22  - Name: .section
23    Type: SHT_PROGBITS
24  - Name: .rel.text
25    Type: SHT_REL
26    Link: .symtab
27    Info: .text
28    Relocations:
29      - Symbol: .section
30        Type:   R_386_32
31      - Offset: 0x1
32        Symbol: symbol
33        Type:   R_386_PC32
34Symbols:
35  - Name:    .section
36    Type:    STT_SECTION
37    Section: .section
38  - Name:    symbol
39    Binding: STB_GLOBAL
40
41# RUN: yaml2obj --docnum=2 %s -o %t-x86-64
42# RUN: llvm-objdump -r %t-x86-64 | FileCheck %s --check-prefix=ELF-x86-64
43
44# ELF-x86-64: .text
45# ELF-x86-64: R_X86_64_32S .section
46# ELF-x86-64: R_X86_64_PC32 symbol
47
48--- !ELF
49FileHeader:
50  Class:   ELFCLASS32
51  Data:    ELFDATA2LSB
52  Type:    ET_REL
53  Machine: EM_X86_64
54Sections:
55  - Name: .text
56    Type: SHT_PROGBITS
57  - Name: .section
58    Type: SHT_PROGBITS
59  - Name: .rel.text
60    Type: SHT_REL
61    Link: .symtab
62    Info: .text
63    Relocations:
64      - Symbol: .section
65        Type:   R_X86_64_32S
66      - Offset: 0x1
67        Symbol: symbol
68        Type:   R_X86_64_PC32
69Symbols:
70  - Name:    .section
71    Type:    STT_SECTION
72    Section: .section
73  - Name:    symbol
74    Binding: STB_GLOBAL
75
76# RUN: llvm-objdump -r %p/Inputs/trivial-object-test.elf-hexagon \
77# RUN:              | FileCheck %s -check-prefix ELF-hexagon
78# RUN: llvm-objdump -r %p/Inputs/trivial-object-test.elf-mips64el \
79# RUN:              | FileCheck %s -check-prefix ELF-MIPS64EL
80# RUN: llvm-objdump -r %p/Inputs/trivial-object-test.elf-mipsel \
81# RUN:              | FileCheck %s -check-prefix ELF-MIPSEL
82# RUN: llvm-objdump -r %p/Inputs/trivial-object-test.wasm \
83# RUN:              | FileCheck %s -check-prefix WASM
84
85# RUN: llvm-objdump -r %p/Inputs/relocations.elf-x86-64 \
86# RUN:              | FileCheck %s -check-prefix ELF-complex-x86-64
87
88# COFF-i386: .text
89# COFF-i386: IMAGE_REL_I386_DIR32 L_.str
90# COFF-i386: IMAGE_REL_I386_REL32 _puts
91# COFF-i386: IMAGE_REL_I386_REL32 _SomeOtherFunction
92
93# COFF-x86-64: .text
94# COFF-x86-64: IMAGE_REL_AMD64_REL32 L.str
95# COFF-x86-64: IMAGE_REL_AMD64_REL32 puts
96# COFF-x86-64: IMAGE_REL_AMD64_REL32 SomeOtherFunction
97
98# ELF-hexagon: .text
99# ELF-hexagon: R_HEX_GOTREL_HI16 .main
100# ELF-hexagon: R_HEX_GOTREL_LO16 .main
101# ELF-hexagon: R_HEX_HI16 puts
102# ELF-hexagon: R_HEX_LO16 puts
103# ELF-hexagon: R_HEX_B15_PCREL testf
104# ELF-hexagon: R_HEX_B22_PCREL puts
105
106## Note: this file was produced with gas to make sure we don't end up in a
107## situation where LLVM produces and accepts a broken file.
108# ELF-MIPS64EL: .data
109# ELF-MIPS64EL: R_MIPS_64/R_MIPS_NONE/R_MIPS_NONE zed
110
111# ELF-MIPSEL: .text
112# ELF-MIPSEL: R_MIPS_HI16 _gp_disp
113# ELF-MIPSEL: R_MIPS_LO16 _gp_disp
114# ELF-MIPSEL: R_MIPS_GOT16 $.str
115# ELF-MIPSEL: R_MIPS_LO16 $.str
116# ELF-MIPSEL: R_MIPS_CALL16 puts
117# ELF-MIPSEL: R_MIPS_CALL16 SomeOtherFunction
118
119# WASM:      CODE
120# WASM-NEXT: OFFSET TYPE VALUE
121# WASM-NEXT: R_WASM_MEMORY_ADDR_SLEB .L.str
122# WASM-NEXT: R_WASM_FUNCTION_INDEX_LEB puts
123# WASM-NEXT: R_WASM_FUNCTION_INDEX_LEB .LSomeOtherFunction_bitcast
124# WASM-NEXT: R_WASM_FUNCTION_INDEX_LEB SomeOtherFunction
125
126# ELF-complex-x86-64: .text
127# ELF-complex-x86-64-NEXT: OFFSET TYPE VALUE
128# ELF-complex-x86-64-NEXT: R_X86_64_8 .data-0x4
129# ELF-complex-x86-64-NEXT: R_X86_64_16 .data-0x4
130# ELF-complex-x86-64-NEXT: R_X86_64_32 .data-0x4
131# ELF-complex-x86-64-NEXT: R_X86_64_32S .data-0x4
132# ELF-complex-x86-64-NEXT: R_X86_64_64 .data-0x4
133# ELF-complex-x86-64-NEXT: R_X86_64_PC32 .data-0x4
134# ELF-complex-x86-64-NEXT: R_X86_64_32 .data
135# ELF-complex-x86-64-NEXT: R_X86_64_32 .data+0x4
136