This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Align data segment using SEGMENT_SIZE
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: binutils at sources dot redhat dot com
- Date: Wed, 25 Sep 2002 16:48:39 +0930
- Subject: Align data segment using SEGMENT_SIZE
The aim of this patch is to allow Jakub's DATA_SEGMENT_ALIGN idea to
work on targets like powerpc64-linux where we want text and data to
reside in separate 256M address ranges. I originally extended the
DATA_SEGMENT_ALIGN token to take an extra "alignment" parameter (which
is why I was poking around in ldexp.c), then realized that I could do
the same thing in the script. The trick is to handle the
COMMONPAGESIZE case by first moving "dot" up to the same address
within a page just below the SEGMENT_SIZE alignment address.
* genscripts.sh (SEGMENT_SIZE): Use MAXPAGESIZE before
TARGET_PAGE_SIZE.
* scripttempl/elf.sc (DATA_SEGMENT_ALIGN): Incorporate
SEGMENT_SIZE alignment.
* emulparams/elf64ppc.sh (DATA_ADDR): Delete.
(SEGMENT_SIZE): Define.
Applying mainline, but not the branch just yet as I have a sneaking
suspicion that DATA_SEGMENT_ALIGN is responsible for a report I
received about "stubs don't match calculated size" on powerpc64-linux.
Index: ld/genscripts.sh
===================================================================
RCS file: /cvs/src/src/ld/genscripts.sh,v
retrieving revision 1.9
diff -u -p -r1.9 genscripts.sh
--- ld/genscripts.sh 22 May 2002 08:44:50 -0000 1.9
+++ ld/genscripts.sh 25 Sep 2002 02:43:49 -0000
@@ -90,7 +90,7 @@ if [ "x$SCRIPT_NAME" = "xelf" ]; then
GENERATE_COMBRELOC_SCRIPT=yes
fi
-SEGMENT_SIZE=${SEGMENT_SIZE-${TARGET_PAGE_SIZE}}
+SEGMENT_SIZE=${SEGMENT_SIZE-${MAXPAGESIZE-${TARGET_PAGE_SIZE}}}
# Determine DATA_ALIGNMENT for the 5 variants, using
# values specified in the emulparams/<emulation>.sh file or default.
Index: ld/emulparams/elf64ppc.sh
===================================================================
RCS file: /cvs/src/src/ld/emulparams/elf64ppc.sh,v
retrieving revision 1.7
diff -u -p -r1.7 elf64ppc.sh
--- ld/emulparams/elf64ppc.sh 24 Sep 2002 04:02:03 -0000 1.7
+++ ld/emulparams/elf64ppc.sh 25 Sep 2002 02:43:50 -0000
@@ -5,7 +5,7 @@ GENERATE_SHLIB_SCRIPT=yes
SCRIPT_NAME=elf
OUTPUT_FORMAT="elf64-powerpc"
TEXT_START_ADDR=0x10000000
-DATA_ADDR="ALIGN (0x10000000) + (. & (${MAXPAGESIZE} - 1))"
+SEGMENT_SIZE=0x10000000
MAXPAGESIZE=0x40000
COMMONPAGESIZE=0x1000
ARCH=powerpc:common64
Index: ld/scripttempl/elf.sc
===================================================================
RCS file: /cvs/src/src/ld/scripttempl/elf.sc,v
retrieving revision 1.34
diff -u -p -r1.34 elf.sc
--- ld/scripttempl/elf.sc 1 Aug 2002 14:02:59 -0000 1.34
+++ ld/scripttempl/elf.sc 25 Sep 2002 02:43:50 -0000
@@ -74,10 +74,10 @@ test -z "${ALIGNMENT}" && ALIGNMENT="${E
test "$LD_FLAG" = "N" && DATA_ADDR=.
test -n "$CREATE_SHLIB" && test -n "$SHLIB_DATA_ADDR" && COMMONPAGESIZE=""
test -z "$CREATE_SHLIB" && test -n "$DATA_ADDR" && COMMONPAGESIZE=""
-DATA_SEGMENT_ALIGN="ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))"
+DATA_SEGMENT_ALIGN="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))"
DATA_SEGMENT_END=""
if test -n "${COMMONPAGESIZE}"; then
- DATA_SEGMENT_ALIGN="DATA_SEGMENT_ALIGN(${MAXPAGESIZE}, ${COMMONPAGESIZE})"
+ DATA_SEGMENT_ALIGN="ALIGN (${SEGMENT_SIZE}) - ((${MAXPAGESIZE} - .) & (${MAXPAGESIZE} - 1)); . = DATA_SEGMENT_ALIGN (${MAXPAGESIZE}, ${COMMONPAGESIZE})"
DATA_SEGMENT_END=". = DATA_SEGMENT_END (.);"
fi
INTERP=".interp ${RELOCATING-0} : { *(.interp) }"
--
Alan Modra
IBM OzLabs - Linux Technology Centre