mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 07:27:45 +00:00
LibELF: Refactor how arch-specific dynamic relocation types are handled
We currently expect that the relocation type numbers are unique across all architectures. But RISC-V and x86_64 use the same numbers for different relocation types (R_X86_64_COPY = R_RISCV_JUMP_SLOT = 5). So create a generic reloc type enum which maps to the arch-specific reloc types instead of checking for all arch reloc types individually everywhere.
This commit is contained in:
parent
c216e7439f
commit
f8628f94b8
6 changed files with 98 additions and 23 deletions
|
@ -13,6 +13,7 @@
|
|||
#include <AK/Concepts.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <Kernel/Memory/VirtualAddress.h>
|
||||
#include <LibELF/Arch/GenericDynamicRelocationType.h>
|
||||
#include <LibELF/ELFABI.h>
|
||||
#include <link.h>
|
||||
|
||||
|
@ -402,7 +403,7 @@ inline void DynamicObject::RelocationSection::for_each_relocation(F func) const
|
|||
{
|
||||
for (unsigned i = 0; i < relocation_count(); ++i) {
|
||||
auto const reloc = relocation(i);
|
||||
if (reloc.type() == 0)
|
||||
if (static_cast<GenericDynamicRelocationType>(reloc.type()) == GenericDynamicRelocationType::NONE)
|
||||
continue;
|
||||
if (func(reloc) == IterationDecision::Break)
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue