diff options
Diffstat (limited to 'binutils-2.22/ld/scripttempl/elf.sc')
-rw-r--r-- | binutils-2.22/ld/scripttempl/elf.sc | 54 |
1 files changed, 33 insertions, 21 deletions
diff --git a/binutils-2.22/ld/scripttempl/elf.sc b/binutils-2.22/ld/scripttempl/elf.sc index 6f61fda..e492a47 100644 --- a/binutils-2.22/ld/scripttempl/elf.sc +++ b/binutils-2.22/ld/scripttempl/elf.sc @@ -111,7 +111,9 @@ 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})" + #DATA_SEGMENT_ALIGN="ALIGN (${SEGMENT_SIZE}) - ((${MAXPAGESIZE} - .) & (${MAXPAGESIZE} - 1)); . = DATA_SEGMENT_ALIGN (${MAXPAGESIZE}, ${COMMONPAGESIZE})" + # For Android, we align at exactly a page boundary. + DATA_SEGMENT_ALIGN="ALIGN (${SEGMENT_SIZE}); . = DATA_SEGMENT_ALIGN (${MAXPAGESIZE}, ${COMMONPAGESIZE})" DATA_SEGMENT_END=". = DATA_SEGMENT_END (.);" DATA_SEGMENT_RELRO_END=". = DATA_SEGMENT_RELRO_END (${SEPARATE_GOTPLT-0}, .);" fi @@ -149,7 +151,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* .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} : { @@ -235,19 +237,17 @@ 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} : { @@ -263,14 +263,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}} @@ -279,8 +279,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}} @@ -291,8 +291,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 this is for an embedded system, don't add SIZEOF_HEADERS. if [ -z "$EMBEDDED" ]; then @@ -476,8 +479,8 @@ cat <<EOF .exception_ranges ${RELOCATING-0} : ONLY_IF_RO { *(.exception_ranges .exception_ranges*) } - /* 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. 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}};}} @@ -491,14 +494,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)) } @@ -544,10 +556,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} ${RELOCATING+${OTHER_BSS_END_SYMBOLS}} @@ -555,7 +565,9 @@ cat <<EOF ${LARGE_SECTIONS} ${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 |