xref: /llvm-project/llvm/test/tools/llvm-objdump/X86/section-filter-relocs.test (revision 87de9a0786d922a1b52db6cd8b12f642d1d00d85)
1## Test that --section works correctly for -d with -r.
2# RUN: yaml2obj %s -o %t.o
3
4## Show that only the specified sections are disassembled.
5## Also show that no relocation sections are dumped because none are
6## specified.
7# RUN: llvm-objdump -d -r %t.o --section=.text --section=.rodata \
8# RUN:   | FileCheck %s --check-prefixes=DISASM,RELOC --implicit-check-not=.text2
9
10# DISASM:       Disassembly of section .text:
11# DISASM-EMPTY:
12# DISASM-NEXT:  0000000000000400 <.text>:
13# DISASM-NEXT:  400: e8 00 00 00 00                callq   0x405 <.text+0x5>
14# RELOC-NEXT:                      00000401:  R_X86_64_PC32        foo+0x1
15# RELOC-NEXT:                      00000401:  R_X86_64_GOT32       foo
16# DISASM:       Disassembly of section .rodata:
17# DISASM-EMPTY:
18# DISASM-NEXT:  0000000000000000 <.rodata>:
19# DISASM-NEXT:  0: 00 00                           addb    %al, (%rax)
20# RELOC-NEXT:              0000000000000000:  R_X86_64_NONE        foo
21# DISASM-NEXT:  2: 00 00                           addb    %al, (%rax)
22
23--- !ELF
24FileHeader:
25  Class:   ELFCLASS64
26  Data:    ELFDATA2LSB
27  Type:    ET_REL
28  Machine: EM_X86_64
29Sections:
30  - Name:         .text
31    Type:         SHT_PROGBITS
32    Flags:        [SHF_ALLOC, SHF_EXECINSTR]
33    Address:      0x400
34    AddressAlign: 0x10
35    Content:      'e800000000'
36  - Name:         .text2
37    Type:         SHT_PROGBITS
38    Flags:        [SHF_ALLOC, SHF_EXECINSTR]
39    Address:      0x401
40    Content:      '90e800000000'
41  - Name:         .rela.text
42    Type:         SHT_RELA
43    Info:         .text
44    Relocations:
45      - Offset: 1
46        Symbol: foo
47        Addend: 1
48        Type:   R_X86_64_PC32
49  - Name:         .another.rela.text
50    Type:         SHT_RELA
51    Info:         .text
52    Relocations:
53      - Offset: 1
54        Symbol: foo
55        Type:   R_X86_64_GOT32
56  - Name:         .rela.text2
57    Type:         SHT_RELA
58    Info:         .text2
59    Relocations:
60      - Offset: 1
61        Symbol: foo
62        Addend: 2
63        Type:   R_X86_64_PLT32
64  - Name:       .rodata
65    Type:       SHT_PROGBITS
66    Flags:      [SHF_ALLOC]
67    Size:       4
68  - Name:       .rela.rodata
69    Type:       SHT_RELA
70    Info:       .rodata
71    Relocations:
72      - Offset: 0
73        Symbol: foo
74        Type: R_X86_64_NONE
75Symbols:
76  - Name: foo
77
78## Test that --section works when dumping relocation sections.
79# RUN: llvm-objdump -r %t.o --section=.another.rela.text --section=.rela.rodata \
80# RUN:   | FileCheck %s --check-prefix=DUMP-RELOCS --implicit-check-not=R_X86_64 \
81# RUN:                  --implicit-check-not="RELOCATION RECORDS"
82
83# DUMP-RELOCS: RELOCATION RECORDS FOR [.text]:
84# DUMP-RELOCS: 00000001 R_X86_64_GOT32 foo
85# DUMP-RELOCS: RELOCATION RECORDS FOR [.rodata]:
86# DUMP-RELOCS: 00000000 R_X86_64_NONE foo
87
88## Test that --section works with --full-contents.
89# RUN: llvm-objdump -s %t.o --section=.text --section=.rela.text2 \
90# RUN:   | FileCheck %s --check-prefix=CONTENTS \
91# RUN:                  --implicit-check-not=.text \
92# RUN:                  --implicit-check-not=.rodata
93
94# CONTENTS: Contents of section .text:
95# CONTENTS: Contents of section .rela.text2:
96