summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--binutils-2.19/bfd/elf32-arm.c15
-rw-r--r--binutils-2.19/binutils/bucomm.h2
-rw-r--r--binutils-2.19/binutils/readelf.c6
-rw-r--r--binutils-2.19/elfcpp/arm.h1
-rw-r--r--binutils-2.19/gas/config/tc-arm.c1
-rw-r--r--binutils-2.19/gold/arm.cc13
-rw-r--r--binutils-2.19/include/elf/arm.h1
-rw-r--r--binutils-2.21/bfd/elf.c2
-rw-r--r--binutils-2.21/bfd/elfxx-mips.c32
-rw-r--r--binutils-2.21/binutils/bucomm.h2
-rw-r--r--binutils-2.21/ld/emulparams/elf32bmip.sh8
-rw-r--r--binutils-2.21/ld/emulparams/elf32ltsmip.sh1
-rw-r--r--binutils-2.21/ld/emultempl/mipself.em5
-rwxr-xr-xbinutils-2.21/ld/genscripts.sh5
-rw-r--r--binutils-2.21/ld/scripttempl/elf.sc54
-rw-r--r--binutils-2.22/binutils/bucomm.h2
-rw-r--r--binutils-2.22/ld/emulparams/elf32bmip.sh8
-rw-r--r--binutils-2.22/ld/emulparams/elf32ltsmip.sh1
-rwxr-xr-xbinutils-2.22/ld/genscripts.sh5
-rw-r--r--binutils-2.22/ld/scripttempl/elf.sc54
20 files changed, 150 insertions, 68 deletions
diff --git a/binutils-2.19/bfd/elf32-arm.c b/binutils-2.19/bfd/elf32-arm.c
index 97ddcca..7de8c56 100644
--- a/binutils-2.19/bfd/elf32-arm.c
+++ b/binutils-2.19/bfd/elf32-arm.c
@@ -9340,6 +9340,19 @@ elf32_arm_merge_eabi_attributes (bfd *ibfd, bfd *obfd)
return FALSE;
}
break;
+ case Tag_DIV_use:
+ /* In later binutils this tag is set to zero if we can use UDIV and SDIV in Thumb
+ mode on a v7-M or v7-R CPU; to one if we can not use UDIV or
+ SDIV at all; and to two if we can use UDIV or SDIV on a v7-A
+ CPU. We will merge as follows: If the input attribute's value
+ is one then the output attribute's value remains unchanged. If
+ the input attribute's value is zero or two then if the output
+ attribute's value is one the output value is set to the input
+ value, otherwise the output value must be the same as the
+ inputs.
+ In this binutils we don't generate in assembler nor propagate this tag */
+
+ break;
default: /* All known attributes should be explicitly covered. */
abort ();
}
@@ -9372,7 +9385,7 @@ elf32_arm_merge_eabi_attributes (bfd *ibfd, bfd *obfd)
for (; in_list; in_list = in_list->next)
{
- if ((in_list->tag & 128) < 64)
+ if ((in_list->tag & 128) < 64 && in_list->tag != Tag_DIV_use)
{
_bfd_error_handler
(_("Warning: %B: Unknown EABI object attribute %d"),
diff --git a/binutils-2.19/binutils/bucomm.h b/binutils-2.19/binutils/bucomm.h
index 08c166b..dd1d2e8 100644
--- a/binutils-2.19/binutils/bucomm.h
+++ b/binutils-2.19/binutils/bucomm.h
@@ -22,6 +22,8 @@
#ifndef _BUCOMM_H
#define _BUCOMM_H
+#include <sys/stat.h>
+
/* Return the filename in a static buffer. */
const char *bfd_get_archive_filename (bfd *);
diff --git a/binutils-2.19/binutils/readelf.c b/binutils-2.19/binutils/readelf.c
index 2d356a6..24a9839 100644
--- a/binutils-2.19/binutils/readelf.c
+++ b/binutils-2.19/binutils/readelf.c
@@ -8796,6 +8796,9 @@ static const char *arm_attr_tag_ABI_optimization_goals[] =
static const char *arm_attr_tag_ABI_FP_optimization_goals[] =
{"None", "Prefer Speed", "Aggressive Speed", "Prefer Size",
"Aggressive Size", "Prefer Accuracy", "Aggressive Accuracy"};
+static const char * arm_attr_tag_DIV_use[] =
+ {"Allowed in Thumb-ISA, v7-R or v7-M", "Not allowed",
+ "Allowed in v7-A with integer division extension"};
#define LOOKUP(id, name) \
{id, #name, 0x80 | ARRAY_SIZE(arm_attr_tag_##name), arm_attr_tag_##name}
@@ -8829,7 +8832,8 @@ static arm_attr_public_tag arm_attr_public_tags[] =
LOOKUP(29, ABI_WMMX_args),
LOOKUP(30, ABI_optimization_goals),
LOOKUP(31, ABI_FP_optimization_goals),
- {32, "compatibility", 0, NULL}
+ {32, "compatibility", 0, NULL},
+ LOOKUP(44, DIV_use)
};
#undef LOOKUP
diff --git a/binutils-2.19/elfcpp/arm.h b/binutils-2.19/elfcpp/arm.h
index 397d0d0..4a8f56c 100644
--- a/binutils-2.19/elfcpp/arm.h
+++ b/binutils-2.19/elfcpp/arm.h
@@ -285,6 +285,7 @@ enum
Tag_undefined37 = 37,
Tag_ABI_FP_16bit_format = 38,
Tag_undefined39 = 39,
+ Tag_DIV_use = 44,
Tag_nodefaults = 64,
Tag_also_compatible_with = 65,
Tag_T2EE_use = 66,
diff --git a/binutils-2.19/gas/config/tc-arm.c b/binutils-2.19/gas/config/tc-arm.c
index 7768f47..062c807 100644
--- a/binutils-2.19/gas/config/tc-arm.c
+++ b/binutils-2.19/gas/config/tc-arm.c
@@ -20855,6 +20855,7 @@ aeabi_set_public_attributes (void)
if (ARM_CPU_HAS_FEATURE (thumb_arch_used, fpu_neon_ext_v1)
|| ARM_CPU_HAS_FEATURE (arm_arch_used, fpu_neon_ext_v1))
bfd_elf_add_proc_attr_int (stdoutput, 12, 1);
+ /* Don't set Tag_DIV_use on purpose. */
}
/* Add the default contents for the .ARM.attributes section. */
diff --git a/binutils-2.19/gold/arm.cc b/binutils-2.19/gold/arm.cc
index 9edfa90..001a5b3 100644
--- a/binutils-2.19/gold/arm.cc
+++ b/binutils-2.19/gold/arm.cc
@@ -10342,6 +10342,19 @@ Target_arm<big_endian>::merge_object_attributes(
out_attr[i].set_int_value(in_attr[i].int_value());
break;
+ case elfcpp::Tag_DIV_use:
+ // In later binutils this tag is set to zero if we can use UDIV and SDIV in Thumb
+ // mode on a v7-M or v7-R CPU; to one if we can not use UDIV or
+ // SDIV at all; and to two if we can use UDIV or SDIV on a v7-A
+ // CPU. We will merge as follows: If the input attribute's value
+ // is one then the output attribute's value remains unchanged. If
+ // the input attribute's value is zero or two then if the output
+ // attribute's value is one the output value is set to the input
+ // value, otherwise the output value must be the same as the
+ // inputs.
+ // In this binutils we don't generate in assembler nor propagate this tag.
+ break;
+
case elfcpp::Tag_nodefaults:
// This tag is set if it exists, but the value is unused (and is
// typically zero). We don't actually need to do anything here -
diff --git a/binutils-2.19/include/elf/arm.h b/binutils-2.19/include/elf/arm.h
index af623f1..1b5a69e 100644
--- a/binutils-2.19/include/elf/arm.h
+++ b/binutils-2.19/include/elf/arm.h
@@ -272,6 +272,7 @@ enum
Tag_ABI_optimization_goals,
Tag_ABI_FP_optimization_goals,
/* 32 is generic. */
+ Tag_DIV_use = 44
};
#endif
diff --git a/binutils-2.21/bfd/elf.c b/binutils-2.21/bfd/elf.c
index 92993a0..3c11bec 100644
--- a/binutils-2.21/bfd/elf.c
+++ b/binutils-2.21/bfd/elf.c
@@ -6213,6 +6213,8 @@ _bfd_elf_init_private_section_data (bfd *ibfd,
|| obfd->xvec->flavour != bfd_target_elf_flavour)
return TRUE;
+ BFD_ASSERT (elf_section_data (osec) != NULL);
+
/* For objcopy and relocatable link, don't copy the output ELF
section type from input if the output BFD section flags have been
set to something different. For a final link allow some flags
diff --git a/binutils-2.21/bfd/elfxx-mips.c b/binutils-2.21/bfd/elfxx-mips.c
index 4718dd4..5178b20 100644
--- a/binutils-2.21/bfd/elfxx-mips.c
+++ b/binutils-2.21/bfd/elfxx-mips.c
@@ -1726,6 +1726,11 @@ mips_elf_check_symbols (struct mips_elf_link_hash_entry *h, void *data)
if (mips_elf_local_pic_function_p (h))
{
+ /* PR 12845: If H is in a section that has been garbage
+ collected it will have its output section set to *ABS*. */
+ if (bfd_is_abs_section (h->root.root.u.def.section->output_section))
+ return TRUE;
+
/* H is a function that might need $25 to be valid on entry.
If we're creating a non-PIC relocatable object, mark H as
being PIC. If we're creating a non-relocatable object with
@@ -3852,6 +3857,10 @@ mips_elf_count_got_symbols (struct mips_elf_link_hash_entry *h, void *data)
struct mips_elf_link_hash_table *htab;
struct mips_got_info *g;
+ /* Follow warning symbol link. */
+ if (h->root.root.type == bfd_link_hash_warning)
+ h = (struct mips_elf_link_hash_entry *) h->root.root.u.i.link;
+
info = (struct bfd_link_info *) data;
htab = mips_elf_hash_table (info);
g = htab->got_info;
@@ -4080,14 +4089,18 @@ mips_elf_merge_got_with (struct mips_elf_bfd2got_hash *bfd2got,
if (estimate >= from->page_gotno + to->page_gotno)
estimate = from->page_gotno + to->page_gotno;
- /* And conservatively estimate how many local, global and TLS entries
+ /* And conservatively estimate how many local and TLS entries
would be needed. */
- estimate += (from->local_gotno
- + from->global_gotno
- + from->tls_gotno
- + to->local_gotno
- + to->global_gotno
- + to->tls_gotno);
+ estimate += from->local_gotno + to->local_gotno;
+ estimate += from->tls_gotno + to->tls_gotno;
+
+ /* If we're merging with the primary got, we will always have
+ the full set of global entries. Otherwise estimate those
+ conservatively as well. */
+ if (to == arg->primary)
+ estimate += arg->global_count;
+ else
+ estimate += from->global_gotno + to->global_gotno;
/* Bail out if the combined GOT might be too big. */
if (estimate > arg->max_count)
@@ -7736,7 +7749,6 @@ _bfd_mips_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
if (!mips_elf_record_got_page_entry (info, abfd, r_symndx,
addend))
return FALSE;
- break;
}
/* Fall through. */
@@ -8601,6 +8613,10 @@ mips_elf_allocate_lazy_stub (struct mips_elf_link_hash_entry *h, void **data)
{
struct mips_elf_link_hash_table *htab;
+ /* Follow warning symbol link. */
+ if (h->root.root.type == bfd_link_hash_warning)
+ h = (struct mips_elf_link_hash_entry *) h->root.root.u.i.link;
+
htab = (struct mips_elf_link_hash_table *) data;
if (h->needs_lazy_stub)
{
diff --git a/binutils-2.21/binutils/bucomm.h b/binutils-2.21/binutils/bucomm.h
index fcbc32b..8124bd0 100644
--- a/binutils-2.21/binutils/bucomm.h
+++ b/binutils-2.21/binutils/bucomm.h
@@ -23,6 +23,8 @@
#ifndef _BUCOMM_H
#define _BUCOMM_H
+#include <sys/stat.h>
+
/* Return the filename in a static buffer. */
const char *bfd_get_archive_filename (const bfd *);
diff --git a/binutils-2.21/ld/emulparams/elf32bmip.sh b/binutils-2.21/ld/emulparams/elf32bmip.sh
index 44a0b8a..8dae1bb 100644
--- a/binutils-2.21/ld/emulparams/elf32bmip.sh
+++ b/binutils-2.21/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)"
@@ -64,12 +64,6 @@ OTHER_BSS_SYMBOLS='_fbss = .;'
OTHER_SECTIONS='
.gptab.sdata : { *(.gptab.data) *(.gptab.sdata) }
.gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) }
- .mdebug.abi32 : { KEEP(*(.mdebug.abi32)) }
- .mdebug.abiN32 : { KEEP(*(.mdebug.abiN32)) }
- .mdebug.abi64 : { KEEP(*(.mdebug.abi64)) }
- .mdebug.abiO64 : { KEEP(*(.mdebug.abiO64)) }
- .mdebug.eabi32 : { KEEP(*(.mdebug.eabi32)) }
- .mdebug.eabi64 : { KEEP(*(.mdebug.eabi64)) }
.gcc_compiled_long32 : { KEEP(*(.gcc_compiled_long32)) }
.gcc_compiled_long64 : { KEEP(*(.gcc_compiled_long64)) }
'
diff --git a/binutils-2.21/ld/emulparams/elf32ltsmip.sh b/binutils-2.21/ld/emulparams/elf32ltsmip.sh
index 4a660f0..edf73df 100644
--- a/binutils-2.21/ld/emulparams/elf32ltsmip.sh
+++ b/binutils-2.21/ld/emulparams/elf32ltsmip.sh
@@ -1,2 +1,3 @@
. ${srcdir}/emulparams/elf32btsmip.sh
OUTPUT_FORMAT="elf32-tradlittlemips"
+unset TEXT_DYNAMIC
diff --git a/binutils-2.21/ld/emultempl/mipself.em b/binutils-2.21/ld/emultempl/mipself.em
index 7a13d4d..ada0786 100644
--- a/binutils-2.21/ld/emultempl/mipself.em
+++ b/binutils-2.21/ld/emultempl/mipself.em
@@ -138,6 +138,11 @@ mips_add_stub_section (const char *stub_sec_name, asection *input_section,
lang_output_section_statement_type *os;
struct hook_stub_info info;
+ /* PR 12845: If the input section has been garbage collected it will
+ not have its output section set to *ABS*. */
+ if (bfd_is_abs_section (output_section))
+ return NULL;
+
/* Create the stub file, if we haven't already. */
if (stub_file == NULL)
{
diff --git a/binutils-2.21/ld/genscripts.sh b/binutils-2.21/ld/genscripts.sh
index c86631b..d54d85d 100755
--- a/binutils-2.21/ld/genscripts.sh
+++ b/binutils-2.21/ld/genscripts.sh
@@ -239,7 +239,8 @@ if [ "x${use_sysroot}" != "xyes" ] ; then
fi
fi
-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
@@ -305,6 +306,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
@@ -358,6 +360,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.21/ld/scripttempl/elf.sc b/binutils-2.21/ld/scripttempl/elf.sc
index b5060ea..deb92bb 100644
--- a/binutils-2.21/ld/scripttempl/elf.sc
+++ b/binutils-2.21/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} :
{
@@ -224,17 +226,15 @@ test "${LARGE_SECTIONS}" = "yes" && LARGE_SECTIONS="
}"
INIT_ARRAY=".init_array ${RELOCATING-0} :
{
- ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_start = .);}}
+ KEEP (*crtbegin*.o(.init_array))
KEEP (*(SORT(.init_array.*)))
KEEP (*(.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))
KEEP (*(SORT(.fini_array.*)))
KEEP (*(.fini_array))
- ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_end = .);}}
}"
CTOR=".ctors ${CONSTRUCTING-0} :
{
@@ -250,14 +250,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}}
@@ -266,8 +266,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}}
@@ -278,8 +278,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
@@ -459,8 +462,8 @@ cat <<EOF
.eh_frame ${RELOCATING-0} : ONLY_IF_RO { KEEP (*(.eh_frame)) }
.gcc_except_table ${RELOCATING-0} : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) }
- /* 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}};}}
@@ -473,14 +476,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)) }
@@ -526,10 +538,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}}
@@ -537,7 +547,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
diff --git a/binutils-2.22/binutils/bucomm.h b/binutils-2.22/binutils/bucomm.h
index fcbc32b..8124bd0 100644
--- a/binutils-2.22/binutils/bucomm.h
+++ b/binutils-2.22/binutils/bucomm.h
@@ -23,6 +23,8 @@
#ifndef _BUCOMM_H
#define _BUCOMM_H
+#include <sys/stat.h>
+
/* Return the filename in a static buffer. */
const char *bfd_get_archive_filename (const bfd *);
diff --git a/binutils-2.22/ld/emulparams/elf32bmip.sh b/binutils-2.22/ld/emulparams/elf32bmip.sh
index 44a0b8a..8dae1bb 100644
--- a/binutils-2.22/ld/emulparams/elf32bmip.sh
+++ b/binutils-2.22/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)"
@@ -64,12 +64,6 @@ OTHER_BSS_SYMBOLS='_fbss = .;'
OTHER_SECTIONS='
.gptab.sdata : { *(.gptab.data) *(.gptab.sdata) }
.gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) }
- .mdebug.abi32 : { KEEP(*(.mdebug.abi32)) }
- .mdebug.abiN32 : { KEEP(*(.mdebug.abiN32)) }
- .mdebug.abi64 : { KEEP(*(.mdebug.abi64)) }
- .mdebug.abiO64 : { KEEP(*(.mdebug.abiO64)) }
- .mdebug.eabi32 : { KEEP(*(.mdebug.eabi32)) }
- .mdebug.eabi64 : { KEEP(*(.mdebug.eabi64)) }
.gcc_compiled_long32 : { KEEP(*(.gcc_compiled_long32)) }
.gcc_compiled_long64 : { KEEP(*(.gcc_compiled_long64)) }
'
diff --git a/binutils-2.22/ld/emulparams/elf32ltsmip.sh b/binutils-2.22/ld/emulparams/elf32ltsmip.sh
index 4a660f0..edf73df 100644
--- a/binutils-2.22/ld/emulparams/elf32ltsmip.sh
+++ b/binutils-2.22/ld/emulparams/elf32ltsmip.sh
@@ -1,2 +1,3 @@
. ${srcdir}/emulparams/elf32btsmip.sh
OUTPUT_FORMAT="elf32-tradlittlemips"
+unset TEXT_DYNAMIC
diff --git a/binutils-2.22/ld/genscripts.sh b/binutils-2.22/ld/genscripts.sh
index 61981bd..4f97c08 100755
--- a/binutils-2.22/ld/genscripts.sh
+++ b/binutils-2.22/ld/genscripts.sh
@@ -241,7 +241,8 @@ if [ "x${use_sysroot}" != "xyes" ] ; then
fi
fi
-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
@@ -307,6 +308,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
@@ -360,6 +362,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.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