| ... | @@ -286,10 +286,6 @@ fn createFile(allocator: *Allocator, file: fs.File, options: link.Options) !Elf | ... | @@ -286,10 +286,6 @@ fn createFile(allocator: *Allocator, file: fs.File, options: link.Options) !Elf |
| 286 | }; | 286 | }; |
| 287 | errdefer self.deinit(); | 287 | errdefer self.deinit(); |
| 288 | | 288 | |
| 289 | if (options.target.cpu.arch == .spu_2) { | | |
| 290 | self.base.options.default_entry_addr = 0; | | |
| 291 | } | | |
| 292 | | | |
| 293 | // Index 0 is always a null symbol. | 289 | // Index 0 is always a null symbol. |
| 294 | try self.local_symbols.append(allocator, .{ | 290 | try self.local_symbols.append(allocator, .{ |
| 295 | .st_name = 0, | 291 | .st_name = 0, |
| ... | @@ -466,12 +462,13 @@ pub fn populateMissingMetadata(self: *Elf) !void { | ... | @@ -466,12 +462,13 @@ pub fn populateMissingMetadata(self: *Elf) !void { |
| 466 | const p_align = 0x1000; | 462 | const p_align = 0x1000; |
| 467 | const off = self.findFreeSpace(file_size, p_align); | 463 | const off = self.findFreeSpace(file_size, p_align); |
| 468 | log.debug("found PT_LOAD free space 0x{x} to 0x{x}\n", .{ off, off + file_size }); | 464 | log.debug("found PT_LOAD free space 0x{x} to 0x{x}\n", .{ off, off + file_size }); |
| | 465 | const entry_addr: u64 = self.entry_addr orelse if (self.base.options.target.cpu.arch == .spu_2) @as(u64, 0) else default_entry_addr; |
| 469 | try self.program_headers.append(self.base.allocator, .{ | 466 | try self.program_headers.append(self.base.allocator, .{ |
| 470 | .p_type = elf.PT_LOAD, | 467 | .p_type = elf.PT_LOAD, |
| 471 | .p_offset = off, | 468 | .p_offset = off, |
| 472 | .p_filesz = file_size, | 469 | .p_filesz = file_size, |
| 473 | .p_vaddr = self.base.options.default_entry_addr, | 470 | .p_vaddr = entry_addr, |
| 474 | .p_paddr = self.base.options.default_entry_addr, | 471 | .p_paddr = entry_addr, |
| 475 | .p_memsz = file_size, | 472 | .p_memsz = file_size, |
| 476 | .p_align = p_align, | 473 | .p_align = p_align, |
| 477 | .p_flags = elf.PF_X | elf.PF_R, | 474 | .p_flags = elf.PF_X | elf.PF_R, |
| ... | @@ -490,13 +487,13 @@ pub fn populateMissingMetadata(self: *Elf) !void { | ... | @@ -490,13 +487,13 @@ pub fn populateMissingMetadata(self: *Elf) !void { |
| 490 | // TODO instead of hard coding the vaddr, make a function to find a vaddr to put things at. | 487 | // TODO instead of hard coding the vaddr, make a function to find a vaddr to put things at. |
| 491 | // we'll need to re-use that function anyway, in case the GOT grows and overlaps something | 488 | // we'll need to re-use that function anyway, in case the GOT grows and overlaps something |
| 492 | // else in virtual memory. | 489 | // else in virtual memory. |
| 493 | const default_got_addr = if (self.base.options.target.cpu.arch.ptrBitWidth() == 16) @as(u32, 0x8000) else 0x4000000; | 490 | const got_addr = if (self.base.options.target.cpu.arch.ptrBitWidth() == 16) @as(u32, 0x8000) else 0x4000000; |
| 494 | try self.program_headers.append(self.base.allocator, .{ | 491 | try self.program_headers.append(self.base.allocator, .{ |
| 495 | .p_type = elf.PT_LOAD, | 492 | .p_type = elf.PT_LOAD, |
| 496 | .p_offset = off, | 493 | .p_offset = off, |
| 497 | .p_filesz = file_size, | 494 | .p_filesz = file_size, |
| 498 | .p_vaddr = default_got_addr, | 495 | .p_vaddr = got_addr, |
| 499 | .p_paddr = default_got_addr, | 496 | .p_paddr = got_addr, |
| 500 | .p_memsz = file_size, | 497 | .p_memsz = file_size, |
| 501 | .p_align = p_align, | 498 | .p_align = p_align, |
| 502 | .p_flags = elf.PF_R, | 499 | .p_flags = elf.PF_R, |