authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-11-12 10:29:13+01:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-11-12 18:12:41-05:00
log0dab319e86f0918331be2e49dde22e9eaf93a46b
treeea683340a274286210cd5069413500960e398e91
parent984c5985907fdb6f48543e3d1e27ffd4d54b0957

elf: dump PLT entries


2 files changed, 32 insertions(+), 1 deletions(-)

src/link/Elf.zig+2-1
...@@ -6265,8 +6265,9 @@ fn fmtDumpState(...@@ -6265,8 +6265,9 @@ fn fmtDumpState(
6265 try writer.print("linker_defined({d}) : (linker defined)\n", .{index});6265 try writer.print("linker_defined({d}) : (linker defined)\n", .{index});
6266 try writer.print("{}\n", .{linker_defined.fmtSymtab(self)});6266 try writer.print("{}\n", .{linker_defined.fmtSymtab(self)});
6267 }6267 }
6268 try writer.print("{}\n", .{self.got.fmt(self)});
6269 try writer.print("{}\n", .{self.zig_got.fmt(self)});6268 try writer.print("{}\n", .{self.zig_got.fmt(self)});
6269 try writer.print("{}\n", .{self.got.fmt(self)});
6270 try writer.print("{}\n", .{self.plt.fmt(self)});
62706271
6271 try writer.writeAll("Output COMDAT groups\n");6272 try writer.writeAll("Output COMDAT groups\n");
6272 for (self.comdat_group_sections.items) |cg| {6273 for (self.comdat_group_sections.items) |cg| {
src/link/Elf/synthetic_sections.zig+30
...@@ -935,6 +935,36 @@ pub const PltSection = struct {...@@ -935,6 +935,36 @@ pub const PltSection = struct {
935 ilocal += 1;935 ilocal += 1;
936 }936 }
937 }937 }
938
939 const FormatCtx = struct {
940 plt: PltSection,
941 elf_file: *Elf,
942 };
943
944 pub fn fmt(plt: PltSection, elf_file: *Elf) std.fmt.Formatter(format2) {
945 return .{ .data = .{ .plt = plt, .elf_file = elf_file } };
946 }
947
948 pub fn format2(
949 ctx: FormatCtx,
950 comptime unused_fmt_string: []const u8,
951 options: std.fmt.FormatOptions,
952 writer: anytype,
953 ) !void {
954 _ = options;
955 _ = unused_fmt_string;
956 try writer.writeAll("PLT\n");
957 for (ctx.plt.symbols.items, 0..) |symbol_index, i| {
958 const symbol = ctx.elf_file.symbol(symbol_index);
959 try writer.print(" {d}@0x{x} => {d}@0x{x} ({s})\n", .{
960 i,
961 symbol.pltAddress(ctx.elf_file),
962 symbol_index,
963 symbol.address(.{}, ctx.elf_file),
964 symbol.name(ctx.elf_file),
965 });
966 }
967 }
938};968};
939969
940pub const GotPltSection = struct {970pub const GotPltSection = struct {