mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 21:08:36 +00:00
elf: calculate required size for .rela.eh_frame
This commit is contained in:
parent
666ac6bf9b
commit
0efc471122
@ -4245,6 +4245,11 @@ fn updateSectionSizesObject(self: *Elf) !void {
|
||||
|
||||
if (self.eh_frame_section_index) |index| {
|
||||
self.shdrs.items[index].sh_size = try eh_frame.calcEhFrameSize(self);
|
||||
|
||||
if (self.eh_frame_rela_section_index) |rela_index| {
|
||||
const shdr = &self.shdrs.items[rela_index];
|
||||
shdr.sh_size = eh_frame.calcEhFrameRelocs(self) * shdr.sh_entsize;
|
||||
}
|
||||
}
|
||||
|
||||
try self.updateSymtabSize();
|
||||
|
||||
@ -282,6 +282,22 @@ pub fn calcEhFrameHdrSize(elf_file: *Elf) usize {
|
||||
return eh_frame_hdr_header_size + count * 8;
|
||||
}
|
||||
|
||||
pub fn calcEhFrameRelocs(elf_file: *Elf) usize {
|
||||
var count: usize = 0;
|
||||
for (elf_file.objects.items) |index| {
|
||||
const object = elf_file.file(index).?.object;
|
||||
for (object.cies.items) |cie| {
|
||||
if (!cie.alive) continue;
|
||||
count += cie.relocs(elf_file).len;
|
||||
}
|
||||
for (object.fdes.items) |fde| {
|
||||
if (!fde.alive) continue;
|
||||
count += fde.relocs(elf_file).len;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
fn resolveReloc(rec: anytype, sym: *const Symbol, rel: elf.Elf64_Rela, elf_file: *Elf, contents: []u8) !void {
|
||||
const offset = std.math.cast(usize, rel.r_offset - rec.offset) orelse return error.Overflow;
|
||||
const P = @as(i64, @intCast(rec.address(elf_file) + offset));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user