elf: fix .eh_frame calc in relocatable mode

This commit is contained in:
Jakub Konka 2024-08-06 22:28:38 +02:00
parent e99818c602
commit 89db24ec6d
2 changed files with 7 additions and 3 deletions

View File

@ -5860,6 +5860,10 @@ pub const Ref = struct {
index: u32,
file: u32,
pub fn eql(ref: Ref, other: Ref) bool {
return ref.index == other.index and ref.file == other.file;
}
pub fn format(
ref: Ref,
comptime unused_fmt_string: []const u8,

View File

@ -145,10 +145,10 @@ pub const Cie = struct {
if (cie_rel.r_addend != other_rel.r_addend) return false;
const cie_object = elf_file.file(cie.file_index).?.object;
const cie_ref = cie_object.resolveSymbol(cie_rel.r_sym(), elf_file);
const other_object = elf_file.file(other.file_index).?.object;
const cie_sym = cie_object.symbols.items[cie_rel.r_sym()];
const other_sym = other_object.symbols.items[other_rel.r_sym()];
if (!std.mem.eql(u8, std.mem.asBytes(&cie_sym), std.mem.asBytes(&other_sym))) return false;
const other_ref = other_object.resolveSymbol(other_rel.r_sym(), elf_file);
if (!cie_ref.eql(other_ref)) return false;
}
return true;
}