diff mbox series

Makefile: Link final elf with --no-warn-rwx-segments

Message ID 20230719050758.161974-1-joel@jms.id.au
State Accepted
Headers show
Series Makefile: Link final elf with --no-warn-rwx-segments | expand

Commit Message

Joel Stanley July 19, 2023, 5:07 a.m. UTC
No system loads skiboot as an ELF, so the segment information is not
used.

Avoids these warnings with binutils as of 2.39:

 powerpc64-linux-gnu-ld: warning: skiboot.tmp.elf has a LOAD segment with RWX permissions
 powerpc64-linux-gnu-ld: warning: skiboot.elf has a LOAD segment with RWX permissions

Signed-off-by: Joel Stanley <joel@jms.id.au>
---
 Makefile.main | 1 +
 1 file changed, 1 insertion(+)

Comments

Reza Arbab Aug. 9, 2023, 9:38 p.m. UTC | #1
On Wed, Jul 19, 2023 at 02:37:58PM +0930, Joel Stanley wrote:
>No system loads skiboot as an ELF, so the segment information is not
>used.
>
>Avoids these warnings with binutils as of 2.39:
>
> powerpc64-linux-gnu-ld: warning: skiboot.tmp.elf has a LOAD segment with RWX permissions
> powerpc64-linux-gnu-ld: warning: skiboot.elf has a LOAD segment with RWX permissions
>
>Signed-off-by: Joel Stanley <joel@jms.id.au>
>---
> Makefile.main | 1 +
> 1 file changed, 1 insertion(+)
>
>diff --git a/Makefile.main b/Makefile.main
>index bfa24f61342f..934d4c2aa133 100644
>--- a/Makefile.main
>+++ b/Makefile.main
>@@ -190,6 +190,7 @@ LDFLAGS += -Wl,--oformat,elf64-powerpc
> LDFLAGS_FINAL = -m elf64lppc --no-multi-toc -N --build-id=none --whole-archive
> LDFLAGS_FINAL += -static -nostdlib -pie -Ttext-segment=$(LD_TEXT) --oformat=elf64-powerpc
> LDFLAGS_FINAL += --orphan-handling=warn
>+LDFLAGS_FINAL += --no-warn-rwx-segments

Applied to master. I wrapped it like this, to not break on systems with 
older binutils:

   LDFLAGS_FINAL += $(call try-ldflag,$(LD),--no-warn-rwx-segments)
diff mbox series

Patch

diff --git a/Makefile.main b/Makefile.main
index bfa24f61342f..934d4c2aa133 100644
--- a/Makefile.main
+++ b/Makefile.main
@@ -190,6 +190,7 @@  LDFLAGS += -Wl,--oformat,elf64-powerpc
 LDFLAGS_FINAL = -m elf64lppc --no-multi-toc -N --build-id=none --whole-archive
 LDFLAGS_FINAL += -static -nostdlib -pie -Ttext-segment=$(LD_TEXT) --oformat=elf64-powerpc
 LDFLAGS_FINAL += --orphan-handling=warn
+LDFLAGS_FINAL += --no-warn-rwx-segments
 
 LDRFLAGS=-melf64ppc
 # Debug stuff