| ... | ... | @@ -534,6 +534,7 @@ pub fn populateMissingMetadata(self: *Elf) !void { |
| 534 | 534 | }; |
| 535 | 535 | const ptr_size: u8 = self.ptrWidthBytes(); |
| 536 | 536 | const is_linux = self.base.options.target.os.tag == .linux; |
| 537 | const large_addrspace = self.base.options.target.ptrBitWidth() >= 32; |
| 537 | 538 | const image_base = self.calcImageBase(); |
| 538 | 539 | |
| 539 | 540 | if (self.phdr_table_index == null) { |
| ... | ... | @@ -581,7 +582,7 @@ pub fn populateMissingMetadata(self: *Elf) !void { |
| 581 | 582 | } |
| 582 | 583 | |
| 583 | 584 | if (self.phdr_got_index == null) { |
| 584 | | const addr: u64 = if (ptr_size >= 4) 0x4000000 else 0x8000; |
| 585 | const addr: u64 = if (large_addrspace) 0x4000000 else 0x8000; |
| 585 | 586 | // We really only need ptr alignment but since we are using PROGBITS, linux requires |
| 586 | 587 | // page align. |
| 587 | 588 | const alignment = if (is_linux) self.page_size else @as(u16, ptr_size); |
| ... | ... | @@ -594,7 +595,7 @@ pub fn populateMissingMetadata(self: *Elf) !void { |
| 594 | 595 | } |
| 595 | 596 | |
| 596 | 597 | if (self.phdr_load_ro_index == null) { |
| 597 | | const addr: u64 = if (ptr_size >= 4) 0xc000000 else 0xa000; |
| 598 | const addr: u64 = if (large_addrspace) 0xc000000 else 0xa000; |
| 598 | 599 | const alignment = if (is_linux) self.page_size else @as(u16, ptr_size); |
| 599 | 600 | self.phdr_load_ro_index = try self.allocateSegment(.{ |
| 600 | 601 | .addr = addr, |
| ... | ... | @@ -605,7 +606,7 @@ pub fn populateMissingMetadata(self: *Elf) !void { |
| 605 | 606 | } |
| 606 | 607 | |
| 607 | 608 | if (self.phdr_load_rw_index == null) { |
| 608 | | const addr: u64 = if (ptr_size >= 4) 0x10000000 else 0xc000; |
| 609 | const addr: u64 = if (large_addrspace) 0x10000000 else 0xc000; |
| 609 | 610 | const alignment = if (is_linux) self.page_size else @as(u16, ptr_size); |
| 610 | 611 | self.phdr_load_rw_index = try self.allocateSegment(.{ |
| 611 | 612 | .addr = addr, |
| ... | ... | @@ -616,7 +617,7 @@ pub fn populateMissingMetadata(self: *Elf) !void { |
| 616 | 617 | } |
| 617 | 618 | |
| 618 | 619 | if (self.phdr_load_zerofill_index == null) { |
| 619 | | const addr: u64 = if (ptr_size >= 4) 0x14000000 else 0xf000; |
| 620 | const addr: u64 = if (large_addrspace) 0x14000000 else 0xf000; |
| 620 | 621 | const alignment = if (is_linux) self.page_size else @as(u16, ptr_size); |
| 621 | 622 | self.phdr_load_zerofill_index = try self.allocateSegment(.{ |
| 622 | 623 | .addr = addr, |