From: Ahmad Fatoum <a.fatoum@barebox.org>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@barebox.org>
Subject: [PATCH 1/2] ARM: cpu: common: skip R_ARM_NONE relocations
Date: Tue, 6 Jan 2026 09:16:56 +0100 [thread overview]
Message-ID: <20260106081659.3491945-1-a.fatoum@barebox.org> (raw)
Relocations may be turned into no-op in place by strip running on an
executable by having their type set to 0 (R_ARM_NONE).
This can happen with the incoming ELF loading in PBL support, so teach
relocate_to_current_adr() to skip these no-op relocation entries.
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
arch/arm/cpu/common.c | 30 +++++++++++++++++++++---------
1 file changed, 21 insertions(+), 9 deletions(-)
diff --git a/arch/arm/cpu/common.c b/arch/arm/cpu/common.c
index 339ef2db2534..5b65b0745b98 100644
--- a/arch/arm/cpu/common.c
+++ b/arch/arm/cpu/common.c
@@ -36,6 +36,7 @@ void sync_caches_for_execution(void)
arm_early_mmu_cache_flush();
}
+#define R_ARM_NONE 0
#define R_ARM_RELATIVE 23
#define R_AARCH64_RELATIVE 1027
@@ -78,14 +79,19 @@ void __prereloc relocate_to_current_adr(void)
#if defined(CONFIG_CPU_64)
while (dstart < dend) {
struct elf64_rela *rel = dstart;
+ unsigned long *fixup;
- if (ELF64_R_TYPE(rel->r_info) == R_AARCH64_RELATIVE) {
- unsigned long *fixup = (unsigned long *)(rel->r_offset + offset);
+ switch(ELF64_R_TYPE(rel->r_info)) {
+ case R_AARCH64_RELATIVE:
+ fixup = (unsigned long *)(rel->r_offset + offset);
*fixup = rel->r_addend + offset;
rel->r_addend += offset;
rel->r_offset += offset;
- } else {
+ break;
+ case R_ARM_NONE:
+ break;
+ default:
putc_ll('>');
puthex_ll(rel->r_info);
putc_ll(' ');
@@ -104,20 +110,26 @@ void __prereloc relocate_to_current_adr(void)
while (dstart < dend) {
struct elf32_rel *rel = dstart;
+ unsigned long r, *fixup;
- if (ELF32_R_TYPE(rel->r_info) == R_ARM_RELATIVE) {
- unsigned long *fixup = (unsigned long *)(rel->r_offset + offset);
+ switch (ELF32_R_TYPE(rel->r_info)) {
+ case R_ARM_RELATIVE:
+ fixup = (unsigned long *)(rel->r_offset + offset);
*fixup = *fixup + offset;
rel->r_offset += offset;
- } else if (ELF32_R_TYPE(rel->r_info) == R_ARM_ABS32) {
- unsigned long r = dynsym[ELF32_R_SYM(rel->r_info) * 4 + 1];
- unsigned long *fixup = (unsigned long *)(rel->r_offset + offset);
+ break;
+ case R_ARM_ABS32:
+ r = dynsym[ELF32_R_SYM(rel->r_info) * 4 + 1];
+ fixup = (unsigned long *)(rel->r_offset + offset);
*fixup = *fixup + r + offset;
rel->r_offset += offset;
- } else {
+ break;
+ case R_ARM_NONE:
+ break;
+ default:
putc_ll('>');
puthex_ll(rel->r_info);
putc_ll(' ');
--
2.47.3
next reply other threads:[~2026-01-06 8:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-06 8:16 Ahmad Fatoum [this message]
2026-01-06 8:16 ` [PATCH 2/2] ARM: cpu: common: define generic relocate_image Ahmad Fatoum
2026-01-06 9:16 ` Sascha Hauer
2026-01-06 11:43 ` Ahmad Fatoum
2026-01-06 13:18 ` [PATCH 1/2] ARM: cpu: common: skip R_ARM_NONE relocations Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260106081659.3491945-1-a.fatoum@barebox.org \
--to=a.fatoum@barebox.org \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox