[llvm] [llvm][yaml2obj] Modify section header overriding timing (PR #130942)

Ruoyu Qiu via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 17 03:44:03 PDT 2025


================
@@ -899,12 +903,17 @@ void ELFState<ELFT>::initSectionHeaders(std::vector<Elf_Shdr> &SHeaders,
     }
 
     LocationCounter += SHeader.sh_size;
-
-    // Override section fields if requested.
-    overrideFields<ELFT>(Sec, SHeader);
+    SectionHeadersOverrideHelper.push_back({SN2I.get(Sec->Name), *Sec});
   }
 }
 
+template <class ELFT>
+void ELFState<ELFT>::overrideSectionHeaders(std::vector<Elf_Shdr> &SHeaders) {
+  for (std::pair<unsigned, ELFYAML::Section> &IndexAndSec :
+       SectionHeadersOverrideHelper)
+    overrideFields<ELFT>(&IndexAndSec.second, SHeaders[IndexAndSec.first]);
----------------
cabbaken wrote:

`initImplicitHeader()` will also use `overrideFields()`, so I defined a new function to call `overrideFields()`.

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


More information about the llvm-commits mailing list