authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-10-20 09:09:01+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-10-20 09:21:17+02:00
log43344833c52dad441475c5eaceb257f524980c60
tree89ed665b78a34926d43bc902060de1c0fc88b6d1
parent762ad4c6f49dfa1b8893353fb099d4e93672733f
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

link.Dwarf: Fix function alignment calculation to match the rest of the linker.

In particular, for user-specified alignment values, we need to do max(user_align, minFunctionAlignment()) to respect the ABI minimum.

1 files changed, 5 insertions(+), 2 deletions(-)

src/link/Dwarf.zig+5-2
......@@ -2372,8 +2372,11 @@ pub fn initWipNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.In
23722372 try wip_nav.infoAddrSym(sym_index, 0);
23732373 wip_nav.func_high_pc = @intCast(wip_nav.debug_info.items.len);
23742374 try diw.writeInt(u32, 0, dwarf.endian);
2375 try uleb128(diw, nav.status.resolved.alignment.toByteUnits() orelse
2376 target_info.defaultFunctionAlignment(file.mod.resolved_target.result).toByteUnits().?);
2375 const target = file.mod.resolved_target.result;
2376 try uleb128(diw, switch (nav.status.resolved.alignment) {
2377 .none => target_info.defaultFunctionAlignment(target),
2378 else => |a| a.maxStrict(target_info.minFunctionAlignment(target)),
2379 }.toByteUnits().?);
23772380 try diw.writeByte(@intFromBool(false));
23782381 try diw.writeByte(@intFromBool(func_type.return_type == .noreturn_type));
23792382