[PATCH] D57700: [llvm-readobj] Display sections that do not belong to a segment in the section-mapping
Matt Davis via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 5 13:02:13 PST 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL353217: [llvm-readobj] Display sections that do not belong to a segment in the section… (authored by mattd, committed by ).
Herald added a project: LLVM.
Changed prior to commit:
https://reviews.llvm.org/D57700?vs=185081&id=185382#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D57700/new/
https://reviews.llvm.org/D57700
Files:
lld/trunk/test/ELF/linkerscript/segment-none.s
llvm/trunk/test/tools/llvm-readobj/gnu-phdrs.test
llvm/trunk/tools/llvm-readobj/ELFDumper.cpp
Index: lld/trunk/test/ELF/linkerscript/segment-none.s
===================================================================
--- lld/trunk/test/ELF/linkerscript/segment-none.s
+++ lld/trunk/test/ELF/linkerscript/segment-none.s
@@ -23,7 +23,7 @@
# CHECK: Section to Segment mapping:
# CHECK-NEXT: Segment Sections...
-# CHECK-NOT: .foo
+# CHECK: None {{.*}}.foo
# DEFINED: Section to Segment mapping:
# DEFINED-NEXT: Segment Sections...
Index: llvm/trunk/tools/llvm-readobj/ELFDumper.cpp
===================================================================
--- llvm/trunk/tools/llvm-readobj/ELFDumper.cpp
+++ llvm/trunk/tools/llvm-readobj/ELFDumper.cpp
@@ -19,6 +19,7 @@
#include "llvm-readobj.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/PointerIntPair.h"
#include "llvm/ADT/STLExtras.h"
@@ -3316,6 +3317,7 @@
template <class ELFT>
void GNUStyle<ELFT>::printSectionMapping(const ELFO *Obj) {
OS << "\n Section to Segment mapping:\n Segment Sections...\n";
+ DenseSet<const Elf_Shdr *> BelongsToSegment;
int Phnum = 0;
for (const Elf_Phdr &Phdr : unwrapOrError(Obj->program_headers())) {
std::string Sections;
@@ -3330,12 +3332,25 @@
Phdr.p_type != ELF::PT_TLS;
if (!TbssInNonTLS && checkTLSSections(Phdr, Sec) &&
checkoffsets(Phdr, Sec) && checkVMA(Phdr, Sec) &&
- checkPTDynamic(Phdr, Sec) && (Sec.sh_type != ELF::SHT_NULL))
+ checkPTDynamic(Phdr, Sec) && (Sec.sh_type != ELF::SHT_NULL)) {
Sections += unwrapOrError(Obj->getSectionName(&Sec)).str() + " ";
+ BelongsToSegment.insert(&Sec);
+ }
}
OS << Sections << "\n";
OS.flush();
}
+
+ // Display sections that do not belong to a segment.
+ std::string Sections;
+ for (const Elf_Shdr &Sec : unwrapOrError(Obj->sections())) {
+ if (BelongsToSegment.find(&Sec) == BelongsToSegment.end())
+ Sections += unwrapOrError(Obj->getSectionName(&Sec)).str() + ' ';
+ }
+ if (!Sections.empty()) {
+ OS << " None " << Sections << '\n';
+ OS.flush();
+ }
}
template <class ELFT>
Index: llvm/trunk/test/tools/llvm-readobj/gnu-phdrs.test
===================================================================
--- llvm/trunk/test/tools/llvm-readobj/gnu-phdrs.test
+++ llvm/trunk/test/tools/llvm-readobj/gnu-phdrs.test
@@ -59,6 +59,7 @@
ELF32-NEXT: 07 .eh_frame_hdr
ELF32-NEXT: 08
ELF32-NEXT: 09 .tdata .ctors .dtors .jcr .dynamic .got
+ELF32-NEXT: None .comment .shstrtab .symtab .strtab
ELF64-PHDRS: Elf file type is EXEC (Executable file)
ELF64-PHDRS-NEXT: Entry point 0x400610
@@ -90,6 +91,7 @@
ELF64-MAPPING-NEXT: 07 .eh_frame_hdr
ELF64-MAPPING-NEXT: 08
ELF64-MAPPING-NEXT: 09 .tdata .init_array .fini_array .jcr .dynamic .got
+ELF64-MAPPING-NEXT: None .comment .shstrtab .symtab .strtab
ELF64-ONEMAPPING: Section to Segment mapping:
ELF64-ONEMAPPING-NOT: Section to Segment mapping:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57700.185382.patch
Type: text/x-patch
Size: 3038 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190205/91b7faac/attachment.bin>
More information about the llvm-commits
mailing list