From 07b8c23f59c5b5856323153098b4828dd2875537 Mon Sep 17 00:00:00 2001 From: Philip Craig Date: Tue, 23 Jul 2024 21:36:37 +1000 Subject: [PATCH] write/elf: don't write empty strtab If there were no strings, we were writing a strtab section header, but not writing any data for the section. --- src/write/elf/object.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/write/elf/object.rs b/src/write/elf/object.rs index 0920a0dd..0746fe9b 100644 --- a/src/write/elf/object.rs +++ b/src/write/elf/object.rs @@ -598,10 +598,12 @@ impl<'a> Object<'a> { writer.reserve_symtab(); if writer.symtab_shndx_needed() { writer.reserve_symtab_shndx_section_index(); + writer.reserve_symtab_shndx(); + } + if writer.strtab_needed() { + writer.reserve_strtab_section_index(); + writer.reserve_strtab(); } - writer.reserve_symtab_shndx(); - writer.reserve_strtab_section_index(); - writer.reserve_strtab(); // Calculate size of relocations. for (index, section) in self.sections.iter().enumerate() {