authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-05-23 10:19:17+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-05-23 12:04:17+02:00
logf3a503eca26e39e7a0870bf02c24b2879ae2cc18
tree0f3420c72b041e2e4f886eaf0c50f13a4267059b
parent71bbc5efc9c35e4d862dba4f40e5bafe165fcbe4

link/macho: ensure we set alignment of literals to max alignment


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

src/link/MachO/InternalObject.zig+3
...@@ -165,6 +165,7 @@ pub fn dedupLiterals(self: InternalObject, lp: MachO.LiteralPool, macho_file: *M...@@ -165,6 +165,7 @@ pub fn dedupLiterals(self: InternalObject, lp: MachO.LiteralPool, macho_file: *M
165 if (target.getLiteralPoolIndex(macho_file)) |lp_index| {165 if (target.getLiteralPoolIndex(macho_file)) |lp_index| {
166 const lp_atom = lp.getAtom(lp_index, macho_file);166 const lp_atom = lp.getAtom(lp_index, macho_file);
167 if (target.atom_index != lp_atom.atom_index) {167 if (target.atom_index != lp_atom.atom_index) {
168 lp_atom.alignment = lp_atom.alignment.max(target.alignment);
168 target.flags.alive = false;169 target.flags.alive = false;
169 rel.target = lp_atom.atom_index;170 rel.target = lp_atom.atom_index;
170 }171 }
...@@ -176,6 +177,7 @@ pub fn dedupLiterals(self: InternalObject, lp: MachO.LiteralPool, macho_file: *M...@@ -176,6 +177,7 @@ pub fn dedupLiterals(self: InternalObject, lp: MachO.LiteralPool, macho_file: *M
176 if (target_atom.getLiteralPoolIndex(macho_file)) |lp_index| {177 if (target_atom.getLiteralPoolIndex(macho_file)) |lp_index| {
177 const lp_atom = lp.getAtom(lp_index, macho_file);178 const lp_atom = lp.getAtom(lp_index, macho_file);
178 if (target_atom.atom_index != lp_atom.atom_index) {179 if (target_atom.atom_index != lp_atom.atom_index) {
180 lp_atom.alignment = lp_atom.alignment.max(target_atom.alignment);
179 target_atom.flags.alive = false;181 target_atom.flags.alive = false;
180 target_sym.atom = lp_atom.atom_index;182 target_sym.atom = lp_atom.atom_index;
181 }183 }
...@@ -193,6 +195,7 @@ pub fn dedupLiterals(self: InternalObject, lp: MachO.LiteralPool, macho_file: *M...@@ -193,6 +195,7 @@ pub fn dedupLiterals(self: InternalObject, lp: MachO.LiteralPool, macho_file: *M
193 if (atom.getLiteralPoolIndex(macho_file)) |lp_index| {195 if (atom.getLiteralPoolIndex(macho_file)) |lp_index| {
194 const lp_atom = lp.getAtom(lp_index, macho_file);196 const lp_atom = lp.getAtom(lp_index, macho_file);
195 if (atom.atom_index != lp_atom.atom_index) {197 if (atom.atom_index != lp_atom.atom_index) {
198 lp_atom.alignment = lp_atom.alignment.max(atom.alignment);
196 atom.flags.alive = false;199 atom.flags.alive = false;
197 extra.objc_selrefs = lp_atom.atom_index;200 extra.objc_selrefs = lp_atom.atom_index;
198 sym.setExtra(extra, macho_file);201 sym.setExtra(extra, macho_file);
src/link/MachO/Object.zig+2
...@@ -593,6 +593,7 @@ pub fn dedupLiterals(self: Object, lp: MachO.LiteralPool, macho_file: *MachO) vo...@@ -593,6 +593,7 @@ pub fn dedupLiterals(self: Object, lp: MachO.LiteralPool, macho_file: *MachO) vo
593 if (target.getLiteralPoolIndex(macho_file)) |lp_index| {593 if (target.getLiteralPoolIndex(macho_file)) |lp_index| {
594 const lp_atom = lp.getAtom(lp_index, macho_file);594 const lp_atom = lp.getAtom(lp_index, macho_file);
595 if (target.atom_index != lp_atom.atom_index) {595 if (target.atom_index != lp_atom.atom_index) {
596 lp_atom.alignment = lp_atom.alignment.max(target.alignment);
596 target.flags.alive = false;597 target.flags.alive = false;
597 rel.target = lp_atom.atom_index;598 rel.target = lp_atom.atom_index;
598 }599 }
...@@ -604,6 +605,7 @@ pub fn dedupLiterals(self: Object, lp: MachO.LiteralPool, macho_file: *MachO) vo...@@ -604,6 +605,7 @@ pub fn dedupLiterals(self: Object, lp: MachO.LiteralPool, macho_file: *MachO) vo
604 if (target_atom.getLiteralPoolIndex(macho_file)) |lp_index| {605 if (target_atom.getLiteralPoolIndex(macho_file)) |lp_index| {
605 const lp_atom = lp.getAtom(lp_index, macho_file);606 const lp_atom = lp.getAtom(lp_index, macho_file);
606 if (target_atom.atom_index != lp_atom.atom_index) {607 if (target_atom.atom_index != lp_atom.atom_index) {
608 lp_atom.alignment = lp_atom.alignment.max(target_atom.alignment);
607 target_atom.flags.alive = false;609 target_atom.flags.alive = false;
608 target_sym.atom = lp_atom.atom_index;610 target_sym.atom = lp_atom.atom_index;
609 }611 }