diff options
author | Andrew Hsieh <andrewhsieh@google.com> | 2014-12-09 19:31:31 +0800 |
---|---|---|
committer | Andrew Hsieh <andrewhsieh@google.com> | 2014-12-09 19:53:01 +0800 |
commit | d6a74de3e11d305ca3159263839e6974c5c46d6e (patch) | |
tree | 395238ebe7e43b7ee66ba75b9397a46d1ca38e8e /binutils-2.25/ld | |
parent | 5e8c1cf25beccac1d22d10dc866912394f42771b (diff) | |
download | toolchain_binutils-d6a74de3e11d305ca3159263839e6974c5c46d6e.zip toolchain_binutils-d6a74de3e11d305ca3159263839e6974c5c46d6e.tar.gz toolchain_binutils-d6a74de3e11d305ca3159263839e6974c5c46d6e.tar.bz2 |
[2.25] re-apply local patches
e0bca373a85fa71b89d9ea42370433b3c0499b9d
160ce55a90bcdcb3000d74805795969edc3f8422
b33d0ddc123435be5e60ebb15a37b3bfb651dc7e
f25603579c0a04b3d5099259cf54c5b3c8775b78
1000fadfaa979b623e1fbd0c87858be4f5b6dffd
83cabeb81083ac53719eaaf68c48734ff9c48fa9
Change-Id: I15f9c78c69f4cfce7a617b7e9d91dd855b6d8efc
Diffstat (limited to 'binutils-2.25/ld')
-rw-r--r-- | binutils-2.25/ld/emulparams/elf32bmip.sh | 8 | ||||
-rw-r--r-- | binutils-2.25/ld/emulparams/elf32ltsmip.sh | 1 | ||||
-rwxr-xr-x | binutils-2.25/ld/genscripts.sh | 5 | ||||
-rw-r--r-- | binutils-2.25/ld/scripttempl/elf.sc | 61 |
4 files changed, 44 insertions, 31 deletions
diff --git a/binutils-2.25/ld/emulparams/elf32bmip.sh b/binutils-2.25/ld/emulparams/elf32bmip.sh index 8da0f8f..c8ed5df 100644 --- a/binutils-2.25/ld/emulparams/elf32bmip.sh +++ b/binutils-2.25/ld/emulparams/elf32bmip.sh @@ -6,7 +6,7 @@ SCRIPT_NAME=elf OUTPUT_FORMAT="elf32-bigmips" BIG_OUTPUT_FORMAT="elf32-bigmips" LITTLE_OUTPUT_FORMAT="elf32-littlemips" -TEXT_START_ADDR=0x0400000 +TEXT_START_ADDR=0x80000 test -n "${EMBEDDED}" || DATA_ADDR=0x10000000 MAXPAGESIZE="CONSTANT (MAXPAGESIZE)" COMMONPAGESIZE="CONSTANT (COMMONPAGESIZE)" @@ -65,12 +65,6 @@ OTHER_BSS_SYMBOLS='_fbss = .;' OTHER_SECTIONS=' .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) } .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) } - .mdebug.abi32 0 : { KEEP(*(.mdebug.abi32)) } - .mdebug.abiN32 0 : { KEEP(*(.mdebug.abiN32)) } - .mdebug.abi64 0 : { KEEP(*(.mdebug.abi64)) } - .mdebug.abiO64 0 : { KEEP(*(.mdebug.abiO64)) } - .mdebug.eabi32 0 : { KEEP(*(.mdebug.eabi32)) } - .mdebug.eabi64 0 : { KEEP(*(.mdebug.eabi64)) } .gcc_compiled_long32 0 : { KEEP(*(.gcc_compiled_long32)) } .gcc_compiled_long64 0 : { KEEP(*(.gcc_compiled_long64)) } ' diff --git a/binutils-2.25/ld/emulparams/elf32ltsmip.sh b/binutils-2.25/ld/emulparams/elf32ltsmip.sh index 4a660f0..edf73df 100644 --- a/binutils-2.25/ld/emulparams/elf32ltsmip.sh +++ b/binutils-2.25/ld/emulparams/elf32ltsmip.sh @@ -1,2 +1,3 @@ . ${srcdir}/emulparams/elf32btsmip.sh OUTPUT_FORMAT="elf32-tradlittlemips" +unset TEXT_DYNAMIC diff --git a/binutils-2.25/ld/genscripts.sh b/binutils-2.25/ld/genscripts.sh index 499607a..1d8c4de 100755 --- a/binutils-2.25/ld/genscripts.sh +++ b/binutils-2.25/ld/genscripts.sh @@ -228,7 +228,8 @@ case :${lib_path1}:${lib_path2}: in *) LIB_PATH=${lib_path1}:${lib_path2} ;; esac -LIB_SEARCH_DIRS=`echo ${LIB_PATH} | sed -e 's/:/ /g' -e 's/\([^ ][^ ]*\)/SEARCH_DIR(\\"\1\\");/g'` +# For Android, comment out LIB_SEARCH_DIRS. +#LIB_SEARCH_DIRS=`echo ${LIB_PATH} | sed -e 's/:/ /g' -e 's/\([^ ][^ ]*\)/SEARCH_DIR(\\"\1\\");/g'` # We need it for testsuite. set $EMULATION_LIBPATH @@ -294,6 +295,7 @@ LD_FLAG= DATA_ALIGNMENT=${DATA_ALIGNMENT_} RELOCATING=" " ( echo "/* Default linker script, for normal executables */" + echo "/* Modified for Android. */" . ${CUSTOMIZER_SCRIPT} . ${srcdir}/scripttempl/${SCRIPT_NAME}.sc ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.x @@ -347,6 +349,7 @@ if test -n "$GENERATE_SHLIB_SCRIPT"; then DATA_ALIGNMENT=${DATA_ALIGNMENT_sc-${DATA_ALIGNMENT}} COMBRELOC=ldscripts/${EMULATION_NAME}.xsc.tmp ( echo "/* Script for --shared -z combreloc: shared library, combine & sort relocs */" + echo "/* Modified for Android. */" . ${CUSTOMIZER_SCRIPT} . ${srcdir}/scripttempl/${SCRIPT_NAME}.sc ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xsc diff --git a/binutils-2.25/ld/scripttempl/elf.sc b/binutils-2.25/ld/scripttempl/elf.sc index 4368fd9..60c7675 100644 --- a/binutils-2.25/ld/scripttempl/elf.sc +++ b/binutils-2.25/ld/scripttempl/elf.sc @@ -127,7 +127,12 @@ DATA_SEGMENT_ALIGN="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))" DATA_SEGMENT_RELRO_END="" DATA_SEGMENT_END="" if test -n "${COMMONPAGESIZE}"; then - DATA_SEGMENT_ALIGN="ALIGN (${SEGMENT_SIZE}) - ((${MAXPAGESIZE} - .) & (${MAXPAGESIZE} - 1)); . = DATA_SEGMENT_ALIGN (${MAXPAGESIZE}, ${COMMONPAGESIZE})" + if [ "$ELFSIZE" = "64" ]; then + DATA_SEGMENT_ALIGN="ALIGN (${SEGMENT_SIZE}) - ((${MAXPAGESIZE} - .) & (${MAXPAGESIZE} - 1)); . = DATA_SEGMENT_ALIGN (${MAXPAGESIZE}, ${COMMONPAGESIZE})" + else + # For 32, we align at exactly a page boundary. + DATA_SEGMENT_ALIGN="ALIGN (${SEGMENT_SIZE}); . = DATA_SEGMENT_ALIGN (${MAXPAGESIZE}, ${COMMONPAGESIZE})" + fi DATA_SEGMENT_END=". = DATA_SEGMENT_END (.);" DATA_SEGMENT_RELRO_END=". = DATA_SEGMENT_RELRO_END (${SEPARATE_GOTPLT-0}, .);" fi @@ -165,7 +170,7 @@ RELA_IPLT=".rela.iplt ${RELOCATING-0} : DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }" RODATA=".${RODATA_NAME} ${RELOCATING-0} : { *(.${RODATA_NAME}${RELOCATING+ .${RODATA_NAME}.* .gnu.linkonce.r.*}) }" DATARELRO=".data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }" -DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }" +DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) *(.mdebug.*) }" if test -z "${NO_SMALL_DATA}"; then SBSS=".${SBSS_NAME} ${RELOCATING-0} : { @@ -240,8 +245,8 @@ test "${LARGE_SECTIONS}" = "yes" && LARGE_SECTIONS=" if test "${ENABLE_INITFINI_ARRAY}" = "yes"; then SORT_INIT_ARRAY="KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))" SORT_FINI_ARRAY="KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))" - CTORS_IN_INIT_ARRAY="EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .ctors" - DTORS_IN_FINI_ARRAY="EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors" + CTORS_IN_INIT_ARRAY="EXCLUDE_FILE (*crtbegin.o *crtbegin*.o *crtend.o *crtend*.o $OTHER_EXCLUDE_FILES) .ctors" + DTORS_IN_FINI_ARRAY="EXCLUDE_FILE (*crtbegin.o *crtbegin*.o *crtend.o *crtend*.o $OTHER_EXCLUDE_FILES) .dtors" else SORT_INIT_ARRAY="KEEP (*(SORT(.init_array.*)))" SORT_FINI_ARRAY="KEEP (*(SORT(.fini_array.*)))" @@ -250,17 +255,15 @@ else fi INIT_ARRAY=".init_array ${RELOCATING-0} : { - ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_start = .);}} + KEEP (*crtbegin*.o(.init_array)) ${SORT_INIT_ARRAY} KEEP (*(.init_array ${CTORS_IN_INIT_ARRAY})) - ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_end = .);}} }" FINI_ARRAY=".fini_array ${RELOCATING-0} : { - ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_start = .);}} + KEEP (*crtbegin*.o(.fini_array)) ${SORT_FINI_ARRAY} KEEP (*(.fini_array ${DTORS_IN_FINI_ARRAY})) - ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_end = .);}} }" CTOR=".ctors ${CONSTRUCTING-0} : { @@ -276,14 +279,14 @@ CTOR=".ctors ${CONSTRUCTING-0} : is in. */ KEEP (*crtbegin.o(.ctors)) - KEEP (*crtbegin?.o(.ctors)) + KEEP (*crtbegin*.o(.ctors)) /* We don't want to include the .ctor section from the crtend.o file until after the sorted ctors. The .ctor section from the crtend file contains the end of ctors marker and it must be last */ - KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .ctors)) + KEEP (*(EXCLUDE_FILE (*crtend.o *crtend*.o $OTHER_EXCLUDE_FILES) .ctors)) KEEP (*(SORT(.ctors.*))) KEEP (*(.ctors)) ${CONSTRUCTING+${CTOR_END}} @@ -292,8 +295,8 @@ DTOR=".dtors ${CONSTRUCTING-0} : { ${CONSTRUCTING+${DTOR_START}} KEEP (*crtbegin.o(.dtors)) - KEEP (*crtbegin?.o(.dtors)) - KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors)) + KEEP (*crtbegin*.o(.dtors)) + KEEP (*(EXCLUDE_FILE (*crtend.o *crtend*.o $OTHER_EXCLUDE_FILES) .dtors)) KEEP (*(SORT(.dtors.*))) KEEP (*(.dtors)) ${CONSTRUCTING+${DTOR_END}} @@ -304,8 +307,11 @@ STACK=" .stack ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} : *(.stack) }" -TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${TEXT_START_ADDR})" -SHLIB_TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${SHLIB_TEXT_START_ADDR:-0})" +# For Android, remove SEGMENT_START. +#TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${TEXT_START_ADDR})" +#SHLIB_TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${SHLIB_TEXT_START_ADDR:-0})" +TEXT_START_ADDR="${TEXT_START_ADDR}" +SHLIB_TEXT_START_ADDR="0" if [ -z "$SEPARATE_CODE" ]; then SIZEOF_HEADERS_CODE=" + SIZEOF_HEADERS" @@ -542,8 +548,8 @@ cat <<EOF .exception_ranges*) } ${TEXT_PLT+${PLT_NEXT_DATA+${PLT}}} - /* Adjust the address for the data segment. We want to adjust up to - the same address within the page on the next page up. */ + /* Adjust the address for the data segment. For 32 bits we want to align + at exactly a page boundary to make life easier for apriori. */ ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+. = ${DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}} ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}} ${CREATE_PIE+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}} @@ -557,14 +563,23 @@ cat <<EOF .tdata ${RELOCATING-0} : { *(.tdata${RELOCATING+ .tdata.* .gnu.linkonce.td.*}) } .tbss ${RELOCATING-0} : { *(.tbss${RELOCATING+ .tbss.* .gnu.linkonce.tb.*})${RELOCATING+ *(.tcommon)} } + /* Ensure the __preinit_array_start label is properly aligned. We + could instead move the label definition inside the section, but + the linker would then create the section even if it turns out to + be empty, which isn't pretty. */ + . = ALIGN(32 / 8); + ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_start = .);}} .preinit_array ${RELOCATING-0} : { - ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_start = .);}} KEEP (*(.preinit_array)) - ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_end = .);}} } + ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_end = .);}} + ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_start = .);}} ${RELOCATING+${INIT_ARRAY}} + ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_end = .);}} + ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_start = .);}} ${RELOCATING+${FINI_ARRAY}} + ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_end = .);}} ${SMALL_DATA_CTOR-${RELOCATING+${CTOR}}} ${SMALL_DATA_DTOR-${RELOCATING+${DTOR}}} .jcr ${RELOCATING-0} : { KEEP (*(.jcr)) } @@ -612,10 +627,8 @@ cat <<EOF *(COMMON) /* Align here to ensure that the .bss section occupies space up to _end. Align after .bss to ensure correct alignment even if the - .bss section disappears because there are no input sections. - FIXME: Why do we need it? When there is no .bss section, we don't - pad the .data section. */ - ${RELOCATING+. = ALIGN(. != 0 ? ${ALIGNMENT} : 1);} + .bss section disappears because there are no input sections. */ + ${RELOCATING+. = ALIGN(${ALIGNMENT});} } ${OTHER_BSS_SECTIONS} ${LARGE_BSS_AFTER_BSS+${LARGE_BSS}} @@ -634,7 +647,9 @@ SHLIB_LARGE_DATA_ADDR=". = SEGMENT_START(\"ldata-segment\", ${SHLIB_LARGE_DATA_A ${LARGE_BSS_AFTER_BSS-${LARGE_BSS}} ${RELOCATING+. = ALIGN(${ALIGNMENT});} ${RELOCATING+${OTHER_END_SYMBOLS}} - ${RELOCATING+${END_SYMBOLS-${USER_LABEL_PREFIX}_end = .; PROVIDE (${USER_LABEL_PREFIX}end = .);}} + ${RELOCATING+${END_SYMBOLS-${USER_LABEL_PREFIX}_end = .; + _bss_end__ = . ; __bss_end__ = . ; __end__ = . ; + PROVIDE (${USER_LABEL_PREFIX}end = .);}} ${RELOCATING+${DATA_SEGMENT_END}} EOF |