From fe35e34add716702819cada50ea40bff531570ab Mon Sep 17 00:00:00 2001 From: ghidra1 Date: Tue, 13 Jan 2026 17:15:52 -0500 Subject: [PATCH] GP-6329 Corrected PowerPC-32 ELF Relocation processing for R_PPC_ADDR16_LO and R_PPC_ADDR16_HA --- .../elf/relocation/PowerPC_ElfRelocationHandler.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Ghidra/Processors/PowerPC/src/main/java/ghidra/app/util/bin/format/elf/relocation/PowerPC_ElfRelocationHandler.java b/Ghidra/Processors/PowerPC/src/main/java/ghidra/app/util/bin/format/elf/relocation/PowerPC_ElfRelocationHandler.java index 639340c175..97545dca3c 100644 --- a/Ghidra/Processors/PowerPC/src/main/java/ghidra/app/util/bin/format/elf/relocation/PowerPC_ElfRelocationHandler.java +++ b/Ghidra/Processors/PowerPC/src/main/java/ghidra/app/util/bin/format/elf/relocation/PowerPC_ElfRelocationHandler.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -138,7 +138,8 @@ public class PowerPC_ElfRelocationHandler extends byteLength = 2; break; case R_PPC_ADDR16_LO: - if (Long.compareUnsigned(symbolValue, relocbase) > 0 && + if (sym.isSection() && sym.getValue() != 0 && + Long.compareUnsigned(symbolValue, relocbase) > 0 && Long.compareUnsigned(symbolValue, relocbase + addend) <= 0) { /** * (freebsd) Addend values are sometimes relative to sections in rela, @@ -156,7 +157,8 @@ public class PowerPC_ElfRelocationHandler extends byteLength = 2; break; case R_PPC_ADDR16_HA: - if (Long.compareUnsigned(symbolValue, relocbase) > 0 && + if (sym.isSection() && sym.getValue() != 0 && + Long.compareUnsigned(symbolValue, relocbase) > 0 && Long.compareUnsigned(symbolValue, relocbase + addend) <= 0) { /** * (freebsd) Addend values are sometimes relative to sections in rela,