From c3f1ff8b0d2aa6fa94854775b80d57c251ce1438 Mon Sep 17 00:00:00 2001 From: Patrick Wickenhaeuser <35903594+patrickwick@users.noreply.github.com> Date: Fri, 4 Oct 2024 15:49:18 +0200 Subject: [PATCH] 19009: zig objcopy: minor cleanup --- lib/compiler/objcopy.zig | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/compiler/objcopy.zig b/lib/compiler/objcopy.zig index fe3d2fbc57..47f395745f 100644 --- a/lib/compiler/objcopy.zig +++ b/lib/compiler/objcopy.zig @@ -274,7 +274,7 @@ const usage = \\ --compress-debug-sections Compress DWARF debug sections with zlib \\ --set-section-alignment = Set alignment of section to bytes. Must be a power of two. \\ --set-section-flags = Set flags of section to represented as a comma separated set of flags. - \\ --add-section = Add file content from with the section name . + \\ --add-section = Add file content from with the a new section named . \\ ; @@ -1251,21 +1251,18 @@ fn ElfFile(comptime is_64: bool) type { fatal("unable to open '{s}': {s}", .{ add_section.file_path, @errorName(err) }); defer section_file.close(); - const max_size = std.math.maxInt(usize); - const payload = try section_file.readToEndAlloc(arena.allocator(), max_size); - const flags = 0; - const alignment = 4; + const payload = try section_file.readToEndAlloc(arena.allocator(), std.math.maxInt(usize)); dest_sections[dest_section_idx] = Elf_Shdr{ .sh_name = user_section_name, .sh_type = elf.SHT_PROGBITS, - .sh_flags = flags, + .sh_flags = 0, .sh_addr = 0, .sh_offset = eof_offset, .sh_size = @intCast(payload.len), .sh_link = elf.SHN_UNDEF, .sh_info = elf.SHN_UNDEF, - .sh_addralign = alignment, + .sh_addralign = 4, .sh_entsize = 0, }; dest_section_idx += 1;