| ... | @@ -274,7 +274,7 @@ const usage = | ... | @@ -274,7 +274,7 @@ const usage = |
| 274 | \\ --compress-debug-sections Compress DWARF debug sections with zlib | 274 | \\ --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 | ; |
| 280 | | 280 | |
| ... | @@ -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(); |
| 1253 | | 1253 | |
| 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; | | |
| 1258 | | 1255 | |
| 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; |