diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2021-07-20 23:37:22 +0200 |
|---|---|---|
| committer | Jakub Konka <kubkon@jakubkonka.com> | 2021-07-20 23:37:22 +0200 |
| commit | 5276ce8e638d3d295c443d8bc33e5c51538ae540 (patch) | |
| tree | 27f3a465a4a5f95d39d857c29c7ba7a6be617873 /src/link/MachO/TextBlock.zig | |
| parent | a442b165f1e219b429e497e1de26780612762871 (diff) | |
| download | zig-5276ce8e638d3d295c443d8bc33e5c51538ae540.tar.gz zig-5276ce8e638d3d295c443d8bc33e5c51538ae540.zip | |
macho: use adapters to directly reference strtab
Thanks to this, we no longer need to do allocs per symbol name
landing in the symbol resolver, plus we do not need to actively
track if the string was already inserted into the string table.
Diffstat (limited to 'src/link/MachO/TextBlock.zig')
| -rw-r--r-- | src/link/MachO/TextBlock.zig | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/link/MachO/TextBlock.zig b/src/link/MachO/TextBlock.zig index d28b9630e6..e7c0139623 100644 --- a/src/link/MachO/TextBlock.zig +++ b/src/link/MachO/TextBlock.zig @@ -640,7 +640,10 @@ fn initRelocFromObject(rel: macho.relocation_info, object: *Object, ctx: RelocCo parsed_rel.where = .local; parsed_rel.where_index = where_index; } else { - const resolv = ctx.macho_file.symbol_resolver.get(sym_name) orelse unreachable; + const n_strx = ctx.macho_file.strtab_dir.getAdapted(@as([]const u8, sym_name), MachO.StringSliceAdapter{ + .strtab = &ctx.macho_file.strtab, + }) orelse unreachable; + const resolv = ctx.macho_file.symbol_resolver.get(n_strx) orelse unreachable; switch (resolv.where) { .global => { parsed_rel.where = .local; @@ -704,7 +707,10 @@ pub fn parseRelocsFromObject( const where_index = object.symbol_mapping.get(rel.r_symbolnum) orelse unreachable; subtractor = where_index; } else { - const resolv = ctx.macho_file.symbol_resolver.get(sym_name) orelse unreachable; + const n_strx = ctx.macho_file.strtab_dir.getAdapted(@as([]const u8, sym_name), MachO.StringSliceAdapter{ + .strtab = &ctx.macho_file.strtab, + }) orelse unreachable; + const resolv = ctx.macho_file.symbol_resolver.get(n_strx) orelse unreachable; assert(resolv.where == .global); subtractor = resolv.local_sym_index; } |
