mirror of
https://github.com/ziglang/zig.git
synced 2025-12-18 20:23:07 +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 {
|
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);
|
const end = start + padToIdeal(size);
|
||||||
|
|
||||||
if (self.base.isRelocatable()) {
|
if (self.base.isRelocatable()) {
|
||||||
@ -3234,12 +3240,6 @@ fn detectAllocCollisionVirtual(self: *MachO, start: u64, size: u64) ?u64 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} 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| {
|
for (self.segments.items) |seg| {
|
||||||
const increased_size = padToIdeal(seg.vmsize);
|
const increased_size = padToIdeal(seg.vmsize);
|
||||||
const test_end = seg.vmaddr +| increased_size;
|
const test_end = seg.vmaddr +| increased_size;
|
||||||
|
|||||||
@ -849,6 +849,7 @@ fn testLinkingStaticLib(b: *Build, opts: Options) *Step {
|
|||||||
const obj = addObject(b, opts, .{
|
const obj = addObject(b, opts, .{
|
||||||
.name = "bobj",
|
.name = "bobj",
|
||||||
.zig_source_bytes = "export var bar: i32 = -42;",
|
.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, .{
|
const lib = addStaticLibrary(b, opts, .{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user