mirror of
https://github.com/ziglang/zig.git
synced 2025-12-16 03:03:09 +00:00
macho: align memory size with file size when emitting relocatable
This commit is contained in:
parent
7388534590
commit
925273bcc8
@ -3223,6 +3223,12 @@ fn detectAllocCollision(self: *MachO, start: u64, size: u64) ?u64 {
|
||||
}
|
||||
|
||||
fn detectAllocCollisionVirtual(self: *MachO, start: u64, size: u64) ?u64 {
|
||||
// Conservatively commit one page size as reserved space for the headers as we
|
||||
// expect it to grow and everything else be moved in flush anyhow.
|
||||
const header_size = self.getPageSize();
|
||||
if (start < header_size)
|
||||
return header_size;
|
||||
|
||||
const end = start + padToIdeal(size);
|
||||
|
||||
if (self.base.isRelocatable()) {
|
||||
@ -3234,12 +3240,6 @@ fn detectAllocCollisionVirtual(self: *MachO, start: u64, size: u64) ?u64 {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Conservatively commit one page size as reserved space for the headers as we
|
||||
// expect it to grow and everything else be moved in flush anyhow.
|
||||
const header_size = self.getPageSize();
|
||||
if (start < header_size)
|
||||
return header_size;
|
||||
|
||||
for (self.segments.items) |seg| {
|
||||
const increased_size = padToIdeal(seg.vmsize);
|
||||
const test_end = seg.vmaddr +| increased_size;
|
||||
|
||||
@ -849,6 +849,7 @@ fn testLinkingStaticLib(b: *Build, opts: Options) *Step {
|
||||
const obj = addObject(b, opts, .{
|
||||
.name = "bobj",
|
||||
.zig_source_bytes = "export var bar: i32 = -42;",
|
||||
.strip = true, // TODO for self-hosted, we don't really emit any valid DWARF yet since we only export a global
|
||||
});
|
||||
|
||||
const lib = addStaticLibrary(b, opts, .{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user