Skip to content

Commit 316fb62

Browse files
committed
Kernel: Fail a bit more gracefully when we don't have userspace symbols.
1 parent a4e48dc commit 316fb62

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

Kernel/ELF/ELFImage.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class ELFImage {
8686
unsigned offset() const { return m_section_header.sh_offset; }
8787
unsigned size() const { return m_section_header.sh_size; }
8888
unsigned entry_size() const { return m_section_header.sh_entsize; }
89-
unsigned entry_count() const { return size() / entry_size(); }
89+
unsigned entry_count() const { return !entry_size() ? 0 : size() / entry_size(); }
9090
dword address() const { return m_section_header.sh_addr; }
9191
const char* raw_data() const { return m_image.raw_data(m_section_header.sh_offset); }
9292
bool is_undefined() const { return m_section_index == SHN_UNDEF; }

Kernel/ELF/ELFLoader.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ class ELFLoader {
1818
char* symbol_ptr(const char* name);
1919
LinearAddress entry() const { return m_image.entry(); }
2020

21+
bool has_symbols() const { return m_image.symbol_count(); }
22+
2123
String symbolicate(dword address) const;
2224

2325
private:

Kernel/KSyms.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,10 @@ static void load_ksyms_from_data(const ByteBuffer& buffer)
115115
if (!symbol.address)
116116
break;
117117
if (!symbol.ksym) {
118-
if (current->process().elf_loader()) {
118+
if (current->process().elf_loader() && current->process().elf_loader()->has_symbols()) {
119119
dbgprintf("%p %s\n", symbol.address, current->process().elf_loader()->symbolicate(symbol.address).characters());
120120
} else {
121-
dbgprintf("%p (no ELF loader for process)\n", symbol.address);
121+
dbgprintf("%p (no ELF symbols for process)\n", symbol.address);
122122
}
123123
continue;
124124
}

0 commit comments

Comments
 (0)