authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-09-27 20:05:46+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-09-27 20:05:46+02:00
log8f90dbba557b33db4f84729925bf9773f9c5c168
tree080cd468cd403f7fb4054d2c2f6924d1e2cf78de
parent8b7255c22a9dcdd9396bbd1f7c212a5c2be71dd0

elf: fix typo in selecting larger addrspace for load segments


1 files changed, 5 insertions(+), 4 deletions(-)

src/link/Elf.zig+5-4
......@@ -534,6 +534,7 @@ pub fn populateMissingMetadata(self: *Elf) !void {
534534 };
535535 const ptr_size: u8 = self.ptrWidthBytes();
536536 const is_linux = self.base.options.target.os.tag == .linux;
537 const large_addrspace = self.base.options.target.ptrBitWidth() >= 32;
537538 const image_base = self.calcImageBase();
538539
539540 if (self.phdr_table_index == null) {
......@@ -581,7 +582,7 @@ pub fn populateMissingMetadata(self: *Elf) !void {
581582 }
582583
583584 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;
585586 // We really only need ptr alignment but since we are using PROGBITS, linux requires
586587 // page align.
587588 const alignment = if (is_linux) self.page_size else @as(u16, ptr_size);
......@@ -594,7 +595,7 @@ pub fn populateMissingMetadata(self: *Elf) !void {
594595 }
595596
596597 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;
598599 const alignment = if (is_linux) self.page_size else @as(u16, ptr_size);
599600 self.phdr_load_ro_index = try self.allocateSegment(.{
600601 .addr = addr,
......@@ -605,7 +606,7 @@ pub fn populateMissingMetadata(self: *Elf) !void {
605606 }
606607
607608 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;
609610 const alignment = if (is_linux) self.page_size else @as(u16, ptr_size);
610611 self.phdr_load_rw_index = try self.allocateSegment(.{
611612 .addr = addr,
......@@ -616,7 +617,7 @@ pub fn populateMissingMetadata(self: *Elf) !void {
616617 }
617618
618619 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;
620621 const alignment = if (is_linux) self.page_size else @as(u16, ptr_size);
621622 self.phdr_load_zerofill_index = try self.allocateSegment(.{
622623 .addr = addr,