[llvm-branch-commits] [llvm] [llvm-objcopy] Stream ELF output to reduce peak memory usage (PR #217706)
James Henderson via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Oct 13 02:08:32 PDT 2026
================
@@ -867,17 +937,17 @@ Expected<Symbol *> SymbolTableSection::getSymbolByIndex(uint32_t Index) {
template <class ELFT>
Error ELFSectionWriter<ELFT>::visit(const SymbolTableSection &Sec) {
- Elf_Sym *Sym = reinterpret_cast<Elf_Sym *>(Out.getBufferStart() + Sec.Offset);
- // Loop though symbols setting each entry of the symbol table.
+ raw_ostream &Out = streamAt(Sec.Offset);
for (const std::unique_ptr<Symbol> &Symbol : Sec.Symbols) {
- Sym->st_name = Symbol->NameIndex;
- Sym->st_value = Symbol->Value;
- Sym->st_size = Symbol->Size;
- Sym->st_other = Symbol->Visibility;
- Sym->setBinding(Symbol->Binding);
- Sym->setType(Symbol->Type);
- Sym->st_shndx = Symbol->getShndx();
- ++Sym;
+ Elf_Sym Sym = {};
----------------
jh7370 wrote:
Same comment as the other cases: ELF primitives don't need initializing to 0, because all the members are explicitly populated.
https://github.com/llvm/llvm-project/pull/217706
More information about the llvm-branch-commits
mailing list