diff --git a/llvm/test/tools/llvm-objcopy/ELF/partitions.test b/llvm/test/tools/llvm-objcopy/ELF/partitions.test --- a/llvm/test/tools/llvm-objcopy/ELF/partitions.test +++ b/llvm/test/tools/llvm-objcopy/ELF/partitions.test @@ -48,17 +48,6 @@ MAIN-NEXT: [11] .shstrtab STRTAB 0000000000000000 003050 000060 00 0 0 1 MAIN-NEXT: [12] .strtab STRTAB 0000000000000000 0030b0 000011 00 0 0 1 -MAIN: Symbol table '.dynsym' contains 2 entries: -MAIN-NEXT: Num: Value Size Type Bind Vis Ndx Name -MAIN-NEXT: 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND -MAIN-NEXT: 1: 0000000000201000 0 NOTYPE GLOBAL DEFAULT 6 _start - -MAIN: Symbol table '.symtab' contains 3 entries: -MAIN-NEXT: Num: Value Size Type Bind Vis Ndx Name -MAIN-NEXT: 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND -MAIN-NEXT: 1: 0000000000202000 0 NOTYPE LOCAL HIDDEN 7 _DYNAMIC -MAIN-NEXT: 2: 0000000000201000 0 NOTYPE GLOBAL DEFAULT 6 _start - MAIN: Program Headers: MAIN-NEXT: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align MAIN-NEXT: PHDR 0x000040 0x0000000000200040 0x0000000000200040 0x0001c0 0x0001c0 R 0x8 @@ -70,6 +59,17 @@ MAIN-NEXT: GNU_RELRO 0x002000 0x0000000000202000 0x0000000000202000 0x000080 0x001000 R 0x1 MAIN-NEXT: GNU_STACK 0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RW 0x0 +MAIN: Symbol table '.dynsym' contains 2 entries: +MAIN-NEXT: Num: Value Size Type Bind Vis Ndx Name +MAIN-NEXT: 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND +MAIN-NEXT: 1: 0000000000201000 0 NOTYPE GLOBAL DEFAULT 6 _start + +MAIN: Symbol table '.symtab' contains 3 entries: +MAIN-NEXT: Num: Value Size Type Bind Vis Ndx Name +MAIN-NEXT: 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND +MAIN-NEXT: 1: 0000000000202000 0 NOTYPE LOCAL HIDDEN 7 _DYNAMIC +MAIN-NEXT: 2: 0000000000201000 0 NOTYPE GLOBAL DEFAULT 6 _start + PART1: ELF Header: PART1-NEXT: Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 PART1-NEXT: Class: ELF64 @@ -105,16 +105,6 @@ PART1-NEXT: [ 9] .shstrtab STRTAB 0000000000000000 002038 00004d 00 0 0 1 PART1-NEXT: [10] .strtab STRTAB 0000000000000000 002085 000004 00 0 0 1 -PART1: Symbol table '.dynsym' contains 2 entries: -PART1-NEXT: Num: Value Size Type Bind Vis Ndx Name -PART1-NEXT: 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND -PART1-NEXT: 1: 0000000000205000 0 NOTYPE GLOBAL DEFAULT 15 g1 - -PART1: Symbol table '.symtab' contains 2 entries: -PART1-NEXT: Num: Value Size Type Bind Vis Ndx Name -PART1-NEXT: 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND -PART1-NEXT: 1: 0000000000205000 0 NOTYPE GLOBAL DEFAULT 6 g1 - PART1: Program Headers: PART1-NEXT: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align PART1-NEXT: PHDR 0x000040 0x0000000000203040 0x0000000000203040 0x000188 0x000188 R 0x1 @@ -125,6 +115,16 @@ PART1-NEXT: GNU_RELRO 0x001000 0x0000000000204000 0x0000000000204000 0x000090 0x001000 R 0x1 PART1-NEXT: GNU_STACK 0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RW 0x0 +PART1: Symbol table '.dynsym' contains 2 entries: +PART1-NEXT: Num: Value Size Type Bind Vis Ndx Name +PART1-NEXT: 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND +PART1-NEXT: 1: 0000000000205000 0 NOTYPE GLOBAL DEFAULT 15 g1 + +PART1: Symbol table '.symtab' contains 2 entries: +PART1-NEXT: Num: Value Size Type Bind Vis Ndx Name +PART1-NEXT: 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND +PART1-NEXT: 1: 0000000000205000 0 NOTYPE GLOBAL DEFAULT 6 g1 + PART2: ELF Header: PART2-NEXT: Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 PART2-NEXT: Class: ELF64 @@ -160,16 +160,6 @@ PART2-NEXT: [ 9] .shstrtab STRTAB 0000000000000000 002038 00004d 00 0 0 1 PART2-NEXT: [10] .strtab STRTAB 0000000000000000 002085 000004 00 0 0 1 -PART2: Symbol table '.dynsym' contains 2 entries: -PART2-NEXT: Num: Value Size Type Bind Vis Ndx Name -PART2-NEXT: 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND -PART2-NEXT: 1: 0000000000208000 0 NOTYPE GLOBAL DEFAULT 23 g2 - -PART2: Symbol table '.symtab' contains 2 entries: -PART2-NEXT: Num: Value Size Type Bind Vis Ndx Name -PART2-NEXT: 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND -PART2-NEXT: 1: 0000000000208000 0 NOTYPE GLOBAL DEFAULT 6 g2 - PART2: Program Headers: PART2-NEXT: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align PART2-NEXT: PHDR 0x000040 0x0000000000206040 0x0000000000206040 0x000188 0x000188 R 0x1 @@ -180,6 +170,16 @@ PART2-NEXT: GNU_RELRO 0x001000 0x0000000000207000 0x0000000000207000 0x000090 0x001000 R 0x1 PART2-NEXT: GNU_STACK 0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RW 0x0 +PART2: Symbol table '.dynsym' contains 2 entries: +PART2-NEXT: Num: Value Size Type Bind Vis Ndx Name +PART2-NEXT: 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND +PART2-NEXT: 1: 0000000000208000 0 NOTYPE GLOBAL DEFAULT 23 g2 + +PART2: Symbol table '.symtab' contains 2 entries: +PART2-NEXT: Num: Value Size Type Bind Vis Ndx Name +PART2-NEXT: 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND +PART2-NEXT: 1: 0000000000208000 0 NOTYPE GLOBAL DEFAULT 6 g2 + RUN: not llvm-objcopy --extract-partition=part3 %p/Inputs/partitions.elf %t4 2>&1 | FileCheck --check-prefix=ERROR1 %s ERROR1: error: could not find partition named 'part3' diff --git a/llvm/test/tools/llvm-readobj/ELF/all.test b/llvm/test/tools/llvm-readobj/ELF/all.test --- a/llvm/test/tools/llvm-readobj/ELF/all.test +++ b/llvm/test/tools/llvm-readobj/ELF/all.test @@ -8,11 +8,11 @@ # LLVM-ALL: LoadName: # LLVM-ALL: ElfHeader { # LLVM-ALL: Sections [ +# LLVM-ALL: ProgramHeaders [ # LLVM-ALL: Relocations [ -# LLVM-ALL: Symbols [ # LLVM-ALL: EHFrameHeader { # LLVM-ALL: .eh_frame section at offset 0x1128 address 0x0: -# LLVM-ALL: ProgramHeaders [ +# LLVM-ALL: Symbols [ # LLVM-ALL: VersionSymbols [ # LLVM-ALL: VersionDefinitions [ # LLVM-ALL: VersionRequirements [ @@ -25,12 +25,12 @@ # GNU-ALL: ELF Header: # GNU-ALL: There are {{.*}} section headers, starting at offset {{.*}}: +# GNU-ALL: Program Headers: +# GNU-ALL: Dynamic section at offset {{.*}} contains {{.*}} entries: # GNU-ALL: Relocation section '.rela.data' at offset {{.*}} contains {{.*}} entries: -# GNU-ALL: Symbol table '.symtab' contains {{.*}} entries: # GNU-ALL: EHFrameHeader { # GNU-ALL: .eh_frame section at offset {{.*}} address 0x0: -# GNU-ALL: Dynamic section at offset {{.*}} contains {{.*}} entries: -# GNU-ALL: Program Headers: +# GNU-ALL: Symbol table '.symtab' contains {{.*}} entries: # GNU-ALL: Version symbols section '.gnu.version' contains {{.*}} entries: # GNU-ALL: Version definition section '.gnu.version_d' contains {{.*}} entries: # GNU-ALL: Version needs section '.gnu.version_r' contains {{.*}} entries: diff --git a/llvm/test/tools/llvm-readobj/ELF/check-output-order.test b/llvm/test/tools/llvm-readobj/ELF/check-output-order.test --- a/llvm/test/tools/llvm-readobj/ELF/check-output-order.test +++ b/llvm/test/tools/llvm-readobj/ELF/check-output-order.test @@ -11,19 +11,19 @@ # CHECK: There are 5 section headers, starting at offset # CHECK: Section Headers: # CHECK: Key to Flags: -# CHECK: There are no relocations in this file. -# CHECK: Symbol table '.symtab' contains 1 entries -# CHECK: 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND -# CHECK: Dynamic section at offset -# CHECK: 0x0000000000000000 (NULL) 0x0 -# CHECK: NeededLibraries [ -# CHECK: ] # CHECK: Elf file type is DYN (Shared object file) # CHECK: Entry point 0x0 # CHECK: There are 1 program headers, starting at offset 64 # CHECK: DYNAMIC # CHECK: Section to Segment mapping: # CHECK: None .symtab .strtab .shstrtab +# CHECK: Dynamic section at offset +# CHECK: 0x0000000000000000 (NULL) 0x0 +# CHECK: NeededLibraries [ +# CHECK: ] +# CHECK: There are no relocations in this file. +# CHECK: Symbol table '.symtab' contains 1 entries +# CHECK: 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND # CHECK: There are no section groups in this file. diff --git a/llvm/test/tools/llvm-readobj/ELF/dynamic-malformed.test b/llvm/test/tools/llvm-readobj/ELF/dynamic-malformed.test --- a/llvm/test/tools/llvm-readobj/ELF/dynamic-malformed.test +++ b/llvm/test/tools/llvm-readobj/ELF/dynamic-malformed.test @@ -12,9 +12,9 @@ # WARN: warning: '[[FILE]]': no valid dynamic table was found # WARN-EMPTY: # WARN: File: +# WARN: ProgramHeaders [ # WARN: Symbols [ # WARN: ] -# WARN: ProgramHeaders [ # WARN-GNU: warning: '[[FILE]]': invalid PT_DYNAMIC size (0x4){{$}} # WARN-GNU: warning: '[[FILE]]': section with index 1 has invalid size (0x4){{$}} diff --git a/llvm/tools/llvm-readobj/llvm-readobj.cpp b/llvm/tools/llvm-readobj/llvm-readobj.cpp --- a/llvm/tools/llvm-readobj/llvm-readobj.cpp +++ b/llvm/tools/llvm-readobj/llvm-readobj.cpp @@ -466,22 +466,22 @@ Dumper->printFileHeaders(); if (opts::SectionHeaders) Dumper->printSectionHeaders(); - if (opts::Relocations) - Dumper->printRelocations(); - if (opts::DynRelocs) - Dumper->printDynamicRelocations(); - if (opts::Symbols || opts::DynamicSymbols) - Dumper->printSymbols(opts::Symbols, opts::DynamicSymbols); if (opts::HashSymbols) Dumper->printHashSymbols(); - if (opts::UnwindInfo) - Dumper->printUnwindInfo(); + if (opts::ProgramHeaders || opts::SectionMapping == cl::BOU_TRUE) + Dumper->printProgramHeaders(opts::ProgramHeaders, opts::SectionMapping); if (opts::DynamicTable) Dumper->printDynamicTable(); if (opts::NeededLibraries) Dumper->printNeededLibraries(); - if (opts::ProgramHeaders || opts::SectionMapping == cl::BOU_TRUE) - Dumper->printProgramHeaders(opts::ProgramHeaders, opts::SectionMapping); + if (opts::Relocations) + Dumper->printRelocations(); + if (opts::DynRelocs) + Dumper->printDynamicRelocations(); + if (opts::UnwindInfo) + Dumper->printUnwindInfo(); + if (opts::Symbols || opts::DynamicSymbols) + Dumper->printSymbols(opts::Symbols, opts::DynamicSymbols); if (!opts::StringDump.empty()) Dumper->printSectionsAsString(Obj, opts::StringDump); if (!opts::HexDump.empty())