[lld] [llvm] [Object][ELF] Support extended header for Object Parser in ELF (PR #162288)
James Henderson via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 8 00:38:27 PDT 2025
================
@@ -889,15 +896,42 @@ Expected<uint64_t> ELFFile<ELFT>::getDynSymtabSize() const {
return 0;
}
-template <class ELFT> ELFFile<ELFT>::ELFFile(StringRef Object) : Buf(Object) {}
+template <class ELFT> ELFFile<ELFT>::ELFFile(StringRef Object) : Buf(Object) {
+ auto Header = getHeader();
+ e_phnum = Header.e_phnum;
+ e_shnum = Header.e_shnum;
+ e_shstrndx = Header.e_shstrndx;
+}
template <class ELFT>
Expected<ELFFile<ELFT>> ELFFile<ELFT>::create(StringRef Object) {
if (sizeof(Elf_Ehdr) > Object.size())
return createError("invalid buffer: the size (" + Twine(Object.size()) +
") is smaller than an ELF header (" +
Twine(sizeof(Elf_Ehdr)) + ")");
- return ELFFile(Object);
+ ELFFile Result(Object);
+
+ //
+ // sections() parse the total number of sections by considering the
+ // extended headers
+ //
+ if (Result.getHeader().HasHeaderExtension()) {
----------------
jh7370 wrote:
Why is this done here rather than within the `ELFFile` constructor?
https://github.com/llvm/llvm-project/pull/162288
More information about the llvm-commits
mailing list