Skip to content

Commit 8d4bd5e

Browse files
committed
Match latest readelf output in ElfPrinter
1 parent 78f9142 commit 8d4bd5e

1 file changed

Lines changed: 18 additions & 11 deletions

File tree

src/LibObjectFile/Elf/ElfPrinter.cs

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,14 @@ public static void PrintElfHeader(ElfObjectFile elf, TextWriter writer)
6868
writer.WriteLine($" Size of program headers: {elf.Layout.SizeOfProgramHeaderEntry} (bytes)");
6969
writer.WriteLine($" Number of program headers: {elf.Segments.Count}");
7070
writer.WriteLine($" Size of section headers: {elf.Layout.SizeOfSectionHeaderEntry} (bytes)");
71-
writer.WriteLine($" Number of section headers: {elf.VisibleSectionCount}");
71+
if (elf.VisibleSectionCount >= ElfNative.SHN_LORESERVE || elf.VisibleSectionCount == 0)
72+
{
73+
writer.WriteLine($" Number of section headers: 0 ({elf.VisibleSectionCount})");
74+
}
75+
else
76+
{
77+
writer.WriteLine($" Number of section headers: {elf.VisibleSectionCount}");
78+
}
7279
writer.WriteLine($" Section header string table index: {elf.SectionHeaderStringTable?.SectionIndex ?? 0}");
7380
}
7481

@@ -97,21 +104,14 @@ public static void PrintSectionHeaders(ElfObjectFile elf, TextWriter writer)
97104
W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
98105
L (link order), O (extra OS processing required), G (group), T (TLS),
99106
C (compressed), x (unknown), o (OS specific), E (exclude),
100-
l (large), p (processor specific)");
107+
D (mbind), l (large), p (processor specific)");
101108
}
102109

103110
public static void PrintSectionGroups(ElfObjectFile elf, TextWriter writer)
104111
{
105112
if (elf == null) throw new ArgumentNullException(nameof(elf));
106113
if (writer == null) throw new ArgumentNullException(nameof(writer));
107114

108-
if (elf.Sections.Count == 0)
109-
{
110-
writer.WriteLine();
111-
writer.WriteLine("There are no sections to group in this file.");
112-
return;
113-
}
114-
115115
writer.WriteLine();
116116
writer.WriteLine("There are no section groups in this file.");
117117
// TODO
@@ -252,8 +252,15 @@ public static void PrintUnwind(ElfObjectFile elf, TextWriter writer)
252252
if (elf == null) throw new ArgumentNullException(nameof(elf));
253253
if (writer == null) throw new ArgumentNullException(nameof(writer));
254254

255-
writer.WriteLine();
256-
writer.WriteLine($"The decoding of unwind sections for machine type {GetElfArch(elf.Arch)} is not currently supported.");
255+
if (elf.Arch == ElfArchEx.I386 || elf.Arch == ElfArchEx.X86_64)
256+
{
257+
writer.WriteLine("No processor specific unwind information to decode");
258+
}
259+
else
260+
{
261+
writer.WriteLine();
262+
writer.WriteLine($"The decoding of unwind sections for machine type {GetElfArch(elf.Arch)} is not currently supported.");
263+
}
257264
}
258265

259266

0 commit comments

Comments
 (0)