diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2023-07-20 20:00:44 +0200 |
|---|---|---|
| committer | Jakub Konka <kubkon@jakubkonka.com> | 2023-07-20 20:01:06 +0200 |
| commit | 245f6553e6840b2221141f3e7724ae6a73294387 (patch) | |
| tree | cc5412a93c1e428d10e018217c145a01b9b64faa /lib/std/Build/Step/CheckObject.zig | |
| parent | 3b6200db41f201839a7238c95ddc2e1323d8acbd (diff) | |
| download | zig-245f6553e6840b2221141f3e7724ae6a73294387.tar.gz zig-245f6553e6840b2221141f3e7724ae6a73294387.zip | |
check-object: format known OS-specific types before doing generic format
Diffstat (limited to 'lib/std/Build/Step/CheckObject.zig')
| -rw-r--r-- | lib/std/Build/Step/CheckObject.zig | 83 |
1 files changed, 40 insertions, 43 deletions
diff --git a/lib/std/Build/Step/CheckObject.zig b/lib/std/Build/Step/CheckObject.zig index 6466708080..3fe84658a2 100644 --- 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).?, |
