| author | |
| committer | |
| log | 3606b5df3f185edd69af823d3cae213e4b93ff39 |
| tree | 393bfeef944ad3b311580427e00adeb751046327 |
| parent | ec2671d16b9363ad7f39312552456cf5e449e930 |
4 files changed, 7 insertions(+), 5 deletions(-)
src/link/Elf.zig+1-1| ... | @@ -1943,7 +1943,7 @@ fn scanRelocs(self: *Elf) !void { | ... | @@ -1943,7 +1943,7 @@ fn scanRelocs(self: *Elf) !void { |
| 1943 | 1943 | ||
| 1944 | for (self.symbols.items, 0..) |*sym, i| { | 1944 | for (self.symbols.items, 0..) |*sym, i| { |
| 1945 | const index = @as(u32, @intCast(i)); | 1945 | const index = @as(u32, @intCast(i)); |
| 1946 | if (!sym.isLocal() and !sym.flags.has_dynamic) { | 1946 | if (!sym.isLocal(self) and !sym.flags.has_dynamic) { |
| 1947 | log.debug("'{s}' is non-local", .{sym.name(self)}); | 1947 | log.debug("'{s}' is non-local", .{sym.name(self)}); |
| 1948 | try self.dynsym.addSymbol(index, self); | 1948 | try self.dynsym.addSymbol(index, self); |
| 1949 | } | 1949 | } |
src/link/Elf/Symbol.zig+3-2| ... | @@ -42,7 +42,8 @@ pub fn outputShndx(symbol: Symbol) ?u16 { | ... | @@ -42,7 +42,8 @@ pub fn outputShndx(symbol: Symbol) ?u16 { |
| 42 | return symbol.output_section_index; | 42 | return symbol.output_section_index; |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | pub fn isLocal(symbol: Symbol) bool { | 45 | pub fn isLocal(symbol: Symbol, elf_file: *Elf) bool { |
| 46 | if (elf_file.isObject()) return symbol.elfSym(elf_file).st_bind() == elf.STB_LOCAL; | ||
| 46 | return !(symbol.flags.import or symbol.flags.@"export"); | 47 | return !(symbol.flags.import or symbol.flags.@"export"); |
| 47 | } | 48 | } |
| 48 | 49 | ||
| ... | @@ -208,7 +209,7 @@ pub fn setOutputSym(symbol: Symbol, elf_file: *Elf, out: *elf.Elf64_Sym) void { | ... | @@ -208,7 +209,7 @@ pub fn setOutputSym(symbol: Symbol, elf_file: *Elf, out: *elf.Elf64_Sym) void { |
| 208 | const esym = symbol.elfSym(elf_file); | 209 | const esym = symbol.elfSym(elf_file); |
| 209 | const st_type = symbol.type(elf_file); | 210 | const st_type = symbol.type(elf_file); |
| 210 | const st_bind: u8 = blk: { | 211 | const st_bind: u8 = blk: { |
| 211 | if (symbol.isLocal()) break :blk 0; | 212 | if (symbol.isLocal(elf_file)) break :blk 0; |
| 212 | if (symbol.flags.weak) break :blk elf.STB_WEAK; | 213 | if (symbol.flags.weak) break :blk elf.STB_WEAK; |
| 213 | if (file_ptr == .shared_object) break :blk elf.STB_GLOBAL; | 214 | if (file_ptr == .shared_object) break :blk elf.STB_GLOBAL; |
| 214 | break :blk esym.st_bind(); | 215 | break :blk esym.st_bind(); |
src/link/Elf/ZigObject.zig+1| ... | @@ -1192,6 +1192,7 @@ pub fn updateExports( | ... | @@ -1192,6 +1192,7 @@ pub fn updateExports( |
| 1192 | global_esym.st_shndx = esym.st_shndx; | 1192 | global_esym.st_shndx = esym.st_shndx; |
| 1193 | global_esym.st_info = (stb_bits << 4) | stt_bits; | 1193 | global_esym.st_info = (stb_bits << 4) | stt_bits; |
| 1194 | global_esym.st_name = name_off; | 1194 | global_esym.st_name = name_off; |
| 1195 | global_esym.st_size = esym.st_size; | ||
| 1195 | self.global_esyms.items(.shndx)[actual_esym_index] = esym_shndx; | 1196 | self.global_esyms.items(.shndx)[actual_esym_index] = esym_shndx; |
| 1196 | } | 1197 | } |
| 1197 | } | 1198 | } |
src/link/Elf/file.zig+2-2| ... | @@ -150,7 +150,7 @@ pub const File = union(enum) { | ... | @@ -150,7 +150,7 @@ pub const File = union(enum) { |
| 150 | if (file_ptr.index() != file.index()) continue; | 150 | if (file_ptr.index() != file.index()) continue; |
| 151 | if (global.atom(elf_file)) |atom| if (!atom.flags.alive) continue; | 151 | if (global.atom(elf_file)) |atom| if (!atom.flags.alive) continue; |
| 152 | global.flags.output_symtab = true; | 152 | global.flags.output_symtab = true; |
| 153 | if (global.isLocal()) { | 153 | if (global.isLocal(elf_file)) { |
| 154 | output_symtab_size.nlocals += 1; | 154 | output_symtab_size.nlocals += 1; |
| 155 | } else { | 155 | } else { |
| 156 | output_symtab_size.nglobals += 1; | 156 | output_symtab_size.nglobals += 1; |
| ... | @@ -181,7 +181,7 @@ pub const File = union(enum) { | ... | @@ -181,7 +181,7 @@ pub const File = union(enum) { |
| 181 | const st_name = @as(u32, @intCast(elf_file.strtab.items.len)); | 181 | const st_name = @as(u32, @intCast(elf_file.strtab.items.len)); |
| 182 | elf_file.strtab.appendSliceAssumeCapacity(global.name(elf_file)); | 182 | elf_file.strtab.appendSliceAssumeCapacity(global.name(elf_file)); |
| 183 | elf_file.strtab.appendAssumeCapacity(0); | 183 | elf_file.strtab.appendAssumeCapacity(0); |
| 184 | if (global.isLocal()) { | 184 | if (global.isLocal(elf_file)) { |
| 185 | const out_sym = &elf_file.symtab.items[ilocal]; | 185 | const out_sym = &elf_file.symtab.items[ilocal]; |
| 186 | out_sym.st_name = st_name; | 186 | out_sym.st_name = st_name; |
| 187 | global.setOutputSym(elf_file, out_sym); | 187 | global.setOutputSym(elf_file, out_sym); |