From bd404ff1cae10a27c6e4d30beb24bc49b1c118a9 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 mapping. --- ld/emulparams/elf32lriscv-defs.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/ld/emulparams/elf32lriscv-defs.sh b/ld/emulparams/elf32lriscv-defs.sh index 0e4b7237ff35..25cf406ee9c7 100644 --- a/ld/emulparams/elf32lriscv-defs.sh +++ b/ld/emulparams/elf32lriscv-defs.sh @@ -29,7 +29,6 @@ SDATA_START_SYMBOLS="_gp = . + 0x800; # 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.*) }