commit 245f6553e6840b2221141f3e7724ae6a73294387 (tree)
parent 3b6200db41f201839a7238c95ddc2e1323d8acbd
Author: Jakub Konka <kubkon@jakubkonka.com>
Date: Thu, 20 Jul 2023 20:00:44 +0200
check-object: format known OS-specific types before doing generic format
Diffstat:
1 file changed, 40 insertions(+), 43 deletions(-)
diff --git a/lib/std/Build/Step/CheckObject.zig b/lib/std/Build/Step/CheckObject.zig
@@ -1238,49 +1238,6 @@ const ElfDumper = struct {
try writer.print("{x} {x}", .{ sym.st_value, sym.st_size });
{
- const tt = sym.st_type();
- if (elf.STT_LOPROC <= tt and tt < elf.STT_HIPROC) {
- try writer.print(" LOPROC+{d}", .{tt - elf.STT_LOPROC});
- } else if (elf.STT_LOOS <= tt and tt < elf.STT_HIOS) {
- try writer.print(" LOOS+{d}", .{tt - elf.STT_LOOS});
- } else {
- const sym_type = switch (tt) {
- elf.STT_NOTYPE => "NOTYPE",
- elf.STT_OBJECT => "OBJECT",
- elf.STT_FUNC => "FUNC",
- elf.STT_SECTION => "SECTION",
- elf.STT_FILE => "FILE",
- elf.STT_COMMON => "COMMON",
- elf.STT_TLS => "TLS",
- elf.STT_NUM => "NUM",
- else => "UNK",
- };
- try writer.print(" {s}", .{sym_type});
- }
- }
-
- {
- const bind = sym.st_bind();
- if (elf.STB_LOPROC <= bind and bind < elf.STB_HIPROC) {
- try writer.print(" LOPROC+{d}", .{bind - elf.STB_LOPROC});
- } else if (elf.STB_LOOS <= bind and bind < elf.STB_HIOS) {
- try writer.print(" LOOS+{d}", .{bind - elf.STB_LOOS});
- } else {
- const sym_bind = switch (bind) {
- elf.STB_LOCAL => "LOCAL",
- elf.STB_GLOBAL => "GLOBAL",
- elf.STB_WEAK => "WEAK",
- elf.STB_NUM => "NUM",
- else => "UNKNOWN",
- };
- try writer.print(" {s}", .{sym_bind});
- }
- }
-
- const sym_vis = @as(elf.STV, @enumFromInt(sym.st_other));
- try writer.print(" {s}", .{@tagName(sym_vis)});
-
- {
if (elf.SHN_LORESERVE <= sym.st_shndx and sym.st_shndx < elf.SHN_HIRESERVE) {
if (elf.SHN_LOPROC <= sym.st_shndx and sym.st_shndx < elf.SHN_HIPROC) {
try writer.print(" LO+{d}", .{sym.st_shndx - elf.SHN_LOPROC});
@@ -1300,6 +1257,46 @@ const ElfDumper = struct {
}
}
+ blk: {
+ const tt = sym.st_type();
+ const sym_type = switch (tt) {
+ elf.STT_NOTYPE => "NOTYPE",
+ elf.STT_OBJECT => "OBJECT",
+ elf.STT_FUNC => "FUNC",
+ elf.STT_SECTION => "SECTION",
+ elf.STT_FILE => "FILE",
+ elf.STT_COMMON => "COMMON",
+ elf.STT_TLS => "TLS",
+ elf.STT_NUM => "NUM",
+ elf.STT_GNU_IFUNC => "IFUNC",
+ else => if (elf.STT_LOPROC <= tt and tt < elf.STT_HIPROC) {
+ break :blk try writer.print(" LOPROC+{d}", .{tt - elf.STT_LOPROC});
+ } else if (elf.STT_LOOS <= tt and tt < elf.STT_HIOS) {
+ break :blk try writer.print(" LOOS+{d}", .{tt - elf.STT_LOOS});
+ } else "UNK",
+ };
+ try writer.print(" {s}", .{sym_type});
+ }
+
+ blk: {
+ const bind = sym.st_bind();
+ const sym_bind = switch (bind) {
+ elf.STB_LOCAL => "LOCAL",
+ elf.STB_GLOBAL => "GLOBAL",
+ elf.STB_WEAK => "WEAK",
+ elf.STB_NUM => "NUM",
+ else => if (elf.STB_LOPROC <= bind and bind < elf.STB_HIPROC) {
+ break :blk try writer.print(" LOPROC+{d}", .{bind - elf.STB_LOPROC});
+ } else if (elf.STB_LOOS <= bind and bind < elf.STB_HIOS) {
+ break :blk try writer.print(" LOOS+{d}", .{bind - elf.STB_LOOS});
+ } else "UNKNOWN",
+ };
+ try writer.print(" {s}", .{sym_bind});
+ }
+
+ const sym_vis = @as(elf.STV, @enumFromInt(sym.st_other));
+ try writer.print(" {s}", .{@tagName(sym_vis)});
+
const sym_name = switch (sym.st_type()) {
elf.STT_SECTION => getSectionName(ctx, sym.st_shndx),
else => symtab.getName(index).?,