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(...@@ -185,14 +185,17 @@ fn cmdObjCopy(
185 fatal("zig objcopy: ELF to RAW or HEX copying does not support --strip", .{});185 fatal("zig objcopy: ELF to RAW or HEX copying does not support --strip", .{});
186 if (opt_extract != null)186 if (opt_extract != null)
187 fatal("zig objcopy: ELF to RAW or HEX copying does not support --extract-to", .{});187 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
189 try emitElf(arena, in_file, out_file, elf_hdr, .{195 try emitElf(arena, in_file, out_file, elf_hdr, .{
190 .ofmt = out_fmt,196 .ofmt = out_fmt,
191 .only_section = only_section,197 .only_section = only_section,
192 .pad_to = pad_to,198 .pad_to = pad_to,
193 .add_section = add_section,
194 .set_section_alignment = set_section_alignment,
195 .set_section_flags = set_section_flags,
196 });199 });
197 },200 },
198 .elf => {201 .elf => {
...@@ -279,9 +282,9 @@ pub const EmitRawElfOptions = struct {...@@ -279,9 +282,9 @@ pub const EmitRawElfOptions = struct {
279 ofmt: std.Target.ObjectFormat,282 ofmt: std.Target.ObjectFormat,
280 only_section: ?[]const u8 = null,283 only_section: ?[]const u8 = null,
281 pad_to: ?u64 = null,284 pad_to: ?u64 = null,
282 add_section: ?AddSection,285 add_section: ?AddSection = null,
283 set_section_alignment: ?SetSectionAlignment,286 set_section_alignment: ?SetSectionAlignment = null,
284 set_section_flags: ?SetSectionFlags,287 set_section_flags: ?SetSectionFlags = null,
285};288};
286289
287const AddSection = struct {290const AddSection = struct {