mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 08:18:12 +00:00
Everywhere: Replace ElfW(type)
macro usage with Elf_type
This works around a `clang-format-17` bug which caused certain usages to be misformatted and fail to compile. Fixes #8315
This commit is contained in:
parent
2151e6c8b4
commit
45d81dceed
20 changed files with 129 additions and 127 deletions
|
@ -21,7 +21,7 @@ namespace ELF {
|
|||
class DynamicObject : public RefCounted<DynamicObject> {
|
||||
public:
|
||||
static NonnullRefPtr<DynamicObject> create(DeprecatedString const& filepath, VirtualAddress base_address, VirtualAddress dynamic_section_address);
|
||||
static char const* name_for_dtag(ElfW(Sword) d_tag);
|
||||
static char const* name_for_dtag(Elf_Sword d_tag);
|
||||
|
||||
~DynamicObject();
|
||||
void dump() const;
|
||||
|
@ -35,24 +35,24 @@ public:
|
|||
|
||||
class DynamicEntry {
|
||||
public:
|
||||
explicit DynamicEntry(const ElfW(Dyn) & dyn)
|
||||
explicit DynamicEntry(Elf_Dyn const& dyn)
|
||||
: m_dyn(dyn)
|
||||
{
|
||||
}
|
||||
|
||||
~DynamicEntry() = default;
|
||||
|
||||
ElfW(Sword) tag() const { return m_dyn.d_tag; }
|
||||
ElfW(Addr) ptr() const { return m_dyn.d_un.d_ptr; }
|
||||
ElfW(Word) val() const { return m_dyn.d_un.d_val; }
|
||||
Elf_Sword tag() const { return m_dyn.d_tag; }
|
||||
Elf_Addr ptr() const { return m_dyn.d_un.d_ptr; }
|
||||
Elf_Word val() const { return m_dyn.d_un.d_val; }
|
||||
|
||||
private:
|
||||
const ElfW(Dyn) & m_dyn;
|
||||
Elf_Dyn const& m_dyn;
|
||||
};
|
||||
|
||||
class Symbol {
|
||||
public:
|
||||
Symbol(DynamicObject const& dynamic, unsigned index, const ElfW(Sym) & sym)
|
||||
Symbol(DynamicObject const& dynamic, unsigned index, Elf_Sym const& sym)
|
||||
: m_dynamic(dynamic)
|
||||
, m_sym(sym)
|
||||
, m_index(index)
|
||||
|
@ -92,7 +92,7 @@ public:
|
|||
|
||||
private:
|
||||
DynamicObject const& m_dynamic;
|
||||
const ElfW(Sym) & m_sym;
|
||||
Elf_Sym const& m_sym;
|
||||
unsigned const m_index;
|
||||
};
|
||||
|
||||
|
@ -153,7 +153,7 @@ public:
|
|||
|
||||
class Relocation {
|
||||
public:
|
||||
Relocation(DynamicObject const& dynamic, const ElfW(Rela) & rel, unsigned offset_in_section, bool addend_used)
|
||||
Relocation(DynamicObject const& dynamic, Elf_Rela const& rel, unsigned offset_in_section, bool addend_used)
|
||||
: m_dynamic(dynamic)
|
||||
, m_rel(rel)
|
||||
, m_offset_in_section(offset_in_section)
|
||||
|
@ -191,7 +191,7 @@ public:
|
|||
|
||||
private:
|
||||
DynamicObject const& m_dynamic;
|
||||
const ElfW(Rela) & m_rel;
|
||||
Elf_Rela const& m_rel;
|
||||
unsigned const m_offset_in_section;
|
||||
bool const m_addend_used;
|
||||
};
|
||||
|
@ -246,7 +246,7 @@ public:
|
|||
|
||||
typedef void (*InitializationFunction)();
|
||||
typedef void (*FinalizationFunction)();
|
||||
typedef ElfW(Addr) (*IfuncResolver)();
|
||||
typedef Elf_Addr (*IfuncResolver)();
|
||||
|
||||
bool has_init_section() const { return m_init_offset != 0; }
|
||||
bool has_init_array_section() const { return m_init_array_offset != 0; }
|
||||
|
@ -295,8 +295,8 @@ public:
|
|||
void set_tls_offset(FlatPtr offset) { m_tls_offset = offset; }
|
||||
void set_tls_size(FlatPtr size) { m_tls_size = size; }
|
||||
|
||||
ElfW(Half) program_header_count() const;
|
||||
const ElfW(Phdr) * program_headers() const;
|
||||
Elf_Half program_header_count() const;
|
||||
Elf_Phdr const* program_headers() const;
|
||||
|
||||
template<VoidFunction<StringView> F>
|
||||
void for_each_needed_library(F) const;
|
||||
|
@ -334,8 +334,8 @@ public:
|
|||
private:
|
||||
explicit DynamicObject(DeprecatedString const& filepath, VirtualAddress base_address, VirtualAddress dynamic_section_address);
|
||||
|
||||
StringView symbol_string_table_string(ElfW(Word)) const;
|
||||
char const* raw_symbol_string_table_string(ElfW(Word)) const;
|
||||
StringView symbol_string_table_string(Elf_Word) const;
|
||||
char const* raw_symbol_string_table_string(Elf_Word) const;
|
||||
void parse();
|
||||
|
||||
DeprecatedString m_filepath;
|
||||
|
@ -363,7 +363,7 @@ private:
|
|||
FlatPtr m_symbol_table_offset { 0 };
|
||||
size_t m_size_of_symbol_table_entry { 0 };
|
||||
|
||||
ElfW(Sword) m_procedure_linkage_table_relocation_type { -1 };
|
||||
Elf_Sword m_procedure_linkage_table_relocation_type { -1 };
|
||||
FlatPtr m_plt_relocation_offset_location { 0 }; // offset of PLT relocations, at end of relocations
|
||||
size_t m_size_of_plt_relocation_entry_list { 0 };
|
||||
Optional<FlatPtr> m_procedure_linkage_table_offset;
|
||||
|
@ -383,14 +383,14 @@ private:
|
|||
bool m_is_pie { false };
|
||||
|
||||
// DT_FLAGS
|
||||
ElfW(Word) m_dt_flags { 0 };
|
||||
Elf_Word m_dt_flags { 0 };
|
||||
|
||||
bool m_has_soname { false };
|
||||
ElfW(Word) m_soname_index { 0 }; // Index into dynstr table for SONAME
|
||||
Elf_Word m_soname_index { 0 }; // Index into dynstr table for SONAME
|
||||
bool m_has_rpath { false };
|
||||
ElfW(Word) m_rpath_index { 0 }; // Index into dynstr table for RPATH
|
||||
Elf_Word m_rpath_index { 0 }; // Index into dynstr table for RPATH
|
||||
bool m_has_runpath { false };
|
||||
ElfW(Word) m_runpath_index { 0 }; // Index into dynstr table for RUNPATH
|
||||
Elf_Word m_runpath_index { 0 }; // Index into dynstr table for RUNPATH
|
||||
|
||||
Optional<FlatPtr> m_tls_offset;
|
||||
Optional<FlatPtr> m_tls_size;
|
||||
|
@ -428,7 +428,7 @@ inline void DynamicObject::for_each_relr_relocation(F f) const
|
|||
VERIFY(section.entry_size() == sizeof(FlatPtr));
|
||||
VERIFY(section.size() >= section.entry_size() * section.entry_count());
|
||||
|
||||
auto* entries = reinterpret_cast<ElfW(Relr)*>(section.address().get());
|
||||
auto* entries = reinterpret_cast<Elf_Relr*>(section.address().get());
|
||||
auto base = base_address().get();
|
||||
FlatPtr patch_addr = 0;
|
||||
for (unsigned i = 0; i < section.entry_count(); ++i) {
|
||||
|
@ -458,7 +458,7 @@ inline void DynamicObject::for_each_symbol(F func) const
|
|||
template<IteratorFunction<DynamicObject::DynamicEntry&> F>
|
||||
inline void DynamicObject::for_each_dynamic_entry(F func) const
|
||||
{
|
||||
auto* dyns = reinterpret_cast<const ElfW(Dyn)*>(m_dynamic_address.as_ptr());
|
||||
auto* dyns = reinterpret_cast<Elf_Dyn const*>(m_dynamic_address.as_ptr());
|
||||
for (unsigned i = 0;; ++i) {
|
||||
auto&& dyn = DynamicEntry(dyns[i]);
|
||||
if (dyn.tag() == DT_NULL)
|
||||
|
@ -483,7 +483,7 @@ inline void DynamicObject::for_each_needed_library(F func) const
|
|||
for_each_dynamic_entry([func, this](auto entry) {
|
||||
if (entry.tag() != DT_NEEDED)
|
||||
return;
|
||||
ElfW(Word) offset = entry.val();
|
||||
Elf_Word offset = entry.val();
|
||||
func(symbol_string_table_string(offset));
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue