| ... | ... | @@ -511,28 +511,6 @@ pub fn populateMissingMetadata(self: *Elf) !void { |
| 511 | 511 | }; |
| 512 | 512 | const ptr_size: u8 = self.ptrWidthBytes(); |
| 513 | 513 | |
| 514 | | if (self.phdr_load_re_index == null) { |
| 515 | | self.phdr_load_re_index = @intCast(u16, self.program_headers.items.len); |
| 516 | | const file_size = self.base.options.program_code_size_hint; |
| 517 | | const p_align = self.page_size; |
| 518 | | const off = self.findFreeSpace(file_size, p_align); |
| 519 | | log.debug("found PT_LOAD RE free space 0x{x} to 0x{x}", .{ off, off + file_size }); |
| 520 | | const entry_addr: u64 = self.entry_addr orelse if (self.base.options.target.cpu.arch == .spu_2) @as(u64, 0) else default_entry_addr; |
| 521 | | try self.program_headers.append(self.base.allocator, .{ |
| 522 | | .p_type = elf.PT_LOAD, |
| 523 | | .p_offset = off, |
| 524 | | .p_filesz = file_size, |
| 525 | | .p_vaddr = entry_addr, |
| 526 | | .p_paddr = entry_addr, |
| 527 | | .p_memsz = file_size, |
| 528 | | .p_align = p_align, |
| 529 | | .p_flags = elf.PF_X | elf.PF_R, |
| 530 | | }); |
| 531 | | try self.atom_free_lists.putNoClobber(self.base.allocator, self.phdr_load_re_index.?, .{}); |
| 532 | | self.entry_addr = null; |
| 533 | | self.phdr_table_dirty = true; |
| 534 | | } |
| 535 | | |
| 536 | 514 | if (self.phdr_got_index == null) { |
| 537 | 515 | self.phdr_got_index = @intCast(u16, self.program_headers.items.len); |
| 538 | 516 | const file_size = @as(u64, ptr_size) * self.base.options.symbol_count_hint; |
| ... | ... | @@ -558,6 +536,28 @@ pub fn populateMissingMetadata(self: *Elf) !void { |
| 558 | 536 | self.phdr_table_dirty = true; |
| 559 | 537 | } |
| 560 | 538 | |
| 539 | if (self.phdr_load_re_index == null) { |
| 540 | self.phdr_load_re_index = @intCast(u16, self.program_headers.items.len); |
| 541 | const file_size = self.base.options.program_code_size_hint; |
| 542 | const p_align = self.page_size; |
| 543 | const off = self.findFreeSpace(file_size, p_align); |
| 544 | log.debug("found PT_LOAD RE free space 0x{x} to 0x{x}", .{ off, off + file_size }); |
| 545 | const entry_addr: u64 = self.entry_addr orelse if (self.base.options.target.cpu.arch == .spu_2) @as(u64, 0) else default_entry_addr; |
| 546 | try self.program_headers.append(self.base.allocator, .{ |
| 547 | .p_type = elf.PT_LOAD, |
| 548 | .p_offset = off, |
| 549 | .p_filesz = file_size, |
| 550 | .p_vaddr = entry_addr, |
| 551 | .p_paddr = entry_addr, |
| 552 | .p_memsz = file_size, |
| 553 | .p_align = p_align, |
| 554 | .p_flags = elf.PF_X | elf.PF_R, |
| 555 | }); |
| 556 | try self.atom_free_lists.putNoClobber(self.base.allocator, self.phdr_load_re_index.?, .{}); |
| 557 | self.entry_addr = null; |
| 558 | self.phdr_table_dirty = true; |
| 559 | } |
| 560 | |
| 561 | 561 | if (self.phdr_load_ro_index == null) { |
| 562 | 562 | self.phdr_load_ro_index = @intCast(u16, self.program_headers.items.len); |
| 563 | 563 | // TODO Find a hint about how much data need to be in rodata ? |