[llvm] r354270 - [llvm-readobj] - Simplify .gnu.version_d dumping.
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 18 05:58:12 PST 2019
Author: grimar
Date: Mon Feb 18 05:58:12 2019
New Revision: 354270
URL: http://llvm.org/viewvc/llvm-project?rev=354270&view=rev
Log:
[llvm-readobj] - Simplify .gnu.version_d dumping.
This is similar to D58048.
Instead of scanning the dynamic table to read the
DT_VERDEFNUM, we could take it from the sh_info field.
(https://docs.oracle.com/cd/E19683-01/816-1386/chapter6-94076/index.html)
The patch does this.
Modified:
llvm/trunk/tools/llvm-readobj/ELFDumper.cpp
Modified: llvm/trunk/tools/llvm-readobj/ELFDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/ELFDumper.cpp?rev=354270&r1=354269&r2=354270&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/ELFDumper.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/ELFDumper.cpp Mon Feb 18 05:58:12 2019
@@ -652,16 +652,6 @@ static void printVersionDefinitionSectio
if (!Sec)
return;
- // The number of entries in the section SHT_GNU_verdef
- // is determined by DT_VERDEFNUM tag.
- unsigned VerDefsNum = 0;
- for (const typename ELFO::Elf_Dyn &Dyn : Dumper->dynamic_table()) {
- if (Dyn.d_tag == DT_VERDEFNUM) {
- VerDefsNum = Dyn.d_un.d_val;
- break;
- }
- }
-
const uint8_t *SecStartAddress =
(const uint8_t *)Obj->base() + Sec->sh_offset;
const uint8_t *SecEndAddress = SecStartAddress + Sec->sh_size;
@@ -669,6 +659,7 @@ static void printVersionDefinitionSectio
const typename ELFO::Elf_Shdr *StrTab =
unwrapOrError(Obj->getSection(Sec->sh_link));
+ unsigned VerDefsNum = Sec->sh_info;
while (VerDefsNum--) {
if (P + sizeof(VerDef) > SecEndAddress)
report_fatal_error("invalid offset in the section");
More information about the llvm-commits
mailing list