Commit 8c321f0cf5
src-self-hosted/link/Elf.zig
@@ -286,6 +286,10 @@ fn createFile(allocator: *Allocator, file: fs.File, options: link.Options) !Elf
};
errdefer self.deinit();
+ if (options.target.cpu.arch == .spu_2) {
+ self.base.options.default_entry_addr = 0;
+ }
+
// Index 0 is always a null symbol.
try self.local_symbols.append(allocator, .{
.st_name = 0,
@@ -466,8 +470,8 @@ pub fn populateMissingMetadata(self: *Elf) !void {
.p_type = elf.PT_LOAD,
.p_offset = off,
.p_filesz = file_size,
- .p_vaddr = default_entry_addr,
- .p_paddr = default_entry_addr,
+ .p_vaddr = self.base.options.default_entry_addr,
+ .p_paddr = self.base.options.default_entry_addr,
.p_memsz = file_size,
.p_align = p_align,
.p_flags = elf.PF_X | elf.PF_R,
@@ -486,7 +490,7 @@ pub fn populateMissingMetadata(self: *Elf) !void {
// TODO instead of hard coding the vaddr, make a function to find a vaddr to put things at.
// we'll need to re-use that function anyway, in case the GOT grows and overlaps something
// else in virtual memory.
- const default_got_addr = if (ptr_size == 2) @as(u32, 0x8000) else 0x4000000;
+ const default_got_addr = if (self.base.options.target.cpu.arch.ptrBitWidth() == 16) @as(u32, 0x8000) else 0x4000000;
try self.program_headers.append(self.base.allocator, .{
.p_type = elf.PT_LOAD,
.p_offset = off,
src-self-hosted/link.zig
@@ -5,6 +5,9 @@ const fs = std.fs;
const trace = @import("tracy.zig").trace;
const Package = @import("Package.zig");
const Type = @import("type.zig").Type;
+const build_options = @import("build_options");
+
+const producer_string = if (std.builtin.is_test) "zig test" else "zig " ++ build_options.version;
pub const Options = struct {
target: std.Target,
@@ -20,6 +23,7 @@ pub const Options = struct {
/// Used for calculating how much space to reserve for executable program code in case
/// the binary file deos not already have such a section.
program_code_size_hint: u64 = 256 * 1024,
+ default_entry_addr: u64 = 0x8000000,
};
pub const File = struct {