mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 08:24:32 -08:00
[boot] Go back to loading symbol table in boot
The symbol table needs to be passed to the panic handler very early in the kernel, loading it in init is far less useful. Return it to the boot directory and remove it from the initrd.
This commit is contained in:
@@ -2,12 +2,13 @@
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <util/counted.h>
|
||||
#include <util/pointers.h>
|
||||
|
||||
namespace elf {
|
||||
|
||||
struct file_header;
|
||||
struct program_header;
|
||||
struct segment_header;
|
||||
struct section_header;
|
||||
|
||||
template <typename T>
|
||||
@@ -37,9 +38,8 @@ class file
|
||||
{
|
||||
public:
|
||||
/// Constructor: Create an elf object out of ELF data in memory
|
||||
/// \arg data The ELF data to read
|
||||
/// \arg size Size of the ELF data, in bytes
|
||||
file(const void *data, size_t size);
|
||||
/// \arg data A const_buffer pointing at the ELF data
|
||||
file(util::const_buffer data);
|
||||
|
||||
/// Check the validity of the ELF data
|
||||
/// \returns true for valid ELF data
|
||||
@@ -51,25 +51,24 @@ public:
|
||||
|
||||
/// Get the base address of the program in memory
|
||||
inline uintptr_t base() const {
|
||||
return reinterpret_cast<uintptr_t>(m_data);
|
||||
return reinterpret_cast<uintptr_t>(m_data.pointer);
|
||||
}
|
||||
|
||||
/// Get the ELF program headers
|
||||
inline const subheaders<program_header> & programs() const { return m_programs; }
|
||||
/// Get the ELF segment headers
|
||||
inline const subheaders<segment_header> & segments() const { return m_segments; }
|
||||
|
||||
/// Get the ELF section headers
|
||||
inline const subheaders<section_header> & sections() const { return m_sections; }
|
||||
|
||||
inline const file_header * header() const {
|
||||
return reinterpret_cast<const file_header *>(m_data);
|
||||
return reinterpret_cast<const file_header *>(m_data.pointer);
|
||||
}
|
||||
|
||||
private:
|
||||
subheaders<program_header> m_programs;
|
||||
subheaders<segment_header> m_segments;
|
||||
subheaders<section_header> m_sections;
|
||||
|
||||
const void *m_data;
|
||||
size_t m_size;
|
||||
util::const_buffer m_data;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ enum class segment_flags : uint32_t
|
||||
};
|
||||
is_bitfield(segment_flags);
|
||||
|
||||
struct program_header
|
||||
struct segment_header
|
||||
{
|
||||
segment_type type;
|
||||
segment_flags flags;
|
||||
|
||||
@@ -5,25 +5,24 @@ static const uint32_t expected_magic = 0x464c457f; // "\x7f" "ELF"
|
||||
|
||||
namespace elf {
|
||||
|
||||
inline const file_header * fh(const void *data) { return reinterpret_cast<const file_header*>(data); }
|
||||
inline const file_header * fh(util::const_buffer data) { return reinterpret_cast<const file_header*>(data.pointer); }
|
||||
|
||||
template <typename T>
|
||||
const T *convert(const void *data, size_t offset) {
|
||||
return reinterpret_cast<const T*>(util::offset_pointer(data, offset));
|
||||
const T *convert(util::const_buffer data, size_t offset) {
|
||||
return reinterpret_cast<const T*>(util::offset_pointer(data.pointer, offset));
|
||||
}
|
||||
|
||||
file::file(const void *data, size_t size) :
|
||||
m_programs(convert<program_header>(data, fh(data)->ph_offset), fh(data)->ph_entsize, fh(data)->ph_num),
|
||||
file::file(util::const_buffer data) :
|
||||
m_segments(convert<segment_header>(data, fh(data)->ph_offset), fh(data)->ph_entsize, fh(data)->ph_num),
|
||||
m_sections(convert<section_header>(data, fh(data)->sh_offset), fh(data)->sh_entsize, fh(data)->sh_num),
|
||||
m_data(data),
|
||||
m_size(size)
|
||||
m_data(data)
|
||||
{
|
||||
}
|
||||
|
||||
bool
|
||||
file::valid() const
|
||||
{
|
||||
if (m_size < sizeof(file_header))
|
||||
if (m_data.count < sizeof(file_header))
|
||||
return false;
|
||||
|
||||
const file_header *fheader = header();
|
||||
|
||||
Reference in New Issue
Block a user