authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-11-14 16:51:25+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-11-14 16:51:25+01:00
log4adb8f786f5d1fb49f87ef549eabf09692671e44
tree2640a58086ab33b9d5c0f860d51c0693819a9be3
parente8839074315635c8d049bc5eac6816ed52c82b42

elf: do not pointlessly store zerofill data for TLVs


1 files changed, 7 insertions(+), 2 deletions(-)

src/link/Elf/ZigObject.zig+7-2
...@@ -933,7 +933,12 @@ fn updateTlv(...@@ -933,7 +933,12 @@ fn updateTlv(
933 {933 {
934 const gop = try self.tls_variables.getOrPut(gpa, atom_ptr.atom_index);934 const gop = try self.tls_variables.getOrPut(gpa, atom_ptr.atom_index);
935 assert(!gop.found_existing); // TODO incremental updates935 assert(!gop.found_existing); // TODO incremental updates
936 gop.value_ptr.* = .{ .symbol_index = sym_index, .code = try gpa.dupe(u8, code) };936 gop.value_ptr.* = .{ .symbol_index = sym_index };
937
938 // We only store the data for the TLV if it's non-zerofill.
939 if (elf_file.shdrs.items[shndx].sh_type != elf.SHT_NOBITS) {
940 gop.value_ptr.code = try gpa.dupe(u8, code);
941 }
937 }942 }
938943
939 {944 {
...@@ -1514,7 +1519,7 @@ const DeclMetadata = struct {...@@ -1514,7 +1519,7 @@ const DeclMetadata = struct {
15141519
1515const TlsVariable = struct {1520const TlsVariable = struct {
1516 symbol_index: Symbol.Index,1521 symbol_index: Symbol.Index,
1517 code: []const u8,1522 code: []const u8 = &[0]u8{},
15181523
1519 fn deinit(tlv: *TlsVariable, allocator: Allocator) void {1524 fn deinit(tlv: *TlsVariable, allocator: Allocator) void {
1520 allocator.free(tlv.code);1525 allocator.free(tlv.code);