summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-05-18 14:48:53 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-05-18 14:49:49 +0200
commit316fb624f795b0cd787b12ca469c2b659670200a (patch)
tree4bc4fcd9ad49de14aa1069e7c9ce5b7739663d71 /Kernel
parenta4e48dce77ba883c7260a7579f3ec53ba989b1f4 (diff)
downloadserenity-316fb624f795b0cd787b12ca469c2b659670200a.zip
Kernel: Fail a bit more gracefully when we don't have userspace symbols.
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/ELF/ELFImage.h2
-rw-r--r--Kernel/ELF/ELFLoader.h2
-rw-r--r--Kernel/KSyms.cpp4
3 files changed, 5 insertions, 3 deletions
diff --git a/Kernel/ELF/ELFImage.h b/Kernel/ELF/ELFImage.h
index 4574f4d0fd..09c18bef0a 100644
--- a/Kernel/ELF/ELFImage.h
+++ b/Kernel/ELF/ELFImage.h
@@ -86,7 +86,7 @@ public:
unsigned offset() const { return m_section_header.sh_offset; }
unsigned size() const { return m_section_header.sh_size; }
unsigned entry_size() const { return m_section_header.sh_entsize; }
- unsigned entry_count() const { return size() / entry_size(); }
+ unsigned entry_count() const { return !entry_size() ? 0 : size() / entry_size(); }
dword address() const { return m_section_header.sh_addr; }
const char* raw_data() const { return m_image.raw_data(m_section_header.sh_offset); }
bool is_undefined() const { return m_section_index == SHN_UNDEF; }
diff --git a/Kernel/ELF/ELFLoader.h b/Kernel/ELF/ELFLoader.h
index 957185b76e..972783a4d1 100644
--- a/Kernel/ELF/ELFLoader.h
+++ b/Kernel/ELF/ELFLoader.h
@@ -18,6 +18,8 @@ public:
char* symbol_ptr(const char* name);
LinearAddress entry() const { return m_image.entry(); }
+ bool has_symbols() const { return m_image.symbol_count(); }
+
String symbolicate(dword address) const;
private:
diff --git a/Kernel/KSyms.cpp b/Kernel/KSyms.cpp
index 1dc7830a3b..38719cd1bb 100644
--- a/Kernel/KSyms.cpp
+++ b/Kernel/KSyms.cpp
@@ -115,10 +115,10 @@ static void load_ksyms_from_data(const ByteBuffer& buffer)
if (!symbol.address)
break;
if (!symbol.ksym) {
- if (current->process().elf_loader()) {
+ if (current->process().elf_loader() && current->process().elf_loader()->has_symbols()) {
dbgprintf("%p %s\n", symbol.address, current->process().elf_loader()->symbolicate(symbol.address).characters());
} else {
- dbgprintf("%p (no ELF loader for process)\n", symbol.address);
+ dbgprintf("%p (no ELF symbols for process)\n", symbol.address);
}
continue;
}