[llvm-branch-commits] [llvm-objdump] -r: support CREL (PR #97382)

Peter Smith via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Jul 2 05:50:04 PDT 2024


================
@@ -292,6 +295,11 @@ template <class ELFT> class ELFObjectFile : public ELFObjectFileBase {
   const Elf_Shdr *DotSymtabSec = nullptr; // Symbol table section.
   const Elf_Shdr *DotSymtabShndxSec = nullptr; // SHT_SYMTAB_SHNDX section.
 
+  // Hold CREL relocations for SectionRef::relocations().
+  mutable SmallVector<SmallVector<Elf_Crel, 0>, 0> Crels;
+  // Hold CREL decoding errors.
+  mutable SmallVector<std::string, 0> CrelErrs;
----------------
smithp35 wrote:

I expect that most objects would have no decoding errors, yet it looks like we're allocating a potentially large (intermediate ELF file as output of LTO for example) amount of empty strings.

An alternative could be an unordered_map of section indexes to strings. This would also look a bit cleaner than just checking if the string is empty for no errors.

I don't have a strong opinion though.

https://github.com/llvm/llvm-project/pull/97382


More information about the llvm-branch-commits mailing list