[PATCH] D86297: [llvm-readobj] - Change how we create DynRegionInfo objects. NFCI.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 21 01:36:16 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG80e9dd08784f: [llvm-readobj] - Change how we create DynRegionInfo objects. NFCI. (authored by grimar).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D86297/new/
https://reviews.llvm.org/D86297
Files:
llvm/tools/llvm-readobj/ELFDumper.cpp
Index: llvm/tools/llvm-readobj/ELFDumper.cpp
===================================================================
--- llvm/tools/llvm-readobj/ELFDumper.cpp
+++ llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -243,24 +243,14 @@
TYPEDEF_ELF_TYPES(ELFT)
- DynRegionInfo checkDRI(DynRegionInfo DRI) {
+ DynRegionInfo createDRI(uint64_t Offset, uint64_t Size, uint64_t EntSize) {
const ELFFile<ELFT> *Obj = ObjF->getELFFile();
- if (DRI.Addr < Obj->base() ||
- reinterpret_cast<const uint8_t *>(DRI.Addr) + DRI.Size >
- Obj->base() + Obj->getBufSize())
+ const uint8_t *Addr = Obj->base() + Offset;
+ if (Addr < Obj->base() || Addr + Size > Obj->base() + Obj->getBufSize())
reportError(errorCodeToError(llvm::object::object_error::parse_failed),
ObjF->getFileName());
- return DRI;
- }
-
- DynRegionInfo createDRIFrom(const Elf_Phdr *P, uintX_t EntSize) {
- return checkDRI({ObjF->getELFFile()->base() + P->p_offset, P->p_filesz,
- EntSize, ObjF->getFileName()});
- }
- DynRegionInfo createDRIFrom(const Elf_Shdr *S) {
- return checkDRI({ObjF->getELFFile()->base() + S->sh_offset, S->sh_size,
- S->sh_entsize, ObjF->getFileName()});
+ return {Addr, Size, EntSize, ObjF->getFileName()};
}
void printAttributes();
@@ -1936,7 +1926,8 @@
DynRegionInfo FromPhdr(ObjF->getFileName());
bool IsPhdrTableValid = false;
if (DynamicPhdr) {
- FromPhdr = createDRIFrom(DynamicPhdr, sizeof(Elf_Dyn));
+ FromPhdr = createDRI(DynamicPhdr->p_offset, DynamicPhdr->p_filesz,
+ sizeof(Elf_Dyn));
FromPhdr.SizePrintName = "PT_DYNAMIC size";
FromPhdr.EntSizePrintName = "";
@@ -1951,8 +1942,7 @@
bool IsSecTableValid = false;
if (DynamicSec) {
FromSec =
- checkDRI({ObjF->getELFFile()->base() + DynamicSec->sh_offset,
- DynamicSec->sh_size, sizeof(Elf_Dyn), ObjF->getFileName()});
+ createDRI(DynamicSec->sh_offset, DynamicSec->sh_size, sizeof(Elf_Dyn));
FromSec.Context = describe(*DynamicSec);
FromSec.EntSizePrintName = "";
@@ -2040,7 +2030,7 @@
DotDynsymSec = &Sec;
if (!DynSymRegion) {
- DynSymRegion = createDRIFrom(&Sec);
+ DynSymRegion = createDRI(Sec.sh_offset, Sec.sh_size, Sec.sh_entsize);
DynSymRegion->Context = describe(Sec);
if (Expected<StringRef> E = Obj->getStringTableForSymtab(Sec))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86297.286969.patch
Type: text/x-patch
Size: 2458 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200821/7c4d5a98/attachment.bin>
More information about the llvm-commits
mailing list