* [PATCH master] sandbox: lds: fix relocation in read-only section warning
@ 2024-10-14 11:35 Ahmad Fatoum
2024-10-15 6:55 ` Sascha Hauer
0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2024-10-14 11:35 UTC (permalink / raw)
To: barebox; +Cc: Abdelrahman Youssef, Ahmad Fatoum
To address an "ELF has a LOAD segment with RWX permissions" warning
during the sandbox build, the RO_DATA_SECTION was marked READONLY.
At least with Debian GCC 12.2.0-14, this just brought us a different
warning:
/usr/bin/ld: common/memory.o: warning: relocation in read-only section `.initcall.9'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
This is understandable: If an initcall is emitted with a relocation,
marking its section as read-only is inconsistent.
Taking a step back, the actual problem is that we need to tell GCC that
our RO_DATA_SECTION is not executable. Therefore, let's insert it before
.data (which is rw^x) instead of .rodata, which is (rx).
Fixes: c11590f5643b ("sandbox: lds: fix "ELF has a LOAD segment with RWX permissions" warning")
Reported-by: Abdelrahman Youssef <abdelrahmanyossef12@gmail.com>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
arch/sandbox/board/barebox.lds.S | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/sandbox/board/barebox.lds.S b/arch/sandbox/board/barebox.lds.S
index de8552dba0ac..0102b9333174 100644
--- a/arch/sandbox/board/barebox.lds.S
+++ b/arch/sandbox/board/barebox.lds.S
@@ -5,9 +5,9 @@
SECTIONS
{
. = ALIGN(64);
- .barebox_rodata (READONLY) : {
+ .barebox_rodata () : {
RO_DATA_SECTION
}
}
-INSERT BEFORE .rodata;
+INSERT BEFORE .data;
--
2.39.5
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH master] sandbox: lds: fix relocation in read-only section warning
2024-10-14 11:35 [PATCH master] sandbox: lds: fix relocation in read-only section warning Ahmad Fatoum
@ 2024-10-15 6:55 ` Sascha Hauer
0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2024-10-15 6:55 UTC (permalink / raw)
To: barebox, Ahmad Fatoum; +Cc: Abdelrahman Youssef
On Mon, 14 Oct 2024 13:35:40 +0200, Ahmad Fatoum wrote:
> To address an "ELF has a LOAD segment with RWX permissions" warning
> during the sandbox build, the RO_DATA_SECTION was marked READONLY.
>
> At least with Debian GCC 12.2.0-14, this just brought us a different
> warning:
>
> /usr/bin/ld: common/memory.o: warning: relocation in read-only section `.initcall.9'
> /usr/bin/ld: warning: creating DT_TEXTREL in a PIE
>
> [...]
Applied, thanks!
[1/1] sandbox: lds: fix relocation in read-only section warning
https://git.pengutronix.de/cgit/barebox/commit/?id=9833da898934 (link may not be stable)
Best regards,
--
Sascha Hauer <s.hauer@pengutronix.de>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-10-15 6:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-14 11:35 [PATCH master] sandbox: lds: fix relocation in read-only section warning Ahmad Fatoum
2024-10-15 6:55 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox