mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:27:45 +00:00
LibELF+Utilities: Avoid truncating 64-bit values
This fixes displaying 64-bit addresses in readelf and also fixes showing backtraces from core dumps on x86_64.
This commit is contained in:
parent
36c3927169
commit
db1c5c4830
6 changed files with 37 additions and 36 deletions
|
@ -51,8 +51,8 @@ public:
|
|||
|
||||
StringView name() const { return m_image.table_string(m_sym.st_name); }
|
||||
unsigned section_index() const { return m_sym.st_shndx; }
|
||||
unsigned value() const { return m_sym.st_value; }
|
||||
unsigned size() const { return m_sym.st_size; }
|
||||
FlatPtr value() const { return m_sym.st_value; }
|
||||
size_t size() const { return m_sym.st_size; }
|
||||
unsigned index() const { return m_index; }
|
||||
#if ARCH(I386)
|
||||
unsigned type() const
|
||||
|
@ -93,11 +93,11 @@ public:
|
|||
unsigned index() const { return m_program_header_index; }
|
||||
u32 type() const { return m_program_header.p_type; }
|
||||
u32 flags() const { return m_program_header.p_flags; }
|
||||
u32 offset() const { return m_program_header.p_offset; }
|
||||
size_t offset() const { return m_program_header.p_offset; }
|
||||
VirtualAddress vaddr() const { return VirtualAddress(m_program_header.p_vaddr); }
|
||||
u32 size_in_memory() const { return m_program_header.p_memsz; }
|
||||
u32 size_in_image() const { return m_program_header.p_filesz; }
|
||||
u32 alignment() const { return m_program_header.p_align; }
|
||||
size_t size_in_memory() const { return m_program_header.p_memsz; }
|
||||
size_t size_in_image() const { return m_program_header.p_filesz; }
|
||||
size_t alignment() const { return m_program_header.p_align; }
|
||||
bool is_readable() const { return flags() & PF_R; }
|
||||
bool is_writable() const { return flags() & PF_W; }
|
||||
bool is_executable() const { return flags() & PF_X; }
|
||||
|
@ -121,16 +121,16 @@ public:
|
|||
~Section() { }
|
||||
|
||||
StringView name() const { return m_image.section_header_table_string(m_section_header.sh_name); }
|
||||
unsigned type() const { return m_section_header.sh_type; }
|
||||
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 !entry_size() ? 0 : size() / entry_size(); }
|
||||
u32 address() const { return m_section_header.sh_addr; }
|
||||
u32 type() const { return m_section_header.sh_type; }
|
||||
size_t offset() const { return m_section_header.sh_offset; }
|
||||
size_t size() const { return m_section_header.sh_size; }
|
||||
size_t entry_size() const { return m_section_header.sh_entsize; }
|
||||
size_t entry_count() const { return !entry_size() ? 0 : size() / entry_size(); }
|
||||
FlatPtr address() const { return m_section_header.sh_addr; }
|
||||
const char* raw_data() const { return m_image.raw_data(m_section_header.sh_offset); }
|
||||
ReadonlyBytes bytes() const { return { raw_data(), size() }; }
|
||||
Optional<RelocationSection> relocations() const;
|
||||
u32 flags() const { return m_section_header.sh_flags; }
|
||||
auto flags() const { return m_section_header.sh_flags; }
|
||||
bool is_writable() const { return flags() & SHF_WRITE; }
|
||||
bool is_executable() const { return flags() & PF_X; }
|
||||
|
||||
|
@ -147,7 +147,7 @@ public:
|
|||
: Section(section.m_image, section.m_section_index)
|
||||
{
|
||||
}
|
||||
unsigned relocation_count() const { return entry_count(); }
|
||||
size_t relocation_count() const { return entry_count(); }
|
||||
Relocation relocation(unsigned index) const;
|
||||
|
||||
template<VoidFunction<Image::Relocation&> F>
|
||||
|
@ -164,7 +164,7 @@ public:
|
|||
|
||||
~Relocation() { }
|
||||
|
||||
unsigned offset() const { return m_rel.r_offset; }
|
||||
size_t offset() const { return m_rel.r_offset; }
|
||||
#if ARCH(I386)
|
||||
unsigned type() const
|
||||
{
|
||||
|
@ -230,9 +230,9 @@ public:
|
|||
bool has_symbols() const { return symbol_count(); }
|
||||
#ifndef KERNEL
|
||||
Optional<Symbol> find_demangled_function(const StringView& name) const;
|
||||
String symbolicate(u32 address, u32* offset = nullptr) const;
|
||||
String symbolicate(FlatPtr address, u32* offset = nullptr) const;
|
||||
#endif
|
||||
Optional<Image::Symbol> find_symbol(u32 address, u32* offset = nullptr) const;
|
||||
Optional<Image::Symbol> find_symbol(FlatPtr address, u32* offset = nullptr) const;
|
||||
|
||||
private:
|
||||
const char* raw_data(unsigned offset) const;
|
||||
|
@ -252,7 +252,7 @@ private:
|
|||
unsigned m_string_table_section_index { 0 };
|
||||
|
||||
struct SortedSymbol {
|
||||
u32 address;
|
||||
FlatPtr address;
|
||||
StringView name;
|
||||
String demangled_name;
|
||||
Optional<Image::Symbol> symbol;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue