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.
This commit is contained in:
Alex Rønne Petersen 2024-10-20 09:09:01 +02:00
parent 762ad4c6f4
commit 43344833c5
No known key found for this signature in database

View File

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