commit ce58f68903f13a90f3bb2a566755e4c74b56ecdf (tree)
parent dcaf43674e35372e1d28ab12c4c4ff9af9f3d646
Author: Jakub Konka <kubkon@jakubkonka.com>
Date: Fri, 26 Jan 2024 00:33:37 +0100
elf: merge all mergeable string rodata sections into one
Diffstat:
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/link/Elf/Object.zig b/src/link/Elf/Object.zig
@@ -251,7 +251,8 @@ fn initOutputSection(self: Object, elf_file: *Elf, shdr: ElfShdr) error{OutOfMem
const name = blk: {
const name = self.getString(shdr.sh_name);
if (elf_file.base.isRelocatable()) break :blk name;
- if (shdr.sh_flags & elf.SHF_MERGE != 0) break :blk name;
+ if (shdr.sh_flags & elf.SHF_MERGE != 0 and shdr.sh_flags & elf.SHF_STRINGS == 0)
+ break :blk name; // TODO: consider dropping SHF_STRINGS once ICF is implemented
const sh_name_prefixes: []const [:0]const u8 = &.{
".text", ".data.rel.ro", ".data", ".rodata", ".bss.rel.ro", ".bss",
".init_array", ".fini_array", ".tbss", ".tdata", ".gcc_except_table", ".ctors",