Skip to contentSkip to conversation

MIPS: boot: compressed: place .rodata.* and discard .MIPS.abiflags

PATCH Applied Rosen Penev 2 participants 2 messages Oct 9 – Nov 5 MIPS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 MIPS: boot: compressed: place .rodata.* and discard .MIPS.abiflags

The decompressor linker script only collects .rodata. Clang emits the decompressor's strings in .rodata.str1.1 and also produces a .MIPS.abiflags section. GNU ld places such orphans next to similar sections, but ld.lld puts them after .bss:

  [ 5] .bss            NOBITS   809246c0 5346b8 402010
  [ 6] .MIPS.abiflags  ...      80d266d0 9366d0 000018
  [ 7] .rodata.str1.1  PROGBITS 80d266e8 9366e8 000164

This pulls the 4 MB of .bss (mostly the boot heap) into the file and leaves the strings beyond _end. For BCM47XX vmlinuz grows from 5.4 MB to 9.6 MB.

Collect .rodata.* with .rodata, and discard .MIPS.abiflags and .gnu.attributes as arch/mips/kernel/vmlinux.lds.S does.

Assisted-by LLM
---
 arch/mips/boot/compressed/ld.script | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/mips/boot/compressed/ld.script +3 -1
index 0ebb667274d6..c45be18c6f0d 100644
@@ -17,7 +17,7 @@ SECTIONS
 	/* . = VMLINUZ_LOAD_ADDRESS; */
 	.text : {
 		*(.text)
-		*(.rodata)
+		*(.rodata .rodata.*)
 	}: text
 	/* End of text section */
 
@@ -50,7 +50,9 @@ SECTIONS
 
 	/* Sections to be discarded */
 	/DISCARD/ : {
+		*(.MIPS.abiflags)
 		*(.MIPS.options)
+		*(.gnu.attributes)
 		*(.options)
 		*(.pdr)
 		*(.reginfo)
Signature · 1 line
2.56.0
maintainer Applied
#1 lore raw
Quoted 47 lines · Rosen Penev

The decompressor linker script only collects .rodata. Clang emits the decompressor's strings in .rodata.str1.1 and also produces a .MIPS.abiflags section. GNU ld places such orphans next to similar sections, but ld.lld puts them after .bss:

  [ 5] .bss            NOBITS   809246c0 5346b8 402010
  [ 6] .MIPS.abiflags  ...      80d266d0 9366d0 000018
  [ 7] .rodata.str1.1  PROGBITS 80d266e8 9366e8 000164

This pulls the 4 MB of .bss (mostly the boot heap) into the file and leaves the strings beyond _end. For BCM47XX vmlinuz grows from 5.4 MB to 9.6 MB.

Collect .rodata.* with .rodata, and discard .MIPS.abiflags and .gnu.attributes as arch/mips/kernel/vmlinux.lds.S does.

Assisted-by LLM
---
 arch/mips/boot/compressed/ld.script | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/mips/boot/compressed/ld.script +3 -1
index 0ebb667274d6..c45be18c6f0d 100644
@@ -17,7 +17,7 @@ SECTIONS
 	/* . = VMLINUZ_LOAD_ADDRESS; */
 	.text : {
 		*(.text)
-		*(.rodata)
+		*(.rodata .rodata.*)
 	}: text
 	/* End of text section */
 
@@ -50,7 +50,9 @@ SECTIONS
 
 	/* Sections to be discarded */
 	/DISCARD/ : {
+		*(.MIPS.abiflags)
 		*(.MIPS.options)
+		*(.gnu.attributes)
 		*(.options)
 		*(.pdr)
 		*(.reginfo)
Signature · 1 line
2.56.0

applied to mips-fixes

Thomas.

Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]