1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 15:48:12 +00:00

LibELF: Remove sketchy use of "undefined" ELF::Image::Section

We were using ELF::Image::section(0) to indicate the "undefined"
section, when what we really wanted was just Optional<Section>.

So let's use Optional instead. :^)
This commit is contained in:
Andreas Kling 2021-05-15 00:13:44 +02:00
parent f70d0f03de
commit 16221305ad
6 changed files with 18 additions and 19 deletions

View file

@ -65,7 +65,9 @@ KResultOr<int> Process::sys$module_load(Userspace<const char*> user_path, size_t
return IterationDecision::Continue;
auto* section_storage = section_storage_by_name.get(section.name()).value_or(nullptr);
VERIFY(section_storage);
section.relocations().for_each_relocation([&](const ELF::Image::Relocation& relocation) {
auto relocations = section.relocations();
VERIFY(relocations.has_value());
relocations->for_each_relocation([&](const ELF::Image::Relocation& relocation) {
auto& patch_ptr = *reinterpret_cast<ptrdiff_t*>(section_storage + relocation.offset());
switch (relocation.type()) {
case R_386_PC32: {