[llvm] [llvm-objdump][ELF]Fix crash when reading strings from .dynstr (PR #125679)
Ruoyu Qiu via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 12 03:14:54 PST 2025
================
@@ -221,6 +221,28 @@ template <class ELFT> void ELFDumper<ELFT>::printDynamicSection() {
std::string TagFmt = " %-" + std::to_string(MaxLen) + "s ";
outs() << "\nDynamic Section:\n";
+ typename ELFT::Xword StringTableSize{0};
+ for (const typename ELFT::Shdr &Sec : cantFail(Elf.sections())) {
+ if (Sec.sh_type == ELF::SHT_DYNSYM) {
+ Expected<const typename ELFT::Shdr *> StringTableSecOrError =
+ getSection<ELFT>(cantFail(Elf.sections()), Sec.sh_link);
+ if (!StringTableSecOrError) {
+ consumeError(StringTableSecOrError.takeError());
+ break;
+ }
+ StringTableSize = StringTableSize < (*StringTableSecOrError)->sh_size
+ ? (*StringTableSecOrError)->sh_size
+ : StringTableSize;
----------------
cabbaken wrote:
Yes, I will fix it.
https://github.com/llvm/llvm-project/pull/125679
More information about the llvm-commits
mailing list