1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-24 22:17:42 +00:00

ELF: Make code a little more buildable on other platforms

Patch from Anonymous.
This commit is contained in:
Andreas Kling 2019-09-27 13:29:05 +02:00
parent 0b59c0d0dc
commit 9c3c117f05
3 changed files with 7 additions and 2 deletions

View file

@ -98,7 +98,7 @@ bool ELFImage::parse()
{
// We only support i386.
if (header().e_machine != 3) {
kprintf("ELFImage::parse(): e_machine=%u not supported!\n");
kprintf("ELFImage::parse(): e_machine=%u not supported!\n", header().e_machine);
return false;
}

View file

@ -4,6 +4,7 @@
#include <AK/ELF/exec_elf.h>
#include <AK/HashMap.h>
#include <AK/OwnPtr.h>
#include <Kernel/VM/VirtualAddress.h>
class ELFImage {
public:

View file

@ -36,8 +36,10 @@ bool ELFLoader::layout()
bool failed = false;
m_image.for_each_program_header([&](const ELFImage::ProgramHeader& program_header) {
if (program_header.type() == PT_TLS) {
#ifdef KERNEL
auto* tls_image = tls_section_hook(program_header.size_in_memory(), program_header.alignment());
memcpy(tls_image, program_header.raw_data(), program_header.size_in_image());
#endif
return;
}
if (program_header.type() != PT_LOAD)
@ -45,6 +47,7 @@ bool ELFLoader::layout()
#ifdef ELFLOADER_DEBUG
kprintf("PH: V%p %u r:%u w:%u\n", program_header.vaddr().get(), program_header.size_in_memory(), program_header.is_readable(), program_header.is_writable());
#endif
#ifdef KERNEL
if (program_header.is_writable()) {
alloc_section_hook(
program_header.vaddr(),
@ -65,6 +68,7 @@ bool ELFLoader::layout()
program_header.is_executable(),
String::format("elf-map-%s%s%s", program_header.is_readable() ? "r" : "", program_header.is_writable() ? "w" : "", program_header.is_executable() ? "x" : ""));
}
#endif
});
return !failed;
}
@ -78,7 +82,7 @@ char* ELFLoader::symbol_ptr(const char* name)
if (strcmp(symbol.name(), name))
return IterationDecision::Continue;
if (m_image.is_executable())
found_ptr = (char*)symbol.value();
found_ptr = (char*)(size_t)symbol.value();
else
ASSERT_NOT_REACHED();
return IterationDecision::Break;