xref: /llvm-project/llvm/test/tools/llvm-readobj/ELF/dynamic-reloc-no-section-headers.test (revision 9c89dcf80736a7c0710dc4c237ec35f0687e1efd)
1## Test that we are able to print dynamic relocations with --dyn-relocations
2## even when there are no section headers.
3
4# RUN: yaml2obj %s -o %t
5# RUN: llvm-readobj --dyn-relocations %t 2>&1 \
6# RUN:  | FileCheck %s -DFILE=%t --implicit-check-not="warning:" --check-prefix=LLVM-NO-SEC-TABLE
7# RUN: llvm-readelf --dyn-relocations %t 2>&1 \
8# RUN:  | FileCheck %s -DFILE=%t --implicit-check-not="warning:" --check-prefix=GNU-NO-SEC-TABLE
9
10# LLVM-NO-SEC-TABLE:      Dynamic Relocations {
11# LLVM-NO-SEC-TABLE-NEXT:   0x0 R_X86_64_NONE foo 0x0
12# LLVM-NO-SEC-TABLE-NEXT: }
13
14# GNU-NO-SEC-TABLE:      'RELA' relocation section at offset 0xb0 contains 24 bytes:
15# GNU-NO-SEC-TABLE-NEXT: Offset            Info             Type             Symbol's Value   Symbol's Name + Addend
16# GNU-NO-SEC-TABLE-NEXT: 0000000000000000  0000000100000000 R_X86_64_NONE    0000000000000000 foo + 0
17
18--- !ELF
19FileHeader:
20  Class:   ELFCLASS64
21  Data:    ELFDATA2LSB
22  Type:    ET_DYN
23  Machine: EM_X86_64
24Sections:
25  - Name:    .rela.dyn
26    Type:    SHT_RELA
27    Relocations:
28      - Type:   R_X86_64_NONE
29        Symbol: 0x1
30  - Name: .dynamic
31    Type: SHT_DYNAMIC
32    Entries:
33      - Tag:   DT_RELA
34        Value: 0x0
35      - Tag:   DT_RELASZ
36        Value: 0x18
37      - Tag:   DT_RELAENT
38        Value: 0x18
39## Offset of .dynsym is 0x138. Offset of PT_LOAD is 0xb0.
40## 0x138 - 0xb0 == 0x88
41      - Tag:   DT_SYMTAB
42        Value: 0x88
43      - Tag:   DT_STRSZ
44        Value: 0x5
45## Offset of .dynstr is 0x168. Offset of PT_LOAD is 0xb0.
46## 0x168 - 0xb0 == 0xb8
47      - Tag:   DT_STRTAB
48        Value: 0xb8
49      - Tag:   DT_NULL
50        Value: 0x0
51  - Name:    .dynsym
52    Type:    SHT_DYNSYM
53  - Type: SectionHeaderTable
54    NoHeaders: true
55DynamicSymbols:
56  - Name: foo
57ProgramHeaders:
58  - Type:     PT_LOAD
59    FirstSec: .rela.dyn
60    LastSec:  .dynstr
61  - Type:     PT_DYNAMIC
62    FirstSec: .dynamic
63    LastSec:  .dynamic
64