.symidx bar
.symidx foo
-// CHECK: Contents of section .data:
-// CHECK-NEXT: 0000 0[[BAR:[1-9]]]000000 0[[FOO:[1-9]]]000000
// CHECK: SYMBOL TABLE:
-// CHECK: [ [[FOO]]](sec 1)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x00000000 foo
-// CHECK-NEXT: [ [[BAR]]](sec 1)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x00000001 bar
+// CHECK: [ [[FOO:[1-9]]]](sec 1)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x00000000 foo
+// CHECK-NEXT: [ [[BAR:[1-9]]]](sec 1)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x00000001 bar
+// CHECK: Contents of section .data:
+// CHECK-NEXT: 0000 0[[BAR]]000000 0[[FOO]]000000
# RUN: llvm-objdump --all-headers -D -z --adjust-vma=0x0 %t | FileCheck %s --check-prefixes=COMMON,NOADJUST
# RUN: llvm-objdump --all-headers -D -z --adjust-vma=0x123000 %t | FileCheck %s --check-prefixes=COMMON,ADJUST
+# NOADJUST: Sections:
+# NOADJUST-NEXT: Idx Name Size VMA Type
+# NOADJUST-NEXT: 0 00000000 0000000000000000
+# NOADJUST-NEXT: 1 .text 00000002 0000000000000000 TEXT
+# NOADJUST-NEXT: 2 .debug_str 00000004 0000000000000000
+# NOADJUST-NEXT: 3 .rela.debug_str 00000018 0000000000000000
+# NOADJUST-NEXT: 4 .data 00000004 0000000000000000 DATA
+# NOADJUST-NEXT: 5 .rela.data 00000018 0000000000000000
+# NOADJUST-NEXT: 6 .symtab 00000060 0000000000000000
+# NOADJUST-NEXT: 7 .strtab 00000010 0000000000000000
+# NOADJUST-NEXT: 8 .shstrtab 0000003c 0000000000000000
+
+# ADJUST: Sections:
+# ADJUST-NEXT: Idx Name Size VMA Type
+# ADJUST-NEXT: 0 00000000 0000000000000000
+# ADJUST-NEXT: 1 .text 00000002 0000000000123000 TEXT
+# ADJUST-NEXT: 2 .debug_str 00000004 0000000000000000
+# ADJUST-NEXT: 3 .rela.debug_str 00000018 0000000000000000
+# ADJUST-NEXT: 4 .data 00000004 0000000000123000 DATA
+# ADJUST-NEXT: 5 .rela.data 00000018 0000000000000000
+# ADJUST-NEXT: 6 .symtab 00000060 0000000000000000
+# ADJUST-NEXT: 7 .strtab 00000010 0000000000000000
+# ADJUST-NEXT: 8 .shstrtab 0000003c 0000000000000000
+
+# COMMON: SYMBOL TABLE:
+# COMMON-NEXT: 0000000000000001 l F .text 00000000 func
+# COMMON-NEXT: 0000000000000000 .text 00000000 sym
+# COMMON-NEXT: 0000000000000000 l d .text 00000000 .text
+
# NOADJUST: 0000000000000000 sym:
# NOADJUST-NEXT: 0: {{.*}} nop
# NOADJUST: 0000000000000001 func:
# COMMON-NEXT: 0: {{.*}} addb %al, (%rax)
## ... There are more lines here. We do not care.
-# NOADJUST: Sections:
-# NOADJUST-NEXT: Idx Name Size VMA Type
-# NOADJUST-NEXT: 0 00000000 0000000000000000
-# NOADJUST-NEXT: 1 .text 00000002 0000000000000000 TEXT
-# NOADJUST-NEXT: 2 .debug_str 00000004 0000000000000000
-# NOADJUST-NEXT: 3 .rela.debug_str 00000018 0000000000000000
-# NOADJUST-NEXT: 4 .data 00000004 0000000000000000 DATA
-# NOADJUST-NEXT: 5 .rela.data 00000018 0000000000000000
-# NOADJUST-NEXT: 6 .symtab 00000060 0000000000000000
-# NOADJUST-NEXT: 7 .strtab 00000010 0000000000000000
-# NOADJUST-NEXT: 8 .shstrtab 0000003c 0000000000000000
-
-# ADJUST: Sections:
-# ADJUST-NEXT: Idx Name Size VMA Type
-# ADJUST-NEXT: 0 00000000 0000000000000000
-# ADJUST-NEXT: 1 .text 00000002 0000000000123000 TEXT
-# ADJUST-NEXT: 2 .debug_str 00000004 0000000000000000
-# ADJUST-NEXT: 3 .rela.debug_str 00000018 0000000000000000
-# ADJUST-NEXT: 4 .data 00000004 0000000000123000 DATA
-# ADJUST-NEXT: 5 .rela.data 00000018 0000000000000000
-# ADJUST-NEXT: 6 .symtab 00000060 0000000000000000
-# ADJUST-NEXT: 7 .strtab 00000010 0000000000000000
-# ADJUST-NEXT: 8 .shstrtab 0000003c 0000000000000000
-
-# COMMON: SYMBOL TABLE:
-# COMMON-NEXT: 0000000000000001 l F .text 00000000 func
-# COMMON-NEXT: 0000000000000000 .text 00000000 sym
-# COMMON-NEXT: 0000000000000000 l d .text 00000000 .text
-
--- !ELF
FileHeader:
Class: ELFCLASS64
# RUN: llvm-mc %s -filetype=obj -triple=x86_64-pc-linux -o %t
# RUN: llvm-objdump -t -r --demangle %t | FileCheck %s
-## Check we demangle symbols when printing relocations.
-# CHECK: 000000000000001 R_X86_64_PLT32 foo()-4
-
## Check we demangle symbols when printing symbol table.
# CHECK: SYMBOL TABLE:
# CHECK-NEXT: 0000000000000000 g F .text 00000000 foo()
+## Check we demangle symbols when printing relocations.
+# CHECK: 000000000000001 R_X86_64_PLT32 foo()-4
+
## Check the case when relocations are inlined into disassembly.
# RUN: llvm-objdump -d -r --demangle %t | FileCheck %s --check-prefix=INLINE
# INLINE: foo():
// RUN: cmp %t0 %t1
// RUN: FileCheck --input-file %t0 %s
-CHECK: Disassembly of section .text:
-CHECK-EMPTY:
-CHECK-NEXT: _start:
-CHECK-NEXT: 10: c3 retl
-CHECK-NEXT: SYMBOL TABLE:
+CHECK: SYMBOL TABLE:
CHECK-NEXT: 00000010 l d .text 00000000 .text
CHECK-NEXT: 00000010 .text 00000000 _start
CHECK-NEXT: 00000020 .text 00000000 _fdata
CHECK-NEXT: 00000010 .text 00000000 _ftext
+CHECK-EMPTY:
+CHECK-NEXT: Disassembly of section .text:
+CHECK-EMPTY:
+CHECK-NEXT: _start:
+CHECK-NEXT: 10: c3 retl
# RUN: yaml2obj %s > %t
# RUN: llvm-objdump --all-headers %t | FileCheck %s
-## Check we print file format, architecture and start address followed by the
-## other data when using --all-headers.
+## Note: --all-headers (-x) is an alias for --archive-headers --file-headers
+## --section-headers --private-headers --reloc --syms (-afhprt). Test for them
+## in the following order which provides GNU objdump compatability.
# CHECK: file format ELF64-x86-64
# CHECK-EMPTY:
# CHECK: Dynamic Section:
# CHECK: Sections:
# CHECK: SYMBOL TABLE:
+# CHECK: RELOCATION RECORDS FOR [.text]:
## Check how we dump the archives.
## Check we dump the appropriate headers for each file in the archive.
# RUN: llvm-objdump --all-headers %t.a | FileCheck %s --check-prefix=ARCHIVE
# ARCHIVE: {{.*}}.a({{.*}}): file format ELF64-x86-64
+# ARCHIVE: rw-r--r--
# ARCHIVE: architecture: x86_64
# ARCHIVE: start address: 0x0000000000000000
-# ARCHIVE: rw-r--r--
# ARCHIVE: Program Header:
# ARCHIVE: Dynamic Section:
# ARCHIVE: Sections:
# ARCHIVE: SYMBOL TABLE:
+# ARCHIVE: RELOCATION RECORDS FOR [.text]:
# ARCHIVE: {{.*}}.a({{.*}}2): file format ELF64-x86-64
+# ARCHIVE: rw-r--r--
# ARCHIVE: architecture: x86_64
# ARCHIVE: start address: 0x0000000000000000
-# ARCHIVE: rw-r--r--
# ARCHIVE: Program Header:
# ARCHIVE: Dynamic Section:
# ARCHIVE: Sections:
# ARCHIVE: SYMBOL TABLE:
+# ARCHIVE: RELOCATION RECORDS FOR [.text]:
!ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
- Type: ET_EXEC
+ Type: ET_REL
Machine: EM_X86_64
Sections:
+ - Name: .text
+ Type: SHT_PROGBITS
+ - Name: .rel.text
+ Type: SHT_REL
+ Info: .text
+ Relocations:
+ - Offset: 0x1
+ Symbol: foo
+ Type: R_X86_64_32
+ - Name: .dynamic
+ Type: SHT_DYNAMIC
+ Flags: [ SHF_WRITE, SHF_ALLOC ]
+ EntSize: 0x0000000000000010
+ Entries:
+ - Tag: DT_INIT
+ Value: 0x00000000000006A0
+ - Tag: DT_NULL
+ Value: 0x0000000000000000
+Symbols:
+ - Name: foo
+ Section: .text
--- /dev/null
+# RUN: yaml2obj %s > %t.o
+# RUN: llvm-objdump --file-headers --private-headers --section-headers --syms \
+# RUN: --full-contents --dwarf=frames \
+# RUN: --reloc %t.o | FileCheck %s --check-prefixes=CHECK,RELOC
+# RUN: llvm-objdump --file-headers --private-headers --section-headers --syms \
+# RUN: --full-contents --dwarf=frames \
+# RUN: --disassemble %t.o | FileCheck %s --check-prefixes=CHECK,DISASM
+
+## Test the ordering of most of the output. Note that --disassemble suppresses
+## --reloc, so we test them independently.
+
+## File headers (-f)
+# CHECK: file format ELF64-x86-64
+# CHECK: architecture: x86_64
+# CHECK: start address: 0x0000000000000000
+## Private headers (-p)
+# CHECK: Program Header:
+# CHECK: Dynamic Section:
+## Section headers (-h)
+# CHECK: Sections:
+## Symbol table (-t)
+# CHECK: SYMBOL TABLE:
+## DWARF contents:
+# CHECK: .eh_frame contents:
+## Relocations (-r)
+# RELOC: RELOCATION RECORDS FOR [.text]:
+## Section contents (-s)
+# CHECK: Contents of section .rel.text:
+# CHECK: Contents of section .dynamic:
+# CHECK: Contents of section .symtab:
+# CHECK: Contents of section .strtab:
+# CHECK: Contents of section .shstrtab:
+## Disassembly (-d)
+# DISASM: Disassembly of section .text:
+
+!ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_X86_64
+Sections:
+ - Name: .text
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+ Content: e800000000e800000000
+ - Name: .rel.text
+ Type: SHT_REL
+ Info: .text
+ Relocations:
+ - Offset: 0x1
+ Symbol: foo
+ Type: R_X86_64_32
+ - Name: .dynamic
+ Type: SHT_DYNAMIC
+ Flags: [ SHF_WRITE, SHF_ALLOC ]
+ EntSize: 0x0000000000000010
+ Entries:
+ - Tag: DT_INIT
+ Value: 0x00000000000006A0
+ - Tag: DT_NULL
+ Value: 0x0000000000000000
+ - Name: .eh_frame
+ Type: SHT_X86_64_UNWIND
+ Flags: [ SHF_ALLOC ]
+ AddressAlign: 0x0000000000000001
+ Content: 00000000
+Symbols:
+ - Name: foo
+ Section: .text
if (StartAddress.getNumOccurrences() || StopAddress.getNumOccurrences())
checkForInvalidStartStopAddress(O, StartAddress, StopAddress);
+ // Note: the order here matches GNU objdump for compatability.
StringRef ArchiveName = A ? A->getFileName() : "";
- if (FileHeaders)
- printFileHeaders(O);
if (ArchiveHeaders && !MachOOpt && C)
printArchiveChild(ArchiveName, *C);
- if (Disassemble)
- disassembleObject(O, Relocations);
- if (Relocations && !Disassemble)
- printRelocations(O);
- if (DynamicRelocations)
- printDynamicRelocations(O);
+ if (FileHeaders)
+ printFileHeaders(O);
if (PrivateHeaders || FirstPrivateHeader)
printPrivateFileHeaders(O, FirstPrivateHeader);
if (SectionHeaders)
printSectionHeaders(O);
- if (SectionContents)
- printSectionContents(O);
if (SymbolTable)
printSymbolTable(O, ArchiveName);
+ if (DwarfDumpType != DIDT_Null) {
+ std::unique_ptr<DIContext> DICtx = DWARFContext::create(*O);
+ // Dump the complete DWARF structure.
+ DIDumpOptions DumpOpts;
+ DumpOpts.DumpType = DwarfDumpType;
+ DICtx->dump(outs(), DumpOpts);
+ }
+ if (Relocations && !Disassemble)
+ printRelocations(O);
+ if (DynamicRelocations)
+ printDynamicRelocations(O);
+ if (SectionContents)
+ printSectionContents(O);
+ if (Disassemble)
+ disassembleObject(O, Relocations);
if (UnwindInfo)
printUnwindInfo(O);
+
+ // Mach-O specific options:
if (ExportsTrie)
printExportsTrie(O);
if (Rebase)
printLazyBindTable(O);
if (WeakBind)
printWeakBindTable(O);
+
+ // Other special sections:
if (RawClangAST)
printRawClangAST(O);
if (FaultMapSection)
printFaultMaps(O);
- if (DwarfDumpType != DIDT_Null) {
- std::unique_ptr<DIContext> DICtx = DWARFContext::create(*O);
- // Dump the complete DWARF structure.
- DIDumpOptions DumpOpts;
- DumpOpts.DumpType = DwarfDumpType;
- DICtx->dump(outs(), DumpOpts);
- }
}
static void dumpObject(const COFFImportFile *I, const Archive *A,