Skip to content
This repository has been archived by the owner on Aug 17, 2022. It is now read-only.

Commit

Permalink
Remove the .data section from RISC-V's default linker script addon
Browse files Browse the repository at this point in the history
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 <[email protected]>

        * emulparams/elf32lriscv-defs.sh (INITIAL_READONLY_SECTIONS):
        Remove the RISC-V specific .data section mapping.
  • Loading branch information
palmer-dabbelt authored and aswaterman committed Dec 30, 2016
1 parent 8c5f683 commit fe737ad
Showing 1 changed file with 0 additions and 10 deletions.
10 changes: 0 additions & 10 deletions ld/emulparams/elf32lriscv-defs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}}}"

Expand Down

0 comments on commit fe737ad

Please sign in to comment.