diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2023-11-14 16:51:25 +0100 |
|---|---|---|
| committer | Jakub Konka <kubkon@jakubkonka.com> | 2023-11-14 16:51:25 +0100 |
| commit | 4adb8f786f5d1fb49f87ef549eabf09692671e44 (patch) | |
| tree | 2640a58086ab33b9d5c0f860d51c0693819a9be3 /src | |
| parent | e8839074315635c8d049bc5eac6816ed52c82b42 (diff) | |
| download | zig-4adb8f786f5d1fb49f87ef549eabf09692671e44.tar.gz zig-4adb8f786f5d1fb49f87ef549eabf09692671e44.zip | |
elf: do not pointlessly store zerofill data for TLVs
Diffstat (limited to 'src')
| -rw-r--r-- | src/link/Elf/ZigObject.zig | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/link/Elf/ZigObject.zig b/src/link/Elf/ZigObject.zig index 28cc8895f7..98bc779ee7 100644 --- a/src/link/Elf/ZigObject.zig +++ b/src/link/Elf/ZigObject.zig @@ -933,7 +933,12 @@ fn updateTlv( { const gop = try self.tls_variables.getOrPut(gpa, atom_ptr.atom_index); assert(!gop.found_existing); // TODO incremental updates - gop.value_ptr.* = .{ .symbol_index = sym_index, .code = try gpa.dupe(u8, code) }; + gop.value_ptr.* = .{ .symbol_index = sym_index }; + + // We only store the data for the TLV if it's non-zerofill. + if (elf_file.shdrs.items[shndx].sh_type != elf.SHT_NOBITS) { + gop.value_ptr.code = try gpa.dupe(u8, code); + } } { @@ -1514,7 +1519,7 @@ const DeclMetadata = struct { const TlsVariable = struct { symbol_index: Symbol.Index, - code: []const u8, + code: []const u8 = &[0]u8{}, fn deinit(tlv: *TlsVariable, allocator: Allocator) void { allocator.free(tlv.code); |
