summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-readobj
diff options
context:
space:
mode:
authorGeorge Rimar <grimar@accesssoftek.com>2019-05-24 11:24:42 +0000
committerGeorge Rimar <grimar@accesssoftek.com>2019-05-24 11:24:42 +0000
commit33bee053c39b46c6aa46abca6cc758979da44b14 (patch)
tree0ed9134a99a0671459aefa9caad68ac9357789bf /llvm/tools/llvm-readobj
parentf835fcf412c92eac20bf2110e13c49fc86d0c55c (diff)
downloadbcm5719-llvm-33bee053c39b46c6aa46abca6cc758979da44b14.tar.gz
bcm5719-llvm-33bee053c39b46c6aa46abca6cc758979da44b14.zip
Revert r361630 "[llvm-readelf] - Allow dumping of the .dynamic section even if there is no PT_DYNAMIC header."
It broke BB: http://lab.llvm.org:8011/builders/ppc64le-lld-multistage-test/builds/3748 llvm-svn: 361631
Diffstat (limited to 'llvm/tools/llvm-readobj')
-rw-r--r--llvm/tools/llvm-readobj/ELFDumper.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp
index b86a6c192ca..159e300de30 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -1331,7 +1331,6 @@ static const char *getElfMipsOptionsOdkType(unsigned Odk) {
template <typename ELFT>
void ELFDumper<ELFT>::loadDynamicTable(const ELFFile<ELFT> *Obj) {
- // Try to locate the PT_DYNAMIC header.
const Elf_Phdr *DynamicPhdr = nullptr;
for (const Elf_Phdr &Phdr : unwrapOrError(Obj->program_headers())) {
if (Phdr.p_type != ELF::PT_DYNAMIC)
@@ -1340,6 +1339,11 @@ void ELFDumper<ELFT>::loadDynamicTable(const ELFFile<ELFT> *Obj) {
break;
}
+ // We do not want to dump dynamic section if we have no PT_DYNAMIC header.
+ // This matches GNU's behavior.
+ if (!DynamicPhdr)
+ return;
+
// Try to locate the .dynamic section in the sections header table.
const Elf_Shdr *DynamicSec = nullptr;
for (const Elf_Shdr &Sec : unwrapOrError(Obj->sections())) {
@@ -1354,16 +1358,9 @@ void ELFDumper<ELFT>::loadDynamicTable(const ELFFile<ELFT> *Obj) {
// Ignore sh_entsize and use the expected value for entry size explicitly.
// This allows us to dump the dynamic sections with a broken sh_entsize
// field.
- if (DynamicSec) {
+ if (DynamicSec)
DynamicTable = checkDRI({ObjF->getELFFile()->base() + DynamicSec->sh_offset,
DynamicSec->sh_size, sizeof(Elf_Dyn)});
- parseDynamicTable();
- }
-
- // If we have a PT_DYNAMIC header, we will either check the found dynamic
- // section or take the dynamic table data directly from the header.
- if (!DynamicPhdr)
- return;
if (DynamicPhdr->p_offset + DynamicPhdr->p_filesz >
ObjF->getMemoryBufferRef().getBufferSize())
@@ -1377,6 +1374,7 @@ void ELFDumper<ELFT>::loadDynamicTable(const ELFFile<ELFT> *Obj) {
}
StringRef Name = unwrapOrError(Obj->getSectionName(DynamicSec));
+
if (DynamicSec->sh_addr + DynamicSec->sh_size >
DynamicPhdr->p_vaddr + DynamicPhdr->p_memsz ||
DynamicSec->sh_addr < DynamicPhdr->p_vaddr)
@@ -1388,6 +1386,8 @@ void ELFDumper<ELFT>::loadDynamicTable(const ELFFile<ELFT> *Obj) {
reportWarning("The SHT_DYNAMIC section '" + Name +
"' is not at the start of "
"PT_DYNAMIC segment");
+
+ parseDynamicTable();
}
template <typename ELFT>
OpenPOWER on IntegriCloud