| ... | @@ -105,6 +105,29 @@ pub fn address(symbol: Symbol, opts: struct { plt: bool = true }, elf_file: *Elf | ... | @@ -105,6 +105,29 @@ pub fn address(symbol: Symbol, opts: struct { plt: bool = true }, elf_file: *Elf |
| 105 | return symbol.pltAddress(elf_file); | 105 | return symbol.pltAddress(elf_file); |
| 106 | } | 106 | } |
| 107 | if (symbol.atom(elf_file)) |atom_ptr| { | 107 | if (symbol.atom(elf_file)) |atom_ptr| { |
| | 108 | if (!atom_ptr.flags.alive) { |
| | 109 | if (mem.eql(u8, atom_ptr.name(elf_file), ".eh_frame")) { |
| | 110 | const sym_name = symbol.name(elf_file); |
| | 111 | if (mem.startsWith(u8, sym_name, "__EH_FRAME_BEGIN__") or |
| | 112 | mem.startsWith(u8, sym_name, "__EH_FRAME_LIST__") or |
| | 113 | mem.startsWith(u8, sym_name, ".eh_frame_seg") or |
| | 114 | symbol.elfSym(elf_file).st_type() == elf.STT_SECTION) |
| | 115 | { |
| | 116 | return elf_file.shdrs.items[elf_file.eh_frame_section_index.?].sh_addr; |
| | 117 | } |
| | 118 | |
| | 119 | if (mem.startsWith(u8, sym_name, "__FRAME_END__") or |
| | 120 | mem.startsWith(u8, sym_name, "__EH_FRAME_LIST_END__")) |
| | 121 | { |
| | 122 | const shdr = elf_file.shdrs.items[elf_file.eh_frame_section_index.?]; |
| | 123 | return shdr.sh_addr + shdr.sh_size; |
| | 124 | } |
| | 125 | |
| | 126 | // TODO I think we potentially should error here |
| | 127 | } |
| | 128 | |
| | 129 | return 0; |
| | 130 | } |
| 108 | return atom_ptr.address(elf_file) + symbol.value; | 131 | return atom_ptr.address(elf_file) + symbol.value; |
| 109 | } | 132 | } |
| 110 | return symbol.value; | 133 | return symbol.value; |
| ... | @@ -432,6 +455,7 @@ pub const Index = u32; | ... | @@ -432,6 +455,7 @@ pub const Index = u32; |
| 432 | | 455 | |
| 433 | const assert = std.debug.assert; | 456 | const assert = std.debug.assert; |
| 434 | const elf = std.elf; | 457 | const elf = std.elf; |
| | 458 | const mem = std.mem; |
| 435 | const std = @import("std"); | 459 | const std = @import("std"); |
| 436 | const synthetic_sections = @import("synthetic_sections.zig"); | 460 | const synthetic_sections = @import("synthetic_sections.zig"); |
| 437 | | 461 | |