Skip to contentSkip to conversation

arm/flat.lds: Specify program headers with flags to avoid linker warnings

PATCH Applied Thomas Huth 2 participants 2 messages Jun 23, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm/flat.lds: Specify program headers with flags to avoid linker warnings

With ld from binutils v2.40 I currently get warning messages like this:

ld: warning: arm/spinlock-test.elf has a LOAD segment with RWX permissions
ld: warning: arm/selftest.elf has a LOAD segment with RWX permissions
ld: warning: arm/pci-test.elf has a LOAD segment with RWX permissions
ld: warning: arm/pmu.elf has a LOAD segment with RWX permissions
...

Seems like these can be silenced by explicitly specifying the program headers with the appropriate flags (like we did in commit 0a06949aafac4a4 on x86 and in commit 5126732d73aa75 on powerpc already).

---
 arm/flat.lds | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
arm/flat.lds +9 -3
index 47fcb649..f722c650 100644
@@ -22,10 +22,16 @@
  *    +----------------------+   <-- physical address 0x0
  */
 
+PHDRS
+{
+    text PT_LOAD FLAGS(5);
+    data PT_LOAD FLAGS(6);
+}
+
 SECTIONS
 {
     PROVIDE(_text = .);
-    .text : { *(.init) *(.text) *(.text.*) }
+    .text : { *(.init) *(.text) *(.text.*) } :text
     . = ALIGN(64K);
     PROVIDE(etext = .);
 
@@ -39,8 +45,8 @@ SECTIONS
     .got      : { *(.got) *(.got.plt) }
     .eh_frame : { *(.eh_frame) }
 
-    .rodata   : { *(.rodata*) }
-    .data     : { *(.data) }
+    .rodata   : { *(.rodata*) } :data
+    .data     : { *(.data) } :data
     . = ALIGN(16);
     PROVIDE(bss = .);
     .bss      : { *(.bss) }
Signature · 1 line
2.39.3
Applied
#1 lore raw
Quoted 53 lines · Thomas Huth

With ld from binutils v2.40 I currently get warning messages like this:

ld: warning: arm/spinlock-test.elf has a LOAD segment with RWX permissions
ld: warning: arm/selftest.elf has a LOAD segment with RWX permissions
ld: warning: arm/pci-test.elf has a LOAD segment with RWX permissions
ld: warning: arm/pmu.elf has a LOAD segment with RWX permissions
...

Seems like these can be silenced by explicitly specifying the program headers with the appropriate flags (like we did in commit 0a06949aafac4a4 on x86 and in commit 5126732d73aa75 on powerpc already).

---
 arm/flat.lds | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
arm/flat.lds +9 -3
index 47fcb649..f722c650 100644
@@ -22,10 +22,16 @@
  *    +----------------------+   <-- physical address 0x0
  */
 
+PHDRS
+{
+    text PT_LOAD FLAGS(5);
+    data PT_LOAD FLAGS(6);
+}
+
 SECTIONS
 {
     PROVIDE(_text = .);
-    .text : { *(.init) *(.text) *(.text.*) }
+    .text : { *(.init) *(.text) *(.text.*) } :text
     . = ALIGN(64K);
     PROVIDE(etext = .);
 
@@ -39,8 +45,8 @@ SECTIONS
     .got      : { *(.got) *(.got.plt) }
     .eh_frame : { *(.eh_frame) }
 
-    .rodata   : { *(.rodata*) }
-    .data     : { *(.data) }
+    .rodata   : { *(.rodata*) } :data
+    .data     : { *(.data) } :data
     . = ALIGN(16);
     PROVIDE(bss = .);
     .bss      : { *(.bss) }
Signature · 1 line
2.39.3

Applied to arm/queue

https://gitlab.com/jones-drew/kvm-unit-tests/-/commits/arm/queue

Thanks,
drew