aboutsummaryrefslogtreecommitdiff
path: root/binutils
diff options
context:
space:
mode:
authorAndrew Waterman <waterman@cs.berkeley.edu>2015-10-10 15:43:15 -0700
committerAndrew Waterman <waterman@cs.berkeley.edu>2015-10-10 15:43:58 -0700
commit97951e32a38043c7f03db08178313a14b13dc5a1 (patch)
treeaf22cb84e387723fa14a4b7d84a6442723af1091 /binutils
parente05cc858aa5a6ed1ae0fec885a83090f81f355fe (diff)
downloadriscv-gnu-toolchain-97951e32a38043c7f03db08178313a14b13dc5a1.zip
riscv-gnu-toolchain-97951e32a38043c7f03db08178313a14b13dc5a1.tar.gz
riscv-gnu-toolchain-97951e32a38043c7f03db08178313a14b13dc5a1.tar.bz2
binutils: for non-PIC, put data at 0x10000
This allows global variable references to be relaxed to C.LUI.
Diffstat (limited to 'binutils')
-rw-r--r--binutils/ld/emulparams/elf32lriscv-defs.sh26
1 files changed, 17 insertions, 9 deletions
diff --git a/binutils/ld/emulparams/elf32lriscv-defs.sh b/binutils/ld/emulparams/elf32lriscv-defs.sh
index dd7abde..24163c9 100644
--- a/binutils/ld/emulparams/elf32lriscv-defs.sh
+++ b/binutils/ld/emulparams/elf32lriscv-defs.sh
@@ -24,16 +24,24 @@ fi
GENERATE_SHLIB_SCRIPT=yes
GENERATE_PIE_SCRIPT=yes
-TEXT_START_ADDR=0x800000
+TEXT_START_ADDR=0x10000
MAXPAGESIZE="CONSTANT (MAXPAGESIZE)"
COMMONPAGESIZE="CONSTANT (COMMONPAGESIZE)"
-INITIAL_READONLY_SECTIONS=".interp ${RELOCATING-0} : { *(.interp) }"
SDATA_START_SYMBOLS="_gp = . + 0x800;
- *(.srodata.cst16) *(.srodata.cst8) *(.srodata.cst4) *(.srodata.cst2) *(.srodata*)"
-if test -n "${CREATE_SHLIB}"; then
- INITIAL_READONLY_SECTIONS=
- SDATA_START_SYMBOLS=
- OTHER_READONLY_SECTIONS=".srodata ${RELOCATING-0} : { *(.srodata.cst16) *(.srodata.cst8) *(.srodata.cst4) *(.srodata.cst2) *(.srodata*) }"
- unset GOT
-fi
+ *(.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}}}"
+
+SDATA_START_SYMBOLS="${CREATE_PIE+${SDATA_START_SYMBOLS}}"