[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


================
@@ -33,10 +36,87 @@ using namespace llvm::objcopy::elf;
 using namespace llvm::object;
 using namespace llvm::support;
 
-template <class ELFT> void ELFWriter<ELFT>::writePhdr(const Segment &Seg) {
-  uint8_t *B = reinterpret_cast<uint8_t *>(Buf->getBufferStart()) +
-               Obj.ProgramHdrSegment.Offset + Seg.Index * sizeof(Elf_Phdr);
-  Elf_Phdr &Phdr = *reinterpret_cast<Elf_Phdr *>(B);
+namespace {
----------------
jh7370 wrote:

Nit: LLVM style prefers `static` for local functions instead of anonymous namespaces. See the coding standards.

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


More information about the llvm-branch-commits mailing list