commit f3a503eca26e39e7a0870bf02c24b2879ae2cc18 (tree)
parent 71bbc5efc9c35e4d862dba4f40e5bafe165fcbe4
Author: Jakub Konka <kubkon@jakubkonka.com>
Date: Thu, 23 May 2024 10:19:17 +0200
link/macho: ensure we set alignment of literals to max alignment
Diffstat:
2 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/src/link/MachO/InternalObject.zig b/src/link/MachO/InternalObject.zig
@@ -165,6 +165,7 @@ pub fn dedupLiterals(self: InternalObject, lp: MachO.LiteralPool, macho_file: *M
if (target.getLiteralPoolIndex(macho_file)) |lp_index| {
const lp_atom = lp.getAtom(lp_index, macho_file);
if (target.atom_index != lp_atom.atom_index) {
+ lp_atom.alignment = lp_atom.alignment.max(target.alignment);
target.flags.alive = false;
rel.target = lp_atom.atom_index;
}
@@ -176,6 +177,7 @@ pub fn dedupLiterals(self: InternalObject, lp: MachO.LiteralPool, macho_file: *M
if (target_atom.getLiteralPoolIndex(macho_file)) |lp_index| {
const lp_atom = lp.getAtom(lp_index, macho_file);
if (target_atom.atom_index != lp_atom.atom_index) {
+ lp_atom.alignment = lp_atom.alignment.max(target_atom.alignment);
target_atom.flags.alive = false;
target_sym.atom = lp_atom.atom_index;
}
@@ -193,6 +195,7 @@ pub fn dedupLiterals(self: InternalObject, lp: MachO.LiteralPool, macho_file: *M
if (atom.getLiteralPoolIndex(macho_file)) |lp_index| {
const lp_atom = lp.getAtom(lp_index, macho_file);
if (atom.atom_index != lp_atom.atom_index) {
+ lp_atom.alignment = lp_atom.alignment.max(atom.alignment);
atom.flags.alive = false;
extra.objc_selrefs = lp_atom.atom_index;
sym.setExtra(extra, macho_file);
diff --git a/src/link/MachO/Object.zig b/src/link/MachO/Object.zig
@@ -593,6 +593,7 @@ pub fn dedupLiterals(self: Object, lp: MachO.LiteralPool, macho_file: *MachO) vo
if (target.getLiteralPoolIndex(macho_file)) |lp_index| {
const lp_atom = lp.getAtom(lp_index, macho_file);
if (target.atom_index != lp_atom.atom_index) {
+ lp_atom.alignment = lp_atom.alignment.max(target.alignment);
target.flags.alive = false;
rel.target = lp_atom.atom_index;
}
@@ -604,6 +605,7 @@ pub fn dedupLiterals(self: Object, lp: MachO.LiteralPool, macho_file: *MachO) vo
if (target_atom.getLiteralPoolIndex(macho_file)) |lp_index| {
const lp_atom = lp.getAtom(lp_index, macho_file);
if (target_atom.atom_index != lp_atom.atom_index) {
+ lp_atom.alignment = lp_atom.alignment.max(target_atom.alignment);
target_atom.flags.alive = false;
target_sym.atom = lp_atom.atom_index;
}