| author | |
| committer | |
| log | 8ca809d928219950ce606b4f8a18ccb52e644407 |
| tree | a9a79983468181184c75dcbe168e8cca0956a746 |
| parent | 41e9b8b6c84a1787ffa647fc42980dcce4942b7d |
3 files changed, 14 insertions(+), 12 deletions(-)
src/link/Elf.zig-8| ... | @@ -5252,14 +5252,6 @@ pub fn isCIdentifier(name: []const u8) bool { | ... | @@ -5252,14 +5252,6 @@ pub fn isCIdentifier(name: []const u8) bool { |
| 5252 | return true; | 5252 | return true; |
| 5253 | } | 5253 | } |
| 5254 | 5254 | ||
| 5255 | pub fn getStartStopBasename(self: *Elf, shdr: elf.Elf64_Shdr) ?[]const u8 { | ||
| 5256 | const name = self.getShString(shdr.sh_name); | ||
| 5257 | if (shdr.sh_flags & elf.SHF_ALLOC != 0 and name.len > 0) { | ||
| 5258 | if (isCIdentifier(name)) return name; | ||
| 5259 | } | ||
| 5260 | return null; | ||
| 5261 | } | ||
| 5262 | |||
| 5263 | pub fn addThunk(self: *Elf) !Thunk.Index { | 5255 | pub fn addThunk(self: *Elf) !Thunk.Index { |
| 5264 | const index = @as(Thunk.Index, @intCast(self.thunks.items.len)); | 5256 | const index = @as(Thunk.Index, @intCast(self.thunks.items.len)); |
| 5265 | const th = try self.thunks.addOne(self.base.comp.gpa); | 5257 | const th = try self.thunks.addOne(self.base.comp.gpa); |
src/link/Elf/LinkerDefined.zig+6-4| ... | @@ -95,8 +95,9 @@ pub fn initSymbols(self: *LinkerDefined, elf_file: *Elf) !void { | ... | @@ -95,8 +95,9 @@ pub fn initSymbols(self: *LinkerDefined, elf_file: *Elf) !void { |
| 95 | 95 | ||
| 96 | var start_stop_count: usize = 0; | 96 | var start_stop_count: usize = 0; |
| 97 | for (elf_file.objects.items) |index| { | 97 | for (elf_file.objects.items) |index| { |
| 98 | for (elf_file.file(index).?.object.shdrs.items) |shdr| { | 98 | const object = elf_file.file(index).?.object; |
| 99 | if (elf_file.getStartStopBasename(shdr)) |_| { | 99 | for (object.shdrs.items) |shdr| { |
| 100 | if (object.getStartStopBasename(shdr)) |_| { | ||
| 100 | start_stop_count += 2; // __start_, __stop_ | 101 | start_stop_count += 2; // __start_, __stop_ |
| 101 | } | 102 | } |
| 102 | } | 103 | } |
| ... | @@ -140,8 +141,9 @@ pub fn initSymbols(self: *LinkerDefined, elf_file: *Elf) !void { | ... | @@ -140,8 +141,9 @@ pub fn initSymbols(self: *LinkerDefined, elf_file: *Elf) !void { |
| 140 | } | 141 | } |
| 141 | 142 | ||
| 142 | for (elf_file.objects.items) |index| { | 143 | for (elf_file.objects.items) |index| { |
| 143 | for (elf_file.file(index).?.object.shdrs.items) |shdr| { | 144 | const object = elf_file.file(index).?.object; |
| 144 | if (elf_file.getStartStopBasename(shdr)) |name| { | 145 | for (object.shdrs.items) |shdr| { |
| 146 | if (object.getStartStopBasename(shdr)) |name| { | ||
| 145 | const start_name = try std.fmt.allocPrintZ(gpa, "__start_{s}", .{name}); | 147 | const start_name = try std.fmt.allocPrintZ(gpa, "__start_{s}", .{name}); |
| 146 | defer gpa.free(start_name); | 148 | defer gpa.free(start_name); |
| 147 | const stop_name = try std.fmt.allocPrintZ(gpa, "__stop_{s}", .{name}); | 149 | const stop_name = try std.fmt.allocPrintZ(gpa, "__stop_{s}", .{name}); |
src/link/Elf/Object.zig+8| ... | @@ -1444,6 +1444,14 @@ pub fn comdatGroup(self: *Object, index: Elf.ComdatGroup.Index) *Elf.ComdatGroup | ... | @@ -1444,6 +1444,14 @@ pub fn comdatGroup(self: *Object, index: Elf.ComdatGroup.Index) *Elf.ComdatGroup |
| 1444 | return &self.comdat_groups.items[index]; | 1444 | return &self.comdat_groups.items[index]; |
| 1445 | } | 1445 | } |
| 1446 | 1446 | ||
| 1447 | pub fn getStartStopBasename(self: Object, shdr: elf.Elf64_Shdr) ?[]const u8 { | ||
| 1448 | const name = self.getString(shdr.sh_name); | ||
| 1449 | if (shdr.sh_flags & elf.SHF_ALLOC != 0 and name.len > 0) { | ||
| 1450 | if (Elf.isCIdentifier(name)) return name; | ||
| 1451 | } | ||
| 1452 | return null; | ||
| 1453 | } | ||
| 1454 | |||
| 1447 | pub fn format( | 1455 | pub fn format( |
| 1448 | self: *Object, | 1456 | self: *Object, |
| 1449 | comptime unused_fmt_string: []const u8, | 1457 | comptime unused_fmt_string: []const u8, |