authorgravatar for 35903594+patrickwick@users.noreply.github.comPatrick Wickenhaeuser <35903594+patrickwick@users.noreply.github.com> 2024-10-04 12:38:35+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
log19a0864e4f96d5c20026dae87c0f9a784ae54272
tree34b7447a0b56a3e28bd2a66b883b0153a896d381
parent182c12de6989a7dd9419917a6cd0e6e804bc9d00

19009: zig objcopy: allow --add-section, --set-section-alignment and --set-section-flags only if the target is an ELF file


1 files changed, 9 insertions(+), 6 deletions(-)

lib/compiler/objcopy.zig+9-6
......@@ -185,14 +185,17 @@ fn cmdObjCopy(
185185 fatal("zig objcopy: ELF to RAW or HEX copying does not support --strip", .{});
186186 if (opt_extract != null)
187187 fatal("zig objcopy: ELF to RAW or HEX copying does not support --extract-to", .{});
188 if (add_section != null)
189 fatal("zig objcopy: ELF to RAW or HEX copying does not support --add-section", .{});
190 if (set_section_alignment != null)
191 fatal("zig objcopy: ELF to RAW or HEX copying does not support --set_section_alignment", .{});
192 if (set_section_flags != null)
193 fatal("zig objcopy: ELF to RAW or HEX copying does not support --set_section_flags", .{});
188194
189195 try emitElf(arena, in_file, out_file, elf_hdr, .{
190196 .ofmt = out_fmt,
191197 .only_section = only_section,
192198 .pad_to = pad_to,
193 .add_section = add_section,
194 .set_section_alignment = set_section_alignment,
195 .set_section_flags = set_section_flags,
196199 });
197200 },
198201 .elf => {
......@@ -279,9 +282,9 @@ pub const EmitRawElfOptions = struct {
279282 ofmt: std.Target.ObjectFormat,
280283 only_section: ?[]const u8 = null,
281284 pad_to: ?u64 = null,
282 add_section: ?AddSection,
283 set_section_alignment: ?SetSectionAlignment,
284 set_section_flags: ?SetSectionFlags,
285 add_section: ?AddSection = null,
286 set_section_alignment: ?SetSectionAlignment = null,
287 set_section_flags: ?SetSectionFlags = null,
285288};
286289
287290const AddSection = struct {