[llvm] [llvm-objdump][ELF]Fix crash when reading strings from .dynstr (PR #125679)
James Henderson via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 25 02:08:13 PST 2025
================
@@ -63,14 +63,22 @@ static Expected<StringRef> getDynamicStrTab(const ELFFile<ELFT> &Elf) {
if (!DynamicEntriesOrError)
return DynamicEntriesOrError.takeError();
+ typename ELFT::Xword StringTableSize{0};
+ const uint8_t *MappedAddr = nullptr;
for (const typename ELFT::Dyn &Dyn : *DynamicEntriesOrError) {
if (Dyn.d_tag == ELF::DT_STRTAB) {
auto MappedAddrOrError = Elf.toMappedAddr(Dyn.getPtr());
if (!MappedAddrOrError)
return MappedAddrOrError.takeError();
- return StringRef(reinterpret_cast<const char *>(*MappedAddrOrError));
+ MappedAddr = *MappedAddrOrError;
+ }
+ if (Dyn.d_tag == ELF::DT_STRSZ) {
----------------
jh7370 wrote:
Nit: LLVM coding style is no braces for single-line ifs like this.
https://github.com/llvm/llvm-project/pull/125679
More information about the llvm-commits
mailing list