| ... | @@ -623,7 +623,7 @@ pub fn initMetadata(self: *Elf, options: InitMetadataOptions) !void { | ... | @@ -623,7 +623,7 @@ pub fn initMetadata(self: *Elf, options: InitMetadataOptions) !void { |
| 623 | const ptr_size = self.ptrWidthBytes(); | 623 | const ptr_size = self.ptrWidthBytes(); |
| 624 | const target = self.base.comp.root_mod.resolved_target.result; | 624 | const target = self.base.comp.root_mod.resolved_target.result; |
| 625 | const ptr_bit_width = target.ptrBitWidth(); | 625 | const ptr_bit_width = target.ptrBitWidth(); |
| 626 | const is_linux = target.os.tag == .linux; | 626 | const has_os = target.os.tag != .freestanding; |
| 627 | const zig_object = self.zigObjectPtr().?; | 627 | const zig_object = self.zigObjectPtr().?; |
| 628 | | 628 | |
| 629 | const fillSection = struct { | 629 | const fillSection = struct { |
| ... | @@ -661,7 +661,7 @@ pub fn initMetadata(self: *Elf, options: InitMetadataOptions) !void { | ... | @@ -661,7 +661,7 @@ pub fn initMetadata(self: *Elf, options: InitMetadataOptions) !void { |
| 661 | if (self.phdr_zig_got_index == null) { | 661 | if (self.phdr_zig_got_index == null) { |
| 662 | // We really only need ptr alignment but since we are using PROGBITS, linux requires | 662 | // We really only need ptr alignment but since we are using PROGBITS, linux requires |
| 663 | // page align. | 663 | // page align. |
| 664 | const alignment = if (is_linux) self.page_size else @as(u16, ptr_size); | 664 | const alignment = if (has_os) self.page_size else @as(u16, ptr_size); |
| 665 | const filesz = @as(u64, ptr_size) * options.symbol_count_hint; | 665 | const filesz = @as(u64, ptr_size) * options.symbol_count_hint; |
| 666 | const off = self.findFreeSpace(filesz, alignment); | 666 | const off = self.findFreeSpace(filesz, alignment); |
| 667 | self.phdr_zig_got_index = try self.addPhdr(.{ | 667 | self.phdr_zig_got_index = try self.addPhdr(.{ |
| ... | @@ -676,7 +676,7 @@ pub fn initMetadata(self: *Elf, options: InitMetadataOptions) !void { | ... | @@ -676,7 +676,7 @@ pub fn initMetadata(self: *Elf, options: InitMetadataOptions) !void { |
| 676 | } | 676 | } |
| 677 | | 677 | |
| 678 | if (self.phdr_zig_load_ro_index == null) { | 678 | if (self.phdr_zig_load_ro_index == null) { |
| 679 | const alignment = if (is_linux) self.page_size else @as(u16, ptr_size); | 679 | const alignment = if (has_os) self.page_size else @as(u16, ptr_size); |
| 680 | const filesz: u64 = 1024; | 680 | const filesz: u64 = 1024; |
| 681 | const off = self.findFreeSpace(filesz, alignment); | 681 | const off = self.findFreeSpace(filesz, alignment); |
| 682 | self.phdr_zig_load_ro_index = try self.addPhdr(.{ | 682 | self.phdr_zig_load_ro_index = try self.addPhdr(.{ |
| ... | @@ -691,7 +691,7 @@ pub fn initMetadata(self: *Elf, options: InitMetadataOptions) !void { | ... | @@ -691,7 +691,7 @@ pub fn initMetadata(self: *Elf, options: InitMetadataOptions) !void { |
| 691 | } | 691 | } |
| 692 | | 692 | |
| 693 | if (self.phdr_zig_load_rw_index == null) { | 693 | if (self.phdr_zig_load_rw_index == null) { |
| 694 | const alignment = if (is_linux) self.page_size else @as(u16, ptr_size); | 694 | const alignment = if (has_os) self.page_size else @as(u16, ptr_size); |
| 695 | const filesz: u64 = 1024; | 695 | const filesz: u64 = 1024; |
| 696 | const off = self.findFreeSpace(filesz, alignment); | 696 | const off = self.findFreeSpace(filesz, alignment); |
| 697 | self.phdr_zig_load_rw_index = try self.addPhdr(.{ | 697 | self.phdr_zig_load_rw_index = try self.addPhdr(.{ |
| ... | @@ -706,7 +706,7 @@ pub fn initMetadata(self: *Elf, options: InitMetadataOptions) !void { | ... | @@ -706,7 +706,7 @@ pub fn initMetadata(self: *Elf, options: InitMetadataOptions) !void { |
| 706 | } | 706 | } |
| 707 | | 707 | |
| 708 | if (self.phdr_zig_load_zerofill_index == null) { | 708 | if (self.phdr_zig_load_zerofill_index == null) { |
| 709 | const alignment = if (is_linux) self.page_size else @as(u16, ptr_size); | 709 | const alignment = if (has_os) self.page_size else @as(u16, ptr_size); |
| 710 | self.phdr_zig_load_zerofill_index = try self.addPhdr(.{ | 710 | self.phdr_zig_load_zerofill_index = try self.addPhdr(.{ |
| 711 | .type = elf.PT_LOAD, | 711 | .type = elf.PT_LOAD, |
| 712 | .addr = if (ptr_bit_width >= 32) 0x14000000 else 0xf000, | 712 | .addr = if (ptr_bit_width >= 32) 0x14000000 else 0xf000, |