From 51bfe85010c6e1554239daa2bda37e44770a9413 Mon Sep 17 00:00:00 2001 From: Palmer Dabbelt Date: Thu, 29 Dec 2016 17:29:53 -0800 Subject: [PATCH] Remove the .data section from RISC-V's default linker script addon I'm actually not sure why this is here: .data isn't read-only and shouldn't be in the INITIAL_READONLY_SECTIONS variable. This causes a handful of sections that should be read-only to actually be read-write when loaded, which breaks things like "-z relro". Removing this causes the default .data mapping to be used, which comes from upstream. As far os I can tell, there was no reason we were ever supposed to have our own .data in the first place, and no other architectures have ever done it this way. I tested this still builds and boots Busybox on Linux. Thanks to Alan Morda for finding the problem. ld/ChangeLog 2016-12-29 Palmer Dabbelt * emulparams/elf32lriscv-defs.sh (INITIAL_READONLY_SECTIONS): Remove the RISC-V-specific data section mappings. --- ld/emulparams/elf32lriscv-defs.sh | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/ld/emulparams/elf32lriscv-defs.sh b/ld/emulparams/elf32lriscv-defs.sh index 0e4b7237ff35..063f059821cb 100644 --- a/ld/emulparams/elf32lriscv-defs.sh +++ b/ld/emulparams/elf32lriscv-defs.sh @@ -26,16 +26,6 @@ COMMONPAGESIZE="CONSTANT (COMMONPAGESIZE)" SDATA_START_SYMBOLS="_gp = . + 0x800; *(.srodata.cst16) *(.srodata.cst8) *(.srodata.cst4) *(.srodata.cst2) *(.srodata .srodata.*)" -# Place the data section before text section. This enables more compact -# global variable access for RVC code via linker relaxation. -INITIAL_READONLY_SECTIONS=" - .data : { *(.data) *(.data.*) *(.gnu.linkonce.d.*) } - .rodata : { *(.rodata) *(.rodata.*) *(.gnu.linkonce.r.*) } - .srodata : { ${SDATA_START_SYMBOLS} } - .sdata : { *(.sdata .sdata.* .gnu.linkonce.s.*) } - .sbss : { *(.dynsbss) *(.sbss .sbss.* .gnu.linkonce.sb.*) } - .bss : { *(.dynbss) *(.bss .bss.* .gnu.linkonce.b.*) *(COMMON) } - . = ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1));" INITIAL_READONLY_SECTIONS=".interp : { *(.interp) } ${CREATE_PIE-${INITIAL_READONLY_SECTIONS}}" INITIAL_READONLY_SECTIONS="${RELOCATING+${CREATE_SHLIB-${INITIAL_READONLY_SECTIONS}}}"