| ... | @@ -159,6 +159,14 @@ pub fn write(zld: *Zld, unwind_info: *UnwindInfo) !void { | ... | @@ -159,6 +159,14 @@ pub fn write(zld: *Zld, unwind_info: *UnwindInfo) !void { |
| 159 | switch (cpu_arch) { | 159 | switch (cpu_arch) { |
| 160 | .aarch64 => {}, // relocs take care of LSDA pointers | 160 | .aarch64 => {}, // relocs take care of LSDA pointers |
| 161 | .x86_64 => { | 161 | .x86_64 => { |
| | 162 | // We need to relocate target symbol address ourselves. |
| | 163 | const atom = zld.getAtom(atom_index); |
| | 164 | const atom_sym = zld.getSymbol(atom.getSymbolWithLoc()); |
| | 165 | try fde_record.setTargetSymbolAddress(atom_sym.n_value, .{ |
| | 166 | .base_addr = sect.addr, |
| | 167 | .base_offset = eh_frame_offset, |
| | 168 | }); |
| | 169 | |
| 162 | // We need to parse LSDA pointer and relocate ourselves. | 170 | // We need to parse LSDA pointer and relocate ourselves. |
| 163 | const cie_record = eh_records.get( | 171 | const cie_record = eh_records.get( |
| 164 | eh_frame_offset + 4 - fde_record.getCiePointer(), | 172 | eh_frame_offset + 4 - fde_record.getCiePointer(), |
| ... | @@ -267,7 +275,7 @@ pub fn EhFrameRecord(comptime is_mutable: bool) type { | ... | @@ -267,7 +275,7 @@ pub fn EhFrameRecord(comptime is_mutable: bool) type { |
| 267 | }) !void { | 275 | }) !void { |
| 268 | assert(rec.tag == .fde); | 276 | assert(rec.tag == .fde); |
| 269 | const addend = @intCast(i64, value) - @intCast(i64, ctx.base_addr + ctx.base_offset + 8); | 277 | const addend = @intCast(i64, value) - @intCast(i64, ctx.base_addr + ctx.base_offset + 8); |
| 270 | mem.writeIntLittle(i64, addend, rec.data[4..][0..8]); | 278 | mem.writeIntLittle(i64, rec.data[4..][0..8], addend); |
| 271 | } | 279 | } |
| 272 | | 280 | |
| 273 | pub fn getPersonalityPointerReloc( | 281 | pub fn getPersonalityPointerReloc( |