authorgravatar for koachan@protonmail.comKoakuma <koachan@protonmail.com> 2022-04-14 21:54:07+07:00
committergravatar for koachan@protonmail.comKoakuma <koachan@protonmail.com> 2022-04-14 22:18:06+07:00
loga6ce2fc3dce018964f73cf88f127ec43bf901b6e
treef7a2e80898929691b5551040800859c982050189
parent43e69be196a808c66d2c9673e7293debec01ad5d

linker: ELF: Add page sizes for ppc64le and sparcv9


1 files changed, 8 insertions(+), 3 deletions(-)

src/link/Elf.zig+8-3
......@@ -65,7 +65,7 @@ phdr_load_rw_index: ?u16 = null,
6565phdr_shdr_table: std.AutoHashMapUnmanaged(u16, u16) = .{},
6666
6767entry_addr: ?u64 = null,
68page_size: u16,
68page_size: u32,
6969
7070shstrtab: std.ArrayListUnmanaged(u8) = std.ArrayListUnmanaged(u8){},
7171shstrtab_index: ?u16 = null,
......@@ -304,7 +304,12 @@ pub fn createEmpty(gpa: Allocator, options: link.Options) !*Elf {
304304 };
305305 const self = try gpa.create(Elf);
306306 errdefer gpa.destroy(self);
307 const page_size: u16 = 0x1000; // TODO ppc64le requires 64KB
307
308 const page_size: u32 = switch (options.target.cpu.arch) {
309 .powerpc64le => 0x10000,
310 .sparcv9 => 0x2000,
311 else => 0x1000,
312 };
308313
309314 var dwarf: ?Dwarf = if (!options.strip and options.module != null)
310315 Dwarf.init(gpa, .elf, options.target)
......@@ -472,7 +477,7 @@ pub fn allocatedSize(self: *Elf, start: u64) u64 {
472477 return min_pos - start;
473478}
474479
475pub fn findFreeSpace(self: *Elf, object_size: u64, min_alignment: u16) u64 {
480pub fn findFreeSpace(self: *Elf, object_size: u64, min_alignment: u32) u64 {
476481 var start: u64 = 0;
477482 while (self.detectAllocCollision(start, object_size)) |item_end| {
478483 start = mem.alignForwardGeneric(u64, item_end, min_alignment);