authorgravatar for 35903594+patrickwick@users.noreply.github.comPatrick Wickenhaeuser <35903594+patrickwick@users.noreply.github.com> 2024-10-04 15:49:18+02:00
committergravatar for 35903594+patrickwick@users.noreply.github.comPatrick Wickenhaeuser <35903594+patrickwick@users.noreply.github.com> 2024-10-04 15:49:50+02:00
logc3f1ff8b0d2aa6fa94854775b80d57c251ce1438
tree9a008250a3a7357d82433a18e00ec17c80ec3f14
parent19a0864e4f96d5c20026dae87c0f9a784ae54272

19009: zig objcopy: minor cleanup


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

lib/compiler/objcopy.zig+4-7
...@@ -274,7 +274,7 @@ const usage =...@@ -274,7 +274,7 @@ const usage =
274 \\ --compress-debug-sections Compress DWARF debug sections with zlib274 \\ --compress-debug-sections Compress DWARF debug sections with zlib
275 \\ --set-section-alignment <name>=<align> Set alignment of section <name> to <align> bytes. Must be a power of two.275 \\ --set-section-alignment <name>=<align> Set alignment of section <name> to <align> bytes. Must be a power of two.
276 \\ --set-section-flags <name>=<file> Set flags of section <name> to <flags> represented as a comma separated set of flags.276 \\ --set-section-flags <name>=<file> Set flags of section <name> to <flags> represented as a comma separated set of flags.
277 \\ --add-section <name>=<file> Add file content from <file> with the section name <name>.277 \\ --add-section <name>=<file> Add file content from <file> with the a new section named <name>.
278 \\278 \\
279;279;
280280
...@@ -1251,21 +1251,18 @@ fn ElfFile(comptime is_64: bool) type {...@@ -1251,21 +1251,18 @@ fn ElfFile(comptime is_64: bool) type {
1251 fatal("unable to open '{s}': {s}", .{ add_section.file_path, @errorName(err) });1251 fatal("unable to open '{s}': {s}", .{ add_section.file_path, @errorName(err) });
1252 defer section_file.close();1252 defer section_file.close();
12531253
1254 const max_size = std.math.maxInt(usize);1254 const payload = try section_file.readToEndAlloc(arena.allocator(), std.math.maxInt(usize));
1255 const payload = try section_file.readToEndAlloc(arena.allocator(), max_size);
1256 const flags = 0;
1257 const alignment = 4;
12581255
1259 dest_sections[dest_section_idx] = Elf_Shdr{1256 dest_sections[dest_section_idx] = Elf_Shdr{
1260 .sh_name = user_section_name,1257 .sh_name = user_section_name,
1261 .sh_type = elf.SHT_PROGBITS,1258 .sh_type = elf.SHT_PROGBITS,
1262 .sh_flags = flags,1259 .sh_flags = 0,
1263 .sh_addr = 0,1260 .sh_addr = 0,
1264 .sh_offset = eof_offset,1261 .sh_offset = eof_offset,
1265 .sh_size = @intCast(payload.len),1262 .sh_size = @intCast(payload.len),
1266 .sh_link = elf.SHN_UNDEF,1263 .sh_link = elf.SHN_UNDEF,
1267 .sh_info = elf.SHN_UNDEF,1264 .sh_info = elf.SHN_UNDEF,
1268 .sh_addralign = alignment,1265 .sh_addralign = 4,
1269 .sh_entsize = 0,1266 .sh_entsize = 0,
1270 };1267 };
1271 dest_section_idx += 1;1268 dest_section_idx += 1;