From cb347a47c275561b61431b572002d3cd83a0150a Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Dec 24 2014 12:11:52 +0000 Subject: Rebase the source on the new 2.25 FSF binutils release. --- diff --git a/binutils-2.20.51.0.10-copy-osabi.patch b/binutils-2.20.51.0.10-copy-osabi.patch index 86cb447..55831ca 100644 --- a/binutils-2.20.51.0.10-copy-osabi.patch +++ b/binutils-2.20.51.0.10-copy-osabi.patch @@ -1,19 +1,17 @@ -*** ../binutils-2.20.51.0.10.original/bfd/elf.c 2010-08-10 15:04:55.000000000 +0100 ---- bfd/elf.c 2010-08-10 15:05:42.000000000 +0100 -*************** _bfd_elf_copy_private_bfd_data (bfd *ibf -*** 1074,1079 **** ---- 1074,1087 ---- - - /* Copy object attributes. */ - _bfd_elf_copy_obj_attributes (ibfd, obfd); -+ -+ /* If the input BFD has the OSABI field set and the -+ output BFD does not, then copy the value. */ -+ if (elf_elfheader (ibfd)->e_ident [EI_OSABI] != ELFOSABI_NONE -+ && elf_elfheader (obfd)->e_ident [EI_OSABI] == ELFOSABI_NONE) -+ elf_elfheader (obfd)->e_ident [EI_OSABI] = -+ elf_elfheader (ibfd)->e_ident [EI_OSABI]; -+ - return TRUE; - } - +--- a/bfd/elf.c 2010-08-10 15:04:55.000000000 +0100 ++++ b/bfd/elf.c 2010-08-10 15:05:42.000000000 +0100 +@@ -1074,6 +1074,14 @@ + + /* Copy object attributes. */ + _bfd_elf_copy_obj_attributes (ibfd, obfd); ++ ++ /* If the input BFD has the OSABI field set and the ++ output BFD does not, then copy the value. */ ++ if (elf_elfheader (ibfd)->e_ident [EI_OSABI] != ELFOSABI_NONE ++ && elf_elfheader (obfd)->e_ident [EI_OSABI] == ELFOSABI_NONE) ++ elf_elfheader (obfd)->e_ident [EI_OSABI] = ++ elf_elfheader (ibfd)->e_ident [EI_OSABI]; ++ + return TRUE; + } + diff --git a/binutils-2.20.51.0.10-ppc64-pie.patch b/binutils-2.20.51.0.10-ppc64-pie.patch index 8862d18..740c071 100644 --- a/binutils-2.20.51.0.10-ppc64-pie.patch +++ b/binutils-2.20.51.0.10-ppc64-pie.patch @@ -1,14 +1,12 @@ -*** ../binutils-2.23.51.0.2.orig/bfd/elf64-ppc.c 2012-09-11 12:13:00.637448573 +0100 ---- bfd/elf64-ppc.c 2012-09-11 12:13:17.922449052 +0100 -*************** ppc64_elf_relocate_section (bfd *output_ -*** 13523,13528 **** ---- 13523,13531 ---- - { - BFD_ASSERT (h->elf.dynindx != -1); - outrel.r_info = ELF64_R_INFO (h->elf.dynindx, r_type); -+ if (h->elf.dynindx == -1 -+ && h->elf.root.type == bfd_link_hash_undefweak) -+ memset (&outrel, 0, sizeof outrel); - } - else - { +--- a/bfd/elf64-ppc.c 2012-09-11 12:13:00.637448573 +0100 ++++ b/bfd/elf64-ppc.c 2012-09-11 12:13:17.922449052 +0100 +@@ -13523,6 +13523,9 @@ + { + BFD_ASSERT (h->elf.dynindx != -1); + outrel.r_info = ELF64_R_INFO (h->elf.dynindx, r_type); ++ if (h->elf.dynindx == -1 ++ && h->elf.root.type == bfd_link_hash_undefweak) ++ memset (&outrel, 0, sizeof outrel); + } + else + { diff --git a/binutils-2.20.51.0.10-sec-merge-emit.patch b/binutils-2.20.51.0.10-sec-merge-emit.patch index 388e143..d099143 100644 --- a/binutils-2.20.51.0.10-sec-merge-emit.patch +++ b/binutils-2.20.51.0.10-sec-merge-emit.patch @@ -1,24 +1,20 @@ -*** ../binutils-2.20.51.0.10.orig/bfd/merge.c 2010-08-20 12:19:33.000000000 +0100 ---- bfd/merge.c 2010-08-20 12:18:01.000000000 +0100 -*************** sec_merge_emit (bfd *abfd, struct sec_me -*** 307,312 **** ---- 307,315 ---- - len = -off & (entry->alignment - 1); - if (len != 0) - { -+ /* We should never have an entry with an alignment -+ greater than the section's alignment. */ -+ BFD_ASSERT (len <= (bfd_size_type) (1 << alignment_power)); - if (bfd_bwrite (pad, len, abfd) != len) - goto err; - off += len; -*************** sec_merge_emit (bfd *abfd, struct sec_me -*** 324,329 **** ---- 327,333 ---- - /* Trailing alignment needed? */ - off = sec->size - off; - if (off != 0 -+ && alignment_power - && bfd_bwrite (pad, off, abfd) != off) - goto err; - +--- a/bfd/merge.c 2010-08-20 12:19:33.000000000 +0100 ++++ b/bfd/merge.c 2010-08-20 12:18:01.000000000 +0100 +@@ -307,6 +307,9 @@ + len = -off & (entry->alignment - 1); + if (len != 0) + { ++ /* We should never have an entry with an alignment ++ greater than the section's alignment. */ ++ BFD_ASSERT (len <= (bfd_size_type) (1 << alignment_power)); + if (bfd_bwrite (pad, len, abfd) != len) + goto err; + off += len; +@@ -324,6 +327,7 @@ + /* Trailing alignment needed? */ + off = sec->size - off; + if (off != 0 ++ && alignment_power + && bfd_bwrite (pad, off, abfd) != off) + goto err; + diff --git a/binutils-2.20.51.0.2-ia64-lib64.patch b/binutils-2.20.51.0.2-ia64-lib64.patch index 5f26b21..c1241ac 100644 --- a/binutils-2.20.51.0.2-ia64-lib64.patch +++ b/binutils-2.20.51.0.2-ia64-lib64.patch @@ -3,8 +3,8 @@ * emulparams/elf64_ia64.sh (LIBPATH_SUFFIX): Use */lib64 paths on ia64-linux if /lib64 tree is present. ---- ../binutils-2.19.50.0.1.orig/ld/emulparams/elf64_ia64.sh 2008-11-21 16:45:00.000000000 +0000 -+++ ld/emulparams/elf64_ia64.sh 2008-11-21 16:55:46.000000000 +0000 +--- a/ld/emulparams/elf64_ia64.sh 2008-11-21 16:45:00.000000000 +0000 ++++ b/ld/emulparams/elf64_ia64.sh 2008-11-21 16:55:46.000000000 +0000 @@ -38,3 +38,13 @@ OTHER_READONLY_SECTIONS="${OTHER_READONL SMALL_DATA_CTOR=" " SMALL_DATA_DTOR=" " diff --git a/binutils-2.20.51.0.2-libtool-lib64.patch b/binutils-2.20.51.0.2-libtool-lib64.patch index 0c61a11..142fc7e 100644 --- a/binutils-2.20.51.0.2-libtool-lib64.patch +++ b/binutils-2.20.51.0.2-libtool-lib64.patch @@ -1,302 +1,236 @@ diff -rcp ../binutils-2.20.51.0.7.original/bfd/configure ./bfd/configure -*** ../binutils-2.20.51.0.7.original/bfd/configure 2010-04-08 14:53:48.000000000 +0100 ---- ./bfd/configure 2010-04-08 14:56:50.000000000 +0100 -*************** fi -*** 10762,10771 **** - # before this can be enabled. - hardcode_into_libs=yes - - # Append ld.so.conf contents to the search path - if test -f /etc/ld.so.conf; then - lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` -! sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" - fi - - # We used to test for /lib/ld.so.1 and disable shared libraries on ---- 10762,10795 ---- - # before this can be enabled. - hardcode_into_libs=yes - -+ # find out which ABI we are using -+ libsuff= -+ case "$host_cpu" in -+ x86_64*|s390*|powerpc*|ppc*|sparc*) -+ echo 'int i;' > conftest.$ac_ext -+ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; then -+ case `/usr/bin/file conftest.$ac_objext` in -+ *64-bit*) -+ libsuff=64 -+ if test x"$sys_lib_search_path_spec" = x"/lib /usr/lib /usr/local/lib"; then -+ sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}" -+ fi -+ sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff}" -+ ;; -+ esac -+ fi -+ rm -rf conftest* -+ ;; -+ esac -+ - # Append ld.so.conf contents to the search path - if test -f /etc/ld.so.conf; then - lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` -! sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra" - fi - - # We used to test for /lib/ld.so.1 and disable shared libraries on +--- a/bfd/configure 2010-04-08 14:53:48.000000000 +0100 ++++ b/bfd/configure 2010-04-08 14:56:50.000000000 +0100 +@@ -10762,10 +10762,34 @@ + # before this can be enabled. + hardcode_into_libs=yes + ++ # find out which ABI we are using ++ libsuff= ++ case "$host_cpu" in ++ x86_64*|s390*|powerpc*|ppc*|sparc*) ++ echo 'int i;' > conftest.$ac_ext ++ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 ++ (eval $ac_compile) 2>&5 ++ ac_status=$? ++ echo "$as_me:$LINENO: \$? = $ac_status" >&5 ++ (exit $ac_status); }; then ++ case `/usr/bin/file conftest.$ac_objext` in ++ *64-bit*) ++ libsuff=64 ++ if test x"$sys_lib_search_path_spec" = x"/lib /usr/lib /usr/local/lib"; then ++ sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}" ++ fi ++ sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff}" ++ ;; ++ esac ++ fi ++ rm -rf conftest* ++ ;; ++ esac ++ + # Append ld.so.conf contents to the search path + if test -f /etc/ld.so.conf; then + lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` +- sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" ++ sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra" + fi + + # We used to test for /lib/ld.so.1 and disable shared libraries on diff -rcp ../binutils-2.20.51.0.7.original/binutils/configure ./binutils/configure -*** ../binutils-2.20.51.0.7.original/binutils/configure 2010-04-08 14:53:45.000000000 +0100 ---- ./binutils/configure 2010-04-08 14:56:21.000000000 +0100 -*************** fi -*** 10560,10569 **** - # before this can be enabled. - hardcode_into_libs=yes - - # Append ld.so.conf contents to the search path - if test -f /etc/ld.so.conf; then - lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` -! sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" - fi - - # We used to test for /lib/ld.so.1 and disable shared libraries on ---- 10560,10593 ---- - # before this can be enabled. - hardcode_into_libs=yes - -+ # find out which ABI we are using -+ libsuff= -+ case "$host_cpu" in -+ x86_64*|s390*|powerpc*|ppc*|sparc*) -+ echo 'int i;' > conftest.$ac_ext -+ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; then -+ case `/usr/bin/file conftest.$ac_objext` in -+ *64-bit*) -+ libsuff=64 -+ if test x"$sys_lib_search_path_spec" = x"/lib /usr/lib /usr/local/lib"; then -+ sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}" -+ fi -+ sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff}" -+ ;; -+ esac -+ fi -+ rm -rf conftest* -+ ;; -+ esac -+ - # Append ld.so.conf contents to the search path - if test -f /etc/ld.so.conf; then - lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` -! sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra" - fi - - # We used to test for /lib/ld.so.1 and disable shared libraries on +--- a/binutils/configure 2010-04-08 14:53:45.000000000 +0100 ++++ b/binutils/configure 2010-04-08 14:56:21.000000000 +0100 +@@ -10560,10 +10560,34 @@ + # before this can be enabled. + hardcode_into_libs=yes + ++ # find out which ABI we are using ++ libsuff= ++ case "$host_cpu" in ++ x86_64*|s390*|powerpc*|ppc*|sparc*) ++ echo 'int i;' > conftest.$ac_ext ++ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 ++ (eval $ac_compile) 2>&5 ++ ac_status=$? ++ echo "$as_me:$LINENO: \$? = $ac_status" >&5 ++ (exit $ac_status); }; then ++ case `/usr/bin/file conftest.$ac_objext` in ++ *64-bit*) ++ libsuff=64 ++ if test x"$sys_lib_search_path_spec" = x"/lib /usr/lib /usr/local/lib"; then ++ sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}" ++ fi ++ sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff}" ++ ;; ++ esac ++ fi ++ rm -rf conftest* ++ ;; ++ esac ++ + # Append ld.so.conf contents to the search path + if test -f /etc/ld.so.conf; then + lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` +- sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" ++ sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra" + fi + + # We used to test for /lib/ld.so.1 and disable shared libraries on diff -rcp ../binutils-2.20.51.0.7.original/gas/configure ./gas/configure -*** ../binutils-2.20.51.0.7.original/gas/configure 2010-04-08 14:53:47.000000000 +0100 ---- ./gas/configure 2010-04-08 14:57:24.000000000 +0100 -*************** fi -*** 10547,10556 **** - # before this can be enabled. - hardcode_into_libs=yes - - # Append ld.so.conf contents to the search path - if test -f /etc/ld.so.conf; then - lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` -! sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" - fi - - # We used to test for /lib/ld.so.1 and disable shared libraries on ---- 10547,10580 ---- - # before this can be enabled. - hardcode_into_libs=yes - -+ # find out which ABI we are using -+ libsuff= -+ case "$host_cpu" in -+ x86_64*|s390*|powerpc*|ppc*|sparc*) -+ echo 'int i;' > conftest.$ac_ext -+ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; then -+ case `/usr/bin/file conftest.$ac_objext` in -+ *64-bit*) -+ libsuff=64 -+ if test x"$sys_lib_search_path_spec" = x"/lib /usr/lib /usr/local/lib"; then -+ sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}" -+ fi -+ sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff}" -+ ;; -+ esac -+ fi -+ rm -rf conftest* -+ ;; -+ esac -+ - # Append ld.so.conf contents to the search path - if test -f /etc/ld.so.conf; then - lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` -! sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra" - fi - - # We used to test for /lib/ld.so.1 and disable shared libraries on +--- a/gas/configure 2010-04-08 14:53:47.000000000 +0100 ++++ b/gas/configure 2010-04-08 14:57:24.000000000 +0100 +@@ -10547,10 +10547,34 @@ + # before this can be enabled. + hardcode_into_libs=yes + ++ # find out which ABI we are using ++ libsuff= ++ case "$host_cpu" in ++ x86_64*|s390*|powerpc*|ppc*|sparc*) ++ echo 'int i;' > conftest.$ac_ext ++ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 ++ (eval $ac_compile) 2>&5 ++ ac_status=$? ++ echo "$as_me:$LINENO: \$? = $ac_status" >&5 ++ (exit $ac_status); }; then ++ case `/usr/bin/file conftest.$ac_objext` in ++ *64-bit*) ++ libsuff=64 ++ if test x"$sys_lib_search_path_spec" = x"/lib /usr/lib /usr/local/lib"; then ++ sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}" ++ fi ++ sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff}" ++ ;; ++ esac ++ fi ++ rm -rf conftest* ++ ;; ++ esac ++ + # Append ld.so.conf contents to the search path + if test -f /etc/ld.so.conf; then + lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` +- sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" ++ sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra" + fi + + # We used to test for /lib/ld.so.1 and disable shared libraries on diff -rcp ../binutils-2.20.51.0.7.original/gprof/configure ./gprof/configure -*** ../binutils-2.20.51.0.7.original/gprof/configure 2010-04-08 14:53:45.000000000 +0100 ---- ./gprof/configure 2010-04-08 14:57:50.000000000 +0100 -*************** fi -*** 10485,10494 **** - # before this can be enabled. - hardcode_into_libs=yes - - # Append ld.so.conf contents to the search path - if test -f /etc/ld.so.conf; then - lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` -! sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" - fi - - # We used to test for /lib/ld.so.1 and disable shared libraries on ---- 10485,10518 ---- - # before this can be enabled. - hardcode_into_libs=yes - -+ # find out which ABI we are using -+ libsuff= -+ case "$host_cpu" in -+ x86_64*|s390*|powerpc*|ppc*|sparc*) -+ echo 'int i;' > conftest.$ac_ext -+ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; then -+ case `/usr/bin/file conftest.$ac_objext` in -+ *64-bit*) -+ libsuff=64 -+ if test x"$sys_lib_search_path_spec" = x"/lib /usr/lib /usr/local/lib"; then -+ sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}" -+ fi -+ sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff}" -+ ;; -+ esac -+ fi -+ rm -rf conftest* -+ ;; -+ esac -+ - # Append ld.so.conf contents to the search path - if test -f /etc/ld.so.conf; then - lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` -! sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra" - fi - - # We used to test for /lib/ld.so.1 and disable shared libraries on +--- a/gprof/configure 2010-04-08 14:53:45.000000000 +0100 ++++ b/gprof/configure 2010-04-08 14:57:50.000000000 +0100 +@@ -10485,10 +10485,34 @@ + # before this can be enabled. + hardcode_into_libs=yes + ++ # find out which ABI we are using ++ libsuff= ++ case "$host_cpu" in ++ x86_64*|s390*|powerpc*|ppc*|sparc*) ++ echo 'int i;' > conftest.$ac_ext ++ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 ++ (eval $ac_compile) 2>&5 ++ ac_status=$? ++ echo "$as_me:$LINENO: \$? = $ac_status" >&5 ++ (exit $ac_status); }; then ++ case `/usr/bin/file conftest.$ac_objext` in ++ *64-bit*) ++ libsuff=64 ++ if test x"$sys_lib_search_path_spec" = x"/lib /usr/lib /usr/local/lib"; then ++ sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}" ++ fi ++ sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff}" ++ ;; ++ esac ++ fi ++ rm -rf conftest* ++ ;; ++ esac ++ + # Append ld.so.conf contents to the search path + if test -f /etc/ld.so.conf; then + lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` +- sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" ++ sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra" + fi + + # We used to test for /lib/ld.so.1 and disable shared libraries on diff -rcp ../binutils-2.20.51.0.7.original/ld/configure ./ld/configure -*** ../binutils-2.20.51.0.7.original/ld/configure 2010-04-08 14:53:44.000000000 +0100 ---- ./ld/configure 2010-04-08 14:58:21.000000000 +0100 -*************** fi -*** 10966,10975 **** - # before this can be enabled. - hardcode_into_libs=yes - - # Append ld.so.conf contents to the search path - if test -f /etc/ld.so.conf; then - lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` -! sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" - fi - - # We used to test for /lib/ld.so.1 and disable shared libraries on ---- 10966,10999 ---- - # before this can be enabled. - hardcode_into_libs=yes - -+ # find out which ABI we are using -+ libsuff= -+ case "$host_cpu" in -+ x86_64*|s390*|powerpc*|ppc*|sparc*) -+ echo 'int i;' > conftest.$ac_ext -+ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; then -+ case `/usr/bin/file conftest.$ac_objext` in -+ *64-bit*) -+ libsuff=64 -+ if test x"$sys_lib_search_path_spec" = x"/lib /usr/lib /usr/local/lib"; then -+ sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}" -+ fi -+ sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff}" -+ ;; -+ esac -+ fi -+ rm -rf conftest* -+ ;; -+ esac -+ - # Append ld.so.conf contents to the search path - if test -f /etc/ld.so.conf; then - lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` -! sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra" - fi - - # We used to test for /lib/ld.so.1 and disable shared libraries on +--- a/ld/configure 2010-04-08 14:53:44.000000000 +0100 ++++ b/ld/configure 2010-04-08 14:58:21.000000000 +0100 +@@ -10966,10 +10966,34 @@ + # before this can be enabled. + hardcode_into_libs=yes + ++ # find out which ABI we are using ++ libsuff= ++ case "$host_cpu" in ++ x86_64*|s390*|powerpc*|ppc*|sparc*) ++ echo 'int i;' > conftest.$ac_ext ++ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 ++ (eval $ac_compile) 2>&5 ++ ac_status=$? ++ echo "$as_me:$LINENO: \$? = $ac_status" >&5 ++ (exit $ac_status); }; then ++ case `/usr/bin/file conftest.$ac_objext` in ++ *64-bit*) ++ libsuff=64 ++ if test x"$sys_lib_search_path_spec" = x"/lib /usr/lib /usr/local/lib"; then ++ sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}" ++ fi ++ sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff}" ++ ;; ++ esac ++ fi ++ rm -rf conftest* ++ ;; ++ esac ++ + # Append ld.so.conf contents to the search path + if test -f /etc/ld.so.conf; then + lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` +- sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" ++ sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra" + fi + + # We used to test for /lib/ld.so.1 and disable shared libraries on Only in .: .#libtool.m4 Only in .: #libtool.m4# diff -rcp ../binutils-2.20.51.0.7.original/opcodes/configure ./opcodes/configure -*** ../binutils-2.20.51.0.7.original/opcodes/configure 2010-04-08 14:53:45.000000000 +0100 ---- ./opcodes/configure 2010-04-08 14:59:10.000000000 +0100 -*************** fi -*** 10496,10505 **** - # before this can be enabled. - hardcode_into_libs=yes - - # Append ld.so.conf contents to the search path - if test -f /etc/ld.so.conf; then - lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` -! sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" - fi - - # We used to test for /lib/ld.so.1 and disable shared libraries on ---- 10496,10529 ---- - # before this can be enabled. - hardcode_into_libs=yes - -+ # find out which ABI we are using -+ libsuff= -+ case "$host_cpu" in -+ x86_64*|s390*|powerpc*|ppc*|sparc*) -+ echo 'int i;' > conftest.$ac_ext -+ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; then -+ case `/usr/bin/file conftest.$ac_objext` in -+ *64-bit*) -+ libsuff=64 -+ if test x"$sys_lib_search_path_spec" = x"/lib /usr/lib /usr/local/lib"; then -+ sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}" -+ fi -+ sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff}" -+ ;; -+ esac -+ fi -+ rm -rf conftest* -+ ;; -+ esac -+ - # Append ld.so.conf contents to the search path - if test -f /etc/ld.so.conf; then - lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` -! sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra" - fi - - # We used to test for /lib/ld.so.1 and disable shared libraries on +--- a/opcodes/configure 2010-04-08 14:53:45.000000000 +0100 ++++ b/opcodes/configure 2010-04-08 14:59:10.000000000 +0100 +@@ -10496,10 +10496,34 @@ + # before this can be enabled. + hardcode_into_libs=yes + ++ # find out which ABI we are using ++ libsuff= ++ case "$host_cpu" in ++ x86_64*|s390*|powerpc*|ppc*|sparc*) ++ echo 'int i;' > conftest.$ac_ext ++ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 ++ (eval $ac_compile) 2>&5 ++ ac_status=$? ++ echo "$as_me:$LINENO: \$? = $ac_status" >&5 ++ (exit $ac_status); }; then ++ case `/usr/bin/file conftest.$ac_objext` in ++ *64-bit*) ++ libsuff=64 ++ if test x"$sys_lib_search_path_spec" = x"/lib /usr/lib /usr/local/lib"; then ++ sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}" ++ fi ++ sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff}" ++ ;; ++ esac ++ fi ++ rm -rf conftest* ++ ;; ++ esac ++ + # Append ld.so.conf contents to the search path + if test -f /etc/ld.so.conf; then + lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` +- sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" ++ sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra" + fi + + # We used to test for /lib/ld.so.1 and disable shared libraries on diff --git a/binutils-2.20.51.0.2-set-long-long.patch b/binutils-2.20.51.0.2-set-long-long.patch deleted file mode 100644 index 667a3cc..0000000 --- a/binutils-2.20.51.0.2-set-long-long.patch +++ /dev/null @@ -1,60 +0,0 @@ -diff -rcp ../binutils-2.20.51.0.7.original/bfd/configure ./bfd/configure -*** ../binutils-2.20.51.0.7.original/bfd/configure 2010-04-08 15:23:58.000000000 +0100 ---- ./bfd/configure 2010-04-08 15:24:06.000000000 +0100 -*************** if test "x${ac_cv_sizeof_long}" = "x8"; -*** 12819,12829 **** - BFD_HOST_64BIT_LONG=1 - test -n "${HOST_64BIT_TYPE}" || HOST_64BIT_TYPE="long" - test -n "${HOST_U_64BIT_TYPE}" || HOST_U_64BIT_TYPE="unsigned long" -! elif test "x${ac_cv_sizeof_long_long}" = "x8"; then - BFD_HOST_64BIT_LONG_LONG=1 - test -n "${HOST_64BIT_TYPE}" || HOST_64BIT_TYPE="long long" - test -n "${HOST_U_64BIT_TYPE}" || HOST_U_64BIT_TYPE="unsigned long long" -! if test "x${ac_cv_sizeof_void_p}" = "x8"; then - BFD_HOSTPTR_T="unsigned long long" - fi - fi ---- 12819,12831 ---- - BFD_HOST_64BIT_LONG=1 - test -n "${HOST_64BIT_TYPE}" || HOST_64BIT_TYPE="long" - test -n "${HOST_U_64BIT_TYPE}" || HOST_U_64BIT_TYPE="unsigned long" -! fi -! if test "x${ac_cv_sizeof_long_long}" = "x8"; then - BFD_HOST_64BIT_LONG_LONG=1 - test -n "${HOST_64BIT_TYPE}" || HOST_64BIT_TYPE="long long" - test -n "${HOST_U_64BIT_TYPE}" || HOST_U_64BIT_TYPE="unsigned long long" -! if test "x${ac_cv_sizeof_void_p}" = "x8" \ -! -a "x${ac_cv_sizeof_long}" != "x8"; then - BFD_HOSTPTR_T="unsigned long long" - fi - fi -diff -rcp ../binutils-2.20.51.0.7.original/bfd/configure.in ./bfd/configure.in -*** ../binutils-2.20.51.0.7.original/bfd/configure.in 2010-04-08 15:23:58.000000000 +0100 ---- ./bfd/configure.in 2010-04-08 15:24:06.000000000 +0100 -*************** if test "x${ac_cv_sizeof_long}" = "x8"; -*** 153,163 **** - BFD_HOST_64BIT_LONG=1 - test -n "${HOST_64BIT_TYPE}" || HOST_64BIT_TYPE="long" - test -n "${HOST_U_64BIT_TYPE}" || HOST_U_64BIT_TYPE="unsigned long" -! elif test "x${ac_cv_sizeof_long_long}" = "x8"; then - BFD_HOST_64BIT_LONG_LONG=1 - test -n "${HOST_64BIT_TYPE}" || HOST_64BIT_TYPE="long long" - test -n "${HOST_U_64BIT_TYPE}" || HOST_U_64BIT_TYPE="unsigned long long" -! if test "x${ac_cv_sizeof_void_p}" = "x8"; then - BFD_HOSTPTR_T="unsigned long long" - fi - fi ---- 153,165 ---- - BFD_HOST_64BIT_LONG=1 - test -n "${HOST_64BIT_TYPE}" || HOST_64BIT_TYPE="long" - test -n "${HOST_U_64BIT_TYPE}" || HOST_U_64BIT_TYPE="unsigned long" -! fi -! if test "x${ac_cv_sizeof_long_long}" = "x8"; then - BFD_HOST_64BIT_LONG_LONG=1 - test -n "${HOST_64BIT_TYPE}" || HOST_64BIT_TYPE="long long" - test -n "${HOST_U_64BIT_TYPE}" || HOST_U_64BIT_TYPE="unsigned long long" -! if test "x${ac_cv_sizeof_void_p}" = "x8" \ -! -a "x${ac_cv_sizeof_long}" != "x8"; then - BFD_HOSTPTR_T="unsigned long long" - fi - fi diff --git a/binutils-2.20.51.0.2-version.patch b/binutils-2.20.51.0.2-version.patch deleted file mode 100644 index 9f728df..0000000 --- a/binutils-2.20.51.0.2-version.patch +++ /dev/null @@ -1,61 +0,0 @@ -diff -rcp ../binutils-2.20.51.0.7.original/bfd/Makefile.am ./bfd/Makefile.am -*** ../binutils-2.20.51.0.7.original/bfd/Makefile.am 2010-04-08 15:07:55.000000000 +0100 ---- ./bfd/Makefile.am 2010-04-08 15:23:14.000000000 +0100 -*************** bfdver.h: $(srcdir)/version.h $(srcdir)/ -*** 953,964 **** - report_bugs_to="\"$(REPORT_BUGS_TO)\"" ;\ - if test "x$(RELEASE)" = x ; then \ - bfd_version_date=`sed -n -e 's/.*DATE //p' < $(srcdir)/version.h` ;\ -! bfd_version_string="\"$(VERSION).$${bfd_version_date}\"" ;\ -! bfd_soversion="$(VERSION).$${bfd_version_date}" ;\ - fi ;\ - sed -e "s,@bfd_version@,$$bfd_version," \ - -e "s,@bfd_version_string@,$$bfd_version_string," \ -! -e "s,@bfd_version_package@,$$bfd_version_package," \ - -e "s,@report_bugs_to@,$$report_bugs_to," \ - < $(srcdir)/version.h > $@; \ - echo "$${bfd_soversion}" > libtool-soversion ---- 953,964 ---- - report_bugs_to="\"$(REPORT_BUGS_TO)\"" ;\ - if test "x$(RELEASE)" = x ; then \ - bfd_version_date=`sed -n -e 's/.*DATE //p' < $(srcdir)/version.h` ;\ -! bfd_version_string="\"$(VERSION)-%{release} $${bfd_version_date}\"" ;\ -! bfd_soversion="$(VERSION)-%{release}" ;\ - fi ;\ - sed -e "s,@bfd_version@,$$bfd_version," \ - -e "s,@bfd_version_string@,$$bfd_version_string," \ -! -e "s,@bfd_version_package@,\"version \"," \ - -e "s,@report_bugs_to@,$$report_bugs_to," \ - < $(srcdir)/version.h > $@; \ - echo "$${bfd_soversion}" > libtool-soversion -diff -rcp ../binutils-2.20.51.0.7.original/bfd/Makefile.in ./bfd/Makefile.in -*** ../binutils-2.20.51.0.7.original/bfd/Makefile.in 2010-04-08 15:07:55.000000000 +0100 ---- ./bfd/Makefile.in 2010-04-08 15:23:14.000000000 +0100 -*************** bfdver.h: $(srcdir)/version.h $(srcdir)/ -*** 1982,1993 **** - report_bugs_to="\"$(REPORT_BUGS_TO)\"" ;\ - if test "x$(RELEASE)" = x ; then \ - bfd_version_date=`sed -n -e 's/.*DATE //p' < $(srcdir)/version.h` ;\ -! bfd_version_string="\"$(VERSION).$${bfd_version_date}\"" ;\ -! bfd_soversion="$(VERSION).$${bfd_version_date}" ;\ - fi ;\ - sed -e "s,@bfd_version@,$$bfd_version," \ - -e "s,@bfd_version_string@,$$bfd_version_string," \ -! -e "s,@bfd_version_package@,$$bfd_version_package," \ - -e "s,@report_bugs_to@,$$report_bugs_to," \ - < $(srcdir)/version.h > $@; \ - echo "$${bfd_soversion}" > libtool-soversion ---- 1982,1993 ---- - report_bugs_to="\"$(REPORT_BUGS_TO)\"" ;\ - if test "x$(RELEASE)" = x ; then \ - bfd_version_date=`sed -n -e 's/.*DATE //p' < $(srcdir)/version.h` ;\ -! bfd_version_string="\"$(VERSION)-%{release} $${bfd_version_date}\"" ;\ -! bfd_soversion="$(VERSION)-%{release}" ;\ - fi ;\ - sed -e "s,@bfd_version@,$$bfd_version," \ - -e "s,@bfd_version_string@,$$bfd_version_string," \ -! -e "s,@bfd_version_package@,\"version \"," \ - -e "s,@report_bugs_to@,$$report_bugs_to," \ - < $(srcdir)/version.h > $@; \ - echo "$${bfd_soversion}" > libtool-soversion - diff --git a/binutils-2.22.52.0.1-export-demangle.h.patch b/binutils-2.22.52.0.1-export-demangle.h.patch index 9a9f3fa..cbd7eed 100644 --- a/binutils-2.22.52.0.1-export-demangle.h.patch +++ b/binutils-2.22.52.0.1-export-demangle.h.patch @@ -1,57 +1,33 @@ -*** ../binutils-2.22.52.0.1.orig/bfd/Makefile.am 2012-03-06 14:00:33.229957572 +0000 ---- bfd/Makefile.am 2012-04-27 16:46:05.410974817 +0100 -*************** if INSTALL_LIBBFD -*** 18,24 **** - bfdlibdir = @bfdlibdir@ - bfdincludedir = @bfdincludedir@ - bfdlib_LTLIBRARIES = libbfd.la -! bfdinclude_HEADERS = $(BFD_H) $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h $(INCDIR)/bfdlink.h - else !INSTALL_LIBBFD - # Empty these so that the respective installation directories will not be created. - bfdlibdir = ---- 18,24 ---- - bfdlibdir = @bfdlibdir@ - bfdincludedir = @bfdincludedir@ - bfdlib_LTLIBRARIES = libbfd.la -! bfdinclude_HEADERS = $(BFD_H) $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h $(INCDIR)/bfdlink.h $(INCDIR)/demangle.h - else !INSTALL_LIBBFD - # Empty these so that the respective installation directories will not be created. - bfdlibdir = -*** ../binutils-2.22.52.0.1.orig/bfd/Makefile.in 2012-03-06 14:00:32.952957600 +0000 ---- bfd/Makefile.in 2012-04-27 16:46:19.718975214 +0100 -*************** RECURSIVE_TARGETS = all-recursive check- -*** 138,144 **** - installcheck-recursive installdirs-recursive pdf-recursive \ - ps-recursive uninstall-recursive - am__bfdinclude_HEADERS_DIST = $(INCDIR)/plugin-api.h bfd.h \ -! $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h $(INCDIR)/bfdlink.h - HEADERS = $(bfdinclude_HEADERS) - RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ - distclean-recursive maintainer-clean-recursive ---- 138,145 ---- - installcheck-recursive installdirs-recursive pdf-recursive \ - ps-recursive uninstall-recursive - am__bfdinclude_HEADERS_DIST = $(INCDIR)/plugin-api.h bfd.h \ -! $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h $(INCDIR)/bfdlink.h \ -! $(INCDIR)/demangle.h - HEADERS = $(bfdinclude_HEADERS) - RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ - distclean-recursive maintainer-clean-recursive -*************** libbfd_la_LDFLAGS = $(am__append_1) -rel -*** 331,337 **** - @INSTALL_LIBBFD_FALSE@bfdinclude_HEADERS = $(am__append_2) - @INSTALL_LIBBFD_TRUE@bfdinclude_HEADERS = $(BFD_H) \ - @INSTALL_LIBBFD_TRUE@ $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h \ -! @INSTALL_LIBBFD_TRUE@ $(INCDIR)/bfdlink.h $(am__append_2) - @INSTALL_LIBBFD_FALSE@rpath_bfdlibdir = @bfdlibdir@ - @INSTALL_LIBBFD_FALSE@noinst_LTLIBRARIES = libbfd.la - AM_CFLAGS = $(WARN_CFLAGS) ---- 332,339 ---- - @INSTALL_LIBBFD_FALSE@bfdinclude_HEADERS = $(am__append_2) - @INSTALL_LIBBFD_TRUE@bfdinclude_HEADERS = $(BFD_H) \ - @INSTALL_LIBBFD_TRUE@ $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h \ -! @INSTALL_LIBBFD_TRUE@ $(INCDIR)/bfdlink.h $(INCDIR)/demangle.h \ -! @INSTALL_LIBBFD_TRUE@ $(am__append_2) - @INSTALL_LIBBFD_FALSE@rpath_bfdlibdir = @bfdlibdir@ - @INSTALL_LIBBFD_FALSE@noinst_LTLIBRARIES = libbfd.la - AM_CFLAGS = $(WARN_CFLAGS) +--- a/bfd/Makefile.am 2012-03-06 14:00:33.229957572 +0000 ++++ b/bfd/Makefile.am 2012-04-27 16:46:05.410974817 +0100 +@@ -18,7 +18,7 @@ + bfdlibdir = @bfdlibdir@ + bfdincludedir = @bfdincludedir@ + bfdlib_LTLIBRARIES = libbfd.la +-bfdinclude_HEADERS = $(BFD_H) $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h $(INCDIR)/bfdlink.h ++bfdinclude_HEADERS = $(BFD_H) $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h $(INCDIR)/bfdlink.h $(INCDIR)/demangle.h + else !INSTALL_LIBBFD + # Empty these so that the respective installation directories will not be created. + bfdlibdir = +--- a/bfd/Makefile.in 2012-03-06 14:00:32.952957600 +0000 ++++ b/bfd/Makefile.in 2012-04-27 16:46:19.718975214 +0100 +@@ -138,7 +138,8 @@ + installcheck-recursive installdirs-recursive pdf-recursive \ + ps-recursive uninstall-recursive + am__bfdinclude_HEADERS_DIST = $(INCDIR)/plugin-api.h bfd.h \ +- $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h $(INCDIR)/bfdlink.h ++ $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h $(INCDIR)/bfdlink.h \ ++ $(INCDIR)/demangle.h + HEADERS = $(bfdinclude_HEADERS) + RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ + distclean-recursive maintainer-clean-recursive +@@ -331,7 +332,8 @@ + @INSTALL_LIBBFD_FALSE@bfdinclude_HEADERS = $(am__append_2) + @INSTALL_LIBBFD_TRUE@bfdinclude_HEADERS = $(BFD_H) \ + @INSTALL_LIBBFD_TRUE@ $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h \ +-@INSTALL_LIBBFD_TRUE@ $(INCDIR)/bfdlink.h $(am__append_2) ++@INSTALL_LIBBFD_TRUE@ $(INCDIR)/bfdlink.h $(INCDIR)/demangle.h \ ++@INSTALL_LIBBFD_TRUE@ $(am__append_2) + @INSTALL_LIBBFD_FALSE@rpath_bfdlibdir = @bfdlibdir@ + @INSTALL_LIBBFD_FALSE@noinst_LTLIBRARIES = libbfd.la + AM_CFLAGS = $(WARN_CFLAGS) diff --git a/binutils-2.22.52.0.1-relro-on-by-default.patch b/binutils-2.22.52.0.1-relro-on-by-default.patch index 7028339..177b48a 100644 --- a/binutils-2.22.52.0.1-relro-on-by-default.patch +++ b/binutils-2.22.52.0.1-relro-on-by-default.patch @@ -1,92 +1,58 @@ -diff -cpr ../binutils-2.22.52.0.1.orig/ld/testsuite/config/default.exp ld/testsuite/config/default.exp -*** ../binutils-2.22.52.0.1.orig/ld/testsuite/config/default.exp 2012-03-06 14:00:31.141957656 +0000 ---- ld/testsuite/config/default.exp 2012-03-06 14:09:33.492940503 +0000 -*************** -*** 23,29 **** - # - - if ![info exists ld] then { -! set ld [findfile $base_dir/ld-new $base_dir/ld-new [transform ld]] - } - - if ![info exists as] then { ---- 23,29 ---- - # - - if ![info exists ld] then { -! set ld "[findfile $base_dir/ld-new $base_dir/ld-new [transform ld]] -znorelro" - } - - if ![info exists as] then { -*************** if {![file isdirectory tmpdir/ld]} then -*** 69,75 **** - catch "exec ln -s ../../ld-new tmpdir/ld/ld" status - catch "exec ln -s ld tmpdir/ld/collect-ld" status - } -! set gcc_ld_flag "-B[pwd]/tmpdir/ld/" - - # load the linker path - if {[file exists tmpdir/libpath.exp]} { ---- 69,75 ---- - catch "exec ln -s ../../ld-new tmpdir/ld/ld" status - catch "exec ln -s ld tmpdir/ld/collect-ld" status - } -! set gcc_ld_flag "-B[pwd]/tmpdir/ld/ -Wl,-z,norelro" - - # load the linker path - if {[file exists tmpdir/libpath.exp]} { -*************** if ![info exists READELFFLAGS] then { -*** 279,285 **** - } - - if ![info exists LD] then { -! set LD [findfile $base_dir/ld-new ./ld-new [transform ld]] - } - - if ![info exists LDFLAGS] then { ---- 279,285 ---- - } - - if ![info exists LD] then { -! set LD "[findfile $base_dir/ld-new ./ld-new [transform ld]] -znorelro" - } - - if ![info exists LDFLAGS] then { +diff -upr ../binutils-2.22.52.0.1.orig/ld/testsuite/config/default.exp ld/testsuite/config/default.exp +--- a/ld/testsuite/config/default.exp 2012-03-06 14:00:31.141957656 +0000 ++++ b/ld/testsuite/config/default.exp 2012-03-06 14:09:33.492940503 +0000 +@@ -23,7 +23,7 @@ + # + + if ![info exists ld] then { +- set ld [findfile $base_dir/ld-new $base_dir/ld-new [transform ld]] ++ set ld "[findfile $base_dir/ld-new $base_dir/ld-new [transform ld]] -znorelro" + } + + if ![info exists as] then { +@@ -60,7 +60,7 @@ if {![file isdirectory tmpdir/ld]} then + catch "exec ln -s ld tmpdir/ld/collect-ld" status + catch "exec ln -s ../../../gas/as-new tmpdir/ld/as" status + } +-set gcc_B_opt "-B[pwd]/tmpdir/ld/" ++set gcc_B_opt "-B[pwd]/tmpdir/ld/ -Wl,-z,norelro" + + # load the linker path + set ld_L_opt "" +@@ -279,7 +279,7 @@ + } + + if ![info exists LD] then { +- set LD [findfile $base_dir/ld-new ./ld-new [transform ld]] ++ set LD "[findfile $base_dir/ld-new ./ld-new [transform ld]] -znorelro" + } + + if ![info exists LDFLAGS] then { diff -cpr ../binutils-2.22.52.0.1.orig/ld/testsuite/ld-bootstrap/bootstrap.exp ld/testsuite/ld-bootstrap/bootstrap.exp -*** ../binutils-2.22.52.0.1.orig/ld/testsuite/ld-bootstrap/bootstrap.exp 2012-03-06 14:00:30.503957676 +0000 ---- ld/testsuite/ld-bootstrap/bootstrap.exp 2012-03-06 15:03:33.949837926 +0000 -*************** foreach flags {"" "strip" "--static" "-- -*** 71,77 **** - - # This test can only be run if we have the ld build directory, - # since we need the object files. -! if {$ld != "$objdir/ld-new"} { - untested $testname - continue - } ---- 71,83 ---- - - # This test can only be run if we have the ld build directory, - # since we need the object files. -! set ldexe $ld -! set ldparm [string first " " $ld] -! if { $ldparm > 0 } then { -! set ldparm [expr $ldparm - 1] -! set ldexe [string range $ld 0 $ldparm] -! } -! if {$ldexe != "$objdir/ld-new"} { - untested $testname - continue - } -*** ../binutils-2.23.2.orig/ld/emultempl/elf32.em 2013-04-24 11:06:47.777176887 +0100 ---- ld/emultempl/elf32.em 2013-04-24 11:07:22.405177847 +0100 -*************** gld${EMULATION_NAME}_before_parse (void) -*** 105,110 **** ---- 105,111 ---- - input_flags.dynamic = ${DYNAMIC_LINK-TRUE}; - config.has_shared = `if test -n "$GENERATE_SHLIB_SCRIPT" ; then echo TRUE ; else echo FALSE ; fi`; - config.separate_code = `if test "x${SEPARATE_CODE}" = xyes ; then echo TRUE ; else echo FALSE ; fi`; -+ link_info.relro = TRUE; - } - - EOF +--- a/ld/testsuite/ld-bootstrap/bootstrap.exp 2012-03-06 14:00:30.503957676 +0000 ++++ b/ld/testsuite/ld-bootstrap/bootstrap.exp 2012-03-06 15:03:33.949837926 +0000 +@@ -71,7 +71,13 @@ + + # This test can only be run if we have the ld build directory, + # since we need the object files. +- if {$ld != "$objdir/ld-new"} { ++ set ldexe $ld ++ set ldparm [string first " " $ld] ++ if { $ldparm > 0 } then { ++ set ldparm [expr $ldparm - 1] ++ set ldexe [string range $ld 0 $ldparm] ++ } ++ if {$ldexe != "$objdir/ld-new"} { + untested $testname + continue + } +--- a/ld/emultempl/elf32.em 2013-04-24 11:06:47.777176887 +0100 ++++ b/ld/emultempl/elf32.em 2013-04-24 11:07:22.405177847 +0100 +@@ -105,6 +105,7 @@ + input_flags.dynamic = ${DYNAMIC_LINK-TRUE}; + config.has_shared = `if test -n "$GENERATE_SHLIB_SCRIPT" ; then echo TRUE ; else echo FALSE ; fi`; + config.separate_code = `if test "x${SEPARATE_CODE}" = xyes ; then echo TRUE ; else echo FALSE ; fi`; ++ link_info.relro = TRUE; + } + + EOF diff --git a/binutils-2.22.52.0.4-no-config-h-check.patch b/binutils-2.22.52.0.4-no-config-h-check.patch index 2fc32e3..c89195a 100644 --- a/binutils-2.22.52.0.4-no-config-h-check.patch +++ b/binutils-2.22.52.0.4-no-config-h-check.patch @@ -1,32 +1,28 @@ -*** ../binutils-2.22.52.0.4.orig/bfd/bfd-in.h 2012-08-02 10:56:34.561769686 +0100 ---- bfd/bfd-in.h 2012-08-02 11:13:27.134797755 +0100 -*************** -*** 25,35 **** - #ifndef __BFD_H_SEEN__ - #define __BFD_H_SEEN__ - -- /* PR 14072: Ensure that config.h is included first. */ -- #if !defined PACKAGE && !defined PACKAGE_VERSION -- #error config.h must be included before this header -- #endif -- - #ifdef __cplusplus - extern "C" { - #endif ---- 25,30 ---- -*** ../binutils-2.22.52.0.4.orig/bfd/bfd-in2.h 2012-08-02 10:56:34.349769680 +0100 ---- bfd/bfd-in2.h 2012-08-02 11:13:40.015798113 +0100 -*************** -*** 32,42 **** - #ifndef __BFD_H_SEEN__ - #define __BFD_H_SEEN__ - -- /* PR 14072: Ensure that config.h is included first. */ -- #if !defined PACKAGE && !defined PACKAGE_VERSION -- #error config.h must be included before this header -- #endif -- - #ifdef __cplusplus - extern "C" { - #endif ---- 32,37 ---- +--- a/bfd/bfd-in.h 2012-08-02 10:56:34.561769686 +0100 ++++ b/bfd/bfd-in.h 2012-08-02 11:13:27.134797755 +0100 +@@ -25,11 +25,6 @@ + #ifndef __BFD_H_SEEN__ + #define __BFD_H_SEEN__ + +-/* PR 14072: Ensure that config.h is included first. */ +-#if !defined PACKAGE && !defined PACKAGE_VERSION +-#error config.h must be included before this header +-#endif +- + #ifdef __cplusplus + extern "C" { + #endif +--- a/bfd/bfd-in2.h 2012-08-02 10:56:34.349769680 +0100 ++++ b/bfd/bfd-in2.h 2012-08-02 11:13:40.015798113 +0100 +@@ -32,11 +32,6 @@ + #ifndef __BFD_H_SEEN__ + #define __BFD_H_SEEN__ + +-/* PR 14072: Ensure that config.h is included first. */ +-#if !defined PACKAGE && !defined PACKAGE_VERSION +-#error config.h must be included before this header +-#endif +- + #ifdef __cplusplus + extern "C" { + #endif diff --git a/binutils-2.23.2-aarch64-em.patch b/binutils-2.23.2-aarch64-em.patch index f4aae4c..73043da 100644 --- a/binutils-2.23.2-aarch64-em.patch +++ b/binutils-2.23.2-aarch64-em.patch @@ -1,47 +1,26 @@ -*** ../binutils-2.23.2.orig/ld/emultempl/aarch64elf.em 2013-06-05 09:46:17.499278813 +0100 ---- ld/emultempl/aarch64elf.em 2013-06-05 09:54:36.981292659 +0100 -*************** gld${EMULATION_NAME}_after_allocation (v -*** 264,270 **** - } - - static void -! gld${EMULATION_NAME}_finish (void) - { - if (! link_info.relocatable) - { ---- 264,270 ---- - } - - static void -! gld${EMULATION_NAME}_local_finish (void) - { - if (! link_info.relocatable) - { -*************** gld${EMULATION_NAME}_finish (void) -*** 276,282 **** - } - } - -! finish_default (); - } - - /* This is a convenient point to tell BFD about target specific flags. ---- 276,282 ---- - } - } - -! gld${EMULATION_NAME}_finish (); - } - - /* This is a convenient point to tell BFD about target specific flags. -*************** LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS= -*** 413,416 **** - LDEMUL_BEFORE_PARSE=gld"${EMULATION_NAME}"_before_parse - - # Call the extra arm-elf function -! LDEMUL_FINISH=gld${EMULATION_NAME}_finish ---- 413,416 ---- - LDEMUL_BEFORE_PARSE=gld"${EMULATION_NAME}"_before_parse - - # Call the extra arm-elf function -! LDEMUL_FINISH=gld${EMULATION_NAME}_local_finish +--- a/ld/emultempl/aarch64elf.em 2013-06-05 09:46:17.499278813 +0100 ++++ b/ld/emultempl/aarch64elf.em 2013-06-05 09:54:36.981292659 +0100 +@@ -264,7 +264,7 @@ + } + + static void +-gld${EMULATION_NAME}_finish (void) ++gld${EMULATION_NAME}_local_finish (void) + { + if (! link_info.relocatable) + { +@@ -276,7 +276,7 @@ + } + } + +- finish_default (); ++ gld${EMULATION_NAME}_finish (); + } + + /* This is a convenient point to tell BFD about target specific flags. +@@ -413,4 +413,4 @@ + LDEMUL_BEFORE_PARSE=gld"${EMULATION_NAME}"_before_parse + + # Call the extra arm-elf function +-LDEMUL_FINISH=gld${EMULATION_NAME}_finish ++LDEMUL_FINISH=gld${EMULATION_NAME}_local_finish diff --git a/binutils-2.23.2-kernel-ld-r.patch b/binutils-2.23.2-kernel-ld-r.patch index 2ba70c5..5fc5d41 100644 --- a/binutils-2.23.2-kernel-ld-r.patch +++ b/binutils-2.23.2-kernel-ld-r.patch @@ -1,2734 +1,2343 @@ -diff -cpr ../binutils-2.23.2.orig/bfd/bfd.c bfd/bfd.c -*** ../binutils-2.23.2.orig/bfd/bfd.c 2013-05-14 16:39:24.681717759 +0100 ---- bfd/bfd.c 2013-05-14 16:40:06.988718932 +0100 -*************** CODE_FRAGMENT -*** 43,48 **** ---- 43,56 ---- - . both_direction = 3 - . }; - . -+ .enum bfd_lto_object_type -+ . { -+ . lto_non_object, -+ . lto_non_ir_object, -+ . lto_ir_object, -+ . lto_mixed_object -+ . }; -+ . - .struct bfd - .{ - . {* A unique identifier of the BFD *} -*************** CODE_FRAGMENT -*** 190,195 **** ---- 198,206 ---- - . {* The last section on the section list. *} - . struct bfd_section *section_last; - . -+ . {* The object-only section on the section list. *} -+ . struct bfd_section *object_only_section; -+ . - . {* The number of sections. *} - . unsigned int section_count; - . -*************** CODE_FRAGMENT -*** 308,313 **** ---- 319,327 ---- - . {* Set if only required symbols should be added in the link hash table for - . this object. Used by VMS linkers. *} - . unsigned int selective_search : 1; -+ . -+ . {* LTO object type. *} -+ . unsigned int lto_type : 2; - .}; - . - */ -*************** bfd_demangle (bfd *abfd, const char *nam -*** 2026,2028 **** ---- 2040,2075 ---- - - return res; - } -+ -+ /* -+ FUNCTION -+ bfd_group_signature -+ -+ SYNOPSIS -+ asymbol *bfd_group_signature (asection *group, asymbol **isympp); -+ -+ DESCRIPTION -+ Return a pointer to the symbol used as a signature for GROUP. -+ */ -+ -+ asymbol * -+ bfd_group_signature (asection *group, asymbol **isympp) -+ { -+ bfd *abfd = group->owner; -+ Elf_Internal_Shdr *ghdr; -+ -+ if (bfd_get_flavour (abfd) != bfd_target_elf_flavour) -+ return NULL; -+ -+ ghdr = &elf_section_data (group)->this_hdr; -+ if (ghdr->sh_link < elf_numsections (abfd)) -+ { -+ const struct elf_backend_data *bed = get_elf_backend_data (abfd); -+ Elf_Internal_Shdr *symhdr = elf_elfsections (abfd) [ghdr->sh_link]; -+ -+ if (symhdr->sh_type == SHT_SYMTAB -+ && ghdr->sh_info < symhdr->sh_size / bed->s->sizeof_sym) -+ return isympp[ghdr->sh_info - 1]; -+ } -+ return NULL; -+ } +diff -upr ../binutils-2.23.2.orig/bfd/bfd.c bfd/bfd.c +--- a/bfd/bfd.c 2013-05-14 16:39:24.681717759 +0100 ++++ b/bfd/bfd.c 2013-05-14 16:40:06.988718932 +0100 +@@ -43,6 +43,14 @@ + . both_direction = 3 + . }; + . ++.enum bfd_lto_object_type ++. { ++. lto_non_object, ++. lto_non_ir_object, ++. lto_ir_object, ++. lto_mixed_object ++. }; ++. + .struct bfd + .{ + . {* A unique identifier of the BFD *} +@@ -190,6 +198,9 @@ + . {* The last section on the section list. *} + . struct bfd_section *section_last; + . ++. {* The object-only section on the section list. *} ++. struct bfd_section *object_only_section; ++. + . {* The number of sections. *} + . unsigned int section_count; + . +@@ -308,6 +319,9 @@ + . {* Set if only required symbols should be added in the link hash table for + . this object. Used by VMS linkers. *} + . unsigned int selective_search : 1; ++. ++. {* LTO object type. *} ++. unsigned int lto_type : 2; + .}; + . + */ +@@ -2026,3 +2040,36 @@ + + return res; + } ++ ++/* ++FUNCTION ++ bfd_group_signature ++ ++SYNOPSIS ++ asymbol *bfd_group_signature (asection *group, asymbol **isympp); ++ ++DESCRIPTION ++ Return a pointer to the symbol used as a signature for GROUP. ++*/ ++ ++asymbol * ++bfd_group_signature (asection *group, asymbol **isympp) ++{ ++ bfd *abfd = group->owner; ++ Elf_Internal_Shdr *ghdr; ++ ++ if (bfd_get_flavour (abfd) != bfd_target_elf_flavour) ++ return NULL; ++ ++ ghdr = &elf_section_data (group)->this_hdr; ++ if (ghdr->sh_link < elf_numsections (abfd)) ++ { ++ const struct elf_backend_data *bed = get_elf_backend_data (abfd); ++ Elf_Internal_Shdr *symhdr = elf_elfsections (abfd) [ghdr->sh_link]; ++ ++ if (symhdr->sh_type == SHT_SYMTAB ++ && ghdr->sh_info < symhdr->sh_size / bed->s->sizeof_sym) ++ return isympp[ghdr->sh_info - 1]; ++ } ++ return NULL; ++} diff -cpr ../binutils-2.23.2.orig/bfd/bfd-in2.h bfd/bfd-in2.h -*** ../binutils-2.23.2.orig/bfd/bfd-in2.h 2013-05-14 16:39:24.640717758 +0100 ---- bfd/bfd-in2.h 2013-05-14 16:42:03.217722154 +0100 -*************** struct bfd_section *bfd_create_gnu_debug -*** 1050,1055 **** ---- 1050,1058 ---- - bfd_boolean bfd_fill_in_gnu_debuglink_section - (bfd *abfd, struct bfd_section *sect, const char *filename); - -+ const char *bfd_extract_object_only_section -+ (bfd *abfd); -+ - /* Extracted from libbfd.c. */ - - /* Byte swapping macros for user section data. */ -*************** extern asection std_section[4]; -*** 1594,1599 **** ---- 1597,1605 ---- - || ((SEC) == bfd_com_section_ptr) \ - || ((SEC) == bfd_ind_section_ptr)) - -+ /* GNU object-only section name. */ -+ #define GNU_OBJECT_ONLY_SECTION_NAME ".gnu_object_only" -+ - /* Macros to handle insertion and deletion of a bfd's sections. These - only handle the list pointers, ie. do not adjust section_count, - target_index etc. */ -*************** enum bfd_direction -*** 5681,5686 **** ---- 5687,5700 ---- - both_direction = 3 - }; - -+ enum bfd_lto_object_type -+ { -+ lto_non_object, -+ lto_non_ir_object, -+ lto_ir_object, -+ lto_mixed_object -+ }; -+ - struct bfd - { - /* A unique identifier of the BFD */ -*************** struct bfd -*** 5828,5833 **** ---- 5842,5850 ---- - /* The last section on the section list. */ - struct bfd_section *section_last; - -+ /* The object-only section on the section list. */ -+ struct bfd_section *object_only_section; -+ - /* The number of sections. */ - unsigned int section_count; - -*************** struct bfd -*** 5946,5951 **** ---- 5963,5971 ---- - /* Set if only required symbols should be added in the link hash table for - this object. Used by VMS linkers. */ - unsigned int selective_search : 1; -+ -+ /* LTO object type. */ -+ unsigned int lto_type : 2; - }; - - typedef enum bfd_error -*************** void bfd_emul_set_commonpagesize (const -*** 6167,6172 **** ---- 6187,6194 ---- - - char *bfd_demangle (bfd *, const char *, int); - -+ asymbol *bfd_group_signature (asection *group, asymbol **isympp); -+ - /* Extracted from archive.c. */ - symindex bfd_get_next_mapent - (bfd *abfd, symindex previous, carsym **sym); +--- a/bfd/bfd-in2.h 2013-05-14 16:39:24.640717758 +0100 ++++ b/bfd/bfd-in2.h 2013-05-14 16:42:03.217722154 +0100 +@@ -1050,6 +1050,9 @@ + bfd_boolean bfd_fill_in_gnu_debuglink_section + (bfd *abfd, struct bfd_section *sect, const char *filename); + ++const char *bfd_extract_object_only_section ++ (bfd *abfd); ++ + /* Extracted from libbfd.c. */ + + /* Byte swapping macros for user section data. */ +@@ -1594,6 +1597,9 @@ + || ((SEC) == bfd_com_section_ptr) \ + || ((SEC) == bfd_ind_section_ptr)) + ++/* GNU object-only section name. */ ++#define GNU_OBJECT_ONLY_SECTION_NAME ".gnu_object_only" ++ + /* Macros to handle insertion and deletion of a bfd's sections. These + only handle the list pointers, ie. do not adjust section_count, + target_index etc. */ +@@ -5681,6 +5687,14 @@ + both_direction = 3 + }; + ++enum bfd_lto_object_type ++ { ++ lto_non_object, ++ lto_non_ir_object, ++ lto_ir_object, ++ lto_mixed_object ++ }; ++ + struct bfd + { + /* A unique identifier of the BFD */ +@@ -5828,6 +5842,9 @@ + /* The last section on the section list. */ + struct bfd_section *section_last; + ++ /* The object-only section on the section list. */ ++ struct bfd_section *object_only_section; ++ + /* The number of sections. */ + unsigned int section_count; + +@@ -5946,6 +5963,9 @@ + /* Set if only required symbols should be added in the link hash table for + this object. Used by VMS linkers. */ + unsigned int selective_search : 1; ++ ++ /* LTO object type. */ ++ unsigned int lto_type : 2; + }; + + typedef enum bfd_error +@@ -6167,6 +6187,8 @@ + + char *bfd_demangle (bfd *, const char *, int); + ++asymbol *bfd_group_signature (asection *group, asymbol **isympp); ++ + /* Extracted from archive.c. */ + symindex bfd_get_next_mapent + (bfd *abfd, symindex previous, carsym **sym); diff -cpr ../binutils-2.23.2.orig/bfd/elf.c bfd/elf.c -*** ../binutils-2.23.2.orig/bfd/elf.c 2013-05-14 16:39:25.317717777 +0100 ---- bfd/elf.c 2013-05-14 16:40:06.993718932 +0100 -*************** static const struct bfd_elf_special_sect -*** 2092,2097 **** ---- 2092,2098 ---- - { STRING_COMMA_LEN (".gnu.linkonce.b"), -2, SHT_NOBITS, SHF_ALLOC + SHF_WRITE }, - { STRING_COMMA_LEN (".gnu.lto_"), -1, SHT_PROGBITS, SHF_EXCLUDE }, - { STRING_COMMA_LEN (".got"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, -+ { STRING_COMMA_LEN (".gnu_object_only"), 0, SHT_GNU_OBJECT_ONLY, SHF_EXCLUDE }, - { STRING_COMMA_LEN (".gnu.version"), 0, SHT_GNU_versym, 0 }, - { STRING_COMMA_LEN (".gnu.version_d"), 0, SHT_GNU_verdef, 0 }, - { STRING_COMMA_LEN (".gnu.version_r"), 0, SHT_GNU_verneed, 0 }, +--- a/bfd/elf.c 2013-05-14 16:39:25.317717777 +0100 ++++ b/bfd/elf.c 2013-05-14 16:40:06.993718932 +0100 +@@ -2092,6 +2092,7 @@ + { STRING_COMMA_LEN (".gnu.linkonce.b"), -2, SHT_NOBITS, SHF_ALLOC + SHF_WRITE }, + { STRING_COMMA_LEN (".gnu.lto_"), -1, SHT_PROGBITS, SHF_EXCLUDE }, + { STRING_COMMA_LEN (".got"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, ++ { STRING_COMMA_LEN (".gnu_object_only"), 0, SHT_GNU_OBJECT_ONLY, SHF_EXCLUDE }, + { STRING_COMMA_LEN (".gnu.version"), 0, SHT_GNU_versym, 0 }, + { STRING_COMMA_LEN (".gnu.version_d"), 0, SHT_GNU_verdef, 0 }, + { STRING_COMMA_LEN (".gnu.version_r"), 0, SHT_GNU_verneed, 0 }, diff -cpr ../binutils-2.23.2.orig/bfd/elflink.c bfd/elflink.c -*** ../binutils-2.23.2.orig/bfd/elflink.c 2013-05-14 16:39:25.280717776 +0100 ---- bfd/elflink.c 2013-05-14 16:40:06.997718932 +0100 -*************** elf_link_add_archive_symbols (bfd *abfd, -*** 5127,5132 **** ---- 5127,5135 ---- - something wrong with the archive. */ - if (element->archive_pass != 0) - { -+ /* Don't load the IR archive member twice. */ -+ if (element->lto_type == lto_ir_object) -+ continue; - bfd_set_error (bfd_error_bad_value); - goto error_return; - } +--- a/bfd/elflink.c 2013-05-14 16:39:25.280717776 +0100 ++++ b/bfd/elflink.c 2013-05-14 16:40:06.997718932 +0100 +@@ -5127,6 +5127,9 @@ + something wrong with the archive. */ + if (element->archive_pass != 0) + { ++ /* Don't load the IR archive member twice. */ ++ if (element->lto_type == lto_ir_object) ++ continue; + bfd_set_error (bfd_error_bad_value); + goto error_return; + } diff -cpr ../binutils-2.23.2.orig/bfd/format.c bfd/format.c -*** ../binutils-2.23.2.orig/bfd/format.c 2013-05-14 16:39:24.265717748 +0100 ---- bfd/format.c 2013-05-14 16:40:07.006718933 +0100 -*************** bfd_check_format (bfd *abfd, bfd_format -*** 95,100 **** ---- 95,127 ---- - return bfd_check_format_matches (abfd, format, NULL); - } - -+ /* Set lto_type in ABFD. */ -+ -+ static void -+ bfd_set_lto_type (bfd *abfd) -+ { -+ if (abfd->format == bfd_object -+ && abfd->lto_type == lto_non_object -+ && (abfd->flags & (DYNAMIC | EXEC_P)) == 0) -+ { -+ asection *sec; -+ enum bfd_lto_object_type type = lto_non_ir_object; -+ for (sec = abfd->sections; sec != NULL; sec = sec->next) -+ { -+ if (strcmp (sec->name, GNU_OBJECT_ONLY_SECTION_NAME) == 0) -+ { -+ type = lto_mixed_object; -+ abfd->object_only_section = sec; -+ break; -+ } -+ else if (type != lto_ir_object -+ && strncmp (sec->name, ".gnu.lto_", 9) == 0) -+ type = lto_ir_object; -+ } -+ abfd->lto_type = type; -+ } -+ } -+ - struct bfd_preserve - { - void *marker; -*************** bfd_check_format_matches (bfd *abfd, bfd -*** 136,142 **** - } - - if (abfd->format != bfd_unknown) -! return abfd->format == format; - - if (matching != NULL || *bfd_associated_vector != NULL) - { ---- 163,172 ---- - } - - if (abfd->format != bfd_unknown) -! { -! bfd_set_lto_type (abfd); -! return abfd->format == format; -! } - - if (matching != NULL || *bfd_associated_vector != NULL) - { -*************** bfd_check_format_matches (bfd *abfd, bfd -*** 322,327 **** ---- 352,360 ---- - - if (matching_vector) - free (matching_vector); -+ -+ bfd_set_lto_type (abfd); -+ - - /* File position has moved, BTW. */ - return TRUE; +--- a/bfd/format.c 2013-05-14 16:39:24.265717748 +0100 ++++ b/bfd/format.c 2013-05-14 16:40:07.006718933 +0100 +@@ -95,6 +95,33 @@ + return bfd_check_format_matches (abfd, format, NULL); + } + ++/* Set lto_type in ABFD. */ ++ ++static void ++bfd_set_lto_type (bfd *abfd) ++{ ++ if (abfd->format == bfd_object ++ && abfd->lto_type == lto_non_object ++ && (abfd->flags & (DYNAMIC | EXEC_P)) == 0) ++ { ++ asection *sec; ++ enum bfd_lto_object_type type = lto_non_ir_object; ++ for (sec = abfd->sections; sec != NULL; sec = sec->next) ++ { ++ if (strcmp (sec->name, GNU_OBJECT_ONLY_SECTION_NAME) == 0) ++ { ++ type = lto_mixed_object; ++ abfd->object_only_section = sec; ++ break; ++ } ++ else if (type != lto_ir_object ++ && strncmp (sec->name, ".gnu.lto_", 9) == 0) ++ type = lto_ir_object; ++ } ++ abfd->lto_type = type; ++ } ++} ++ + struct bfd_preserve + { + void *marker; +@@ -136,7 +163,10 @@ + } + + if (abfd->format != bfd_unknown) +- return abfd->format == format; ++ { ++ bfd_set_lto_type (abfd); ++ return abfd->format == format; ++ } + + if (matching != NULL || *bfd_associated_vector != NULL) + { +@@ -322,6 +352,9 @@ + + if (matching_vector) + free (matching_vector); ++ ++ bfd_set_lto_type (abfd); ++ + + /* File position has moved, BTW. */ + return TRUE; diff -cpr ../binutils-2.23.2.orig/bfd/opncls.c bfd/opncls.c -*** ../binutils-2.23.2.orig/bfd/opncls.c 2013-05-14 16:39:23.701717732 +0100 ---- bfd/opncls.c 2013-05-14 16:40:07.008718933 +0100 -*************** bfd_fill_in_gnu_debuglink_section (bfd * -*** 1569,1571 **** ---- 1569,1637 ---- - - return TRUE; - } -+ -+ /* -+ FUNCTION -+ bfd_extract_object_only_section -+ -+ SYNOPSIS -+ const char *bfd_extract_object_only_section -+ (bfd *abfd); -+ -+ DESCRIPTION -+ -+ Takes a @var{ABFD} and extract the .gnu_object_only section into -+ a temporary file. -+ -+ RETURNS -+ The name of the temporary file is returned if all is ok. -+ Otherwise <> is returned and bfd_error is set. -+ */ -+ -+ const char * -+ bfd_extract_object_only_section (bfd *abfd) -+ { -+ asection *sec = abfd->object_only_section; -+ const char *name; -+ FILE *file; -+ bfd_byte *memhunk = NULL; -+ size_t off, size; -+ bfd_error_type err; -+ -+ /* Get a temporary object-only file. */ -+ name = make_temp_file (".obj-only.o"); -+ -+ /* Open the object-only file. */ -+ file = real_fopen (name, FOPEN_WB); -+ if (!bfd_get_full_section_contents (abfd, sec, &memhunk)) -+ { -+ err = bfd_get_error (); -+ -+ loser: -+ free (memhunk); -+ fclose (file); -+ unlink (name); -+ bfd_set_error (err); -+ return NULL; -+ } -+ -+ off = 0; -+ size = sec->size; -+ while (off != size) -+ { -+ size_t written, nwrite = size - off; -+ -+ written = fwrite (memhunk + off, 1, nwrite, file); -+ if (written < nwrite && ferror (file)) -+ { -+ err = bfd_error_system_call; -+ goto loser; -+ } -+ -+ off += written; -+ } -+ -+ free (memhunk); -+ fclose (file); -+ return name; -+ } +--- a/bfd/opncls.c 2013-05-14 16:39:23.701717732 +0100 ++++ b/bfd/opncls.c 2013-05-14 16:40:07.008718933 +0100 +@@ -1569,3 +1569,69 @@ + + return TRUE; + } ++ ++/* ++FUNCTION ++ bfd_extract_object_only_section ++ ++SYNOPSIS ++ const char *bfd_extract_object_only_section ++ (bfd *abfd); ++ ++DESCRIPTION ++ ++ Takes a @var{ABFD} and extract the .gnu_object_only section into ++ a temporary file. ++ ++RETURNS ++ The name of the temporary file is returned if all is ok. ++ Otherwise <> is returned and bfd_error is set. ++*/ ++ ++const char * ++bfd_extract_object_only_section (bfd *abfd) ++{ ++ asection *sec = abfd->object_only_section; ++ const char *name; ++ FILE *file; ++ bfd_byte *memhunk = NULL; ++ size_t off, size; ++ bfd_error_type err; ++ ++ /* Get a temporary object-only file. */ ++ name = make_temp_file (".obj-only.o"); ++ ++ /* Open the object-only file. */ ++ file = real_fopen (name, FOPEN_WB); ++ if (!bfd_get_full_section_contents (abfd, sec, &memhunk)) ++ { ++ err = bfd_get_error (); ++ ++loser: ++ free (memhunk); ++ fclose (file); ++ unlink (name); ++ bfd_set_error (err); ++ return NULL; ++ } ++ ++ off = 0; ++ size = sec->size; ++ while (off != size) ++ { ++ size_t written, nwrite = size - off; ++ ++ written = fwrite (memhunk + off, 1, nwrite, file); ++ if (written < nwrite && ferror (file)) ++ { ++ err = bfd_error_system_call; ++ goto loser; ++ } ++ ++ off += written; ++ } ++ ++ free (memhunk); ++ fclose (file); ++ return name; ++} diff -cpr ../binutils-2.23.2.orig/bfd/plugin.c bfd/plugin.c -*** ../binutils-2.23.2.orig/bfd/plugin.c 2013-05-14 16:39:25.137717772 +0100 ---- bfd/plugin.c 2013-05-14 16:40:07.010718933 +0100 -*************** register_claim_file (ld_plugin_claim_fil -*** 130,135 **** ---- 130,268 ---- - return LDPS_OK; - } - -+ static asection bfd_plugin_fake_text_section -+ = BFD_FAKE_SECTION (bfd_plugin_fake_text_section, 0, 0, ".text", 0); -+ static asection bfd_plugin_fake_common_section -+ = BFD_FAKE_SECTION (bfd_plugin_fake_common_section, SEC_IS_COMMON, 0, -+ NULL, 0); -+ -+ /* Get symbols from object only section. */ -+ -+ static void -+ bfd_plugin_get_symbols_in_object_only (bfd *abfd) -+ { -+ struct plugin_data_struct *plugin_data = abfd->tdata.plugin_data; -+ const char *object_only_file; -+ bfd *nbfd; -+ long storage; -+ long object_only_nsyms, added_nsyms, i; -+ asymbol **object_only_syms, **added_syms; -+ -+ plugin_data->object_only_syms = NULL; -+ plugin_data->object_only_nsyms = 0; -+ -+ if (abfd->sections == NULL && abfd->my_archive == NULL) -+ { -+ nbfd = bfd_openr (abfd->filename, NULL); -+ if (nbfd == NULL || !bfd_check_format (nbfd, bfd_object)) -+ { -+ (*_bfd_error_handler) -+ (_("%s: failed to open to extract object only section: %s"), -+ abfd->filename, bfd_errmsg (bfd_get_error ())); -+ bfd_close (nbfd); -+ return; -+ } -+ } -+ else -+ { -+ if (!bfd_check_format (abfd, bfd_object)) -+ { -+ (*_bfd_error_handler) -+ (_("%B: invalid file to extract object only section: %s"), -+ abfd, bfd_errmsg (bfd_get_error ())); -+ return; -+ } -+ nbfd = abfd; -+ } -+ -+ if (nbfd->lto_type == lto_mixed_object -+ && (nbfd->flags & HAS_SYMS) != 0) -+ { -+ object_only_file = bfd_extract_object_only_section (nbfd); -+ if (object_only_file == NULL) -+ (*_bfd_error_handler) -+ (_("%B: failed to extract object only section: %s"), -+ abfd, bfd_errmsg (bfd_get_error ())); -+ } -+ else -+ object_only_file = NULL; -+ -+ /* Close the new bfd we just opened. */ -+ if (nbfd != abfd) -+ bfd_close (nbfd); -+ -+ /* Return if there is no object only section or there is no -+ symbol in object only section. */ -+ if (!object_only_file) -+ return; -+ -+ /* Open the file containing object only section. */ -+ nbfd = bfd_openr (object_only_file, NULL); -+ if (!bfd_check_format (nbfd, bfd_object)) -+ { -+ (*_bfd_error_handler) -+ (_("%B: failed to open object only section: %s"), -+ abfd, bfd_errmsg (bfd_get_error ())); -+ goto quit; -+ } -+ -+ storage = bfd_get_symtab_upper_bound (nbfd); -+ if (storage <= 0) -+ { -+ if (storage < 0) -+ (*_bfd_error_handler) -+ (_("%B: failed to get symbol table in object only section: %s"), -+ abfd, bfd_errmsg (bfd_get_error ())); -+ -+ goto quit; -+ } -+ -+ object_only_syms = (asymbol **) bfd_malloc (storage); -+ object_only_nsyms = bfd_canonicalize_symtab (nbfd, object_only_syms); -+ -+ /* FIXME: We waste some spaces if not all symbols are copied. */ -+ added_syms = (asymbol **) bfd_alloc (abfd, storage); -+ added_nsyms = 0; -+ -+ /* Copy only global symbols from object only section. */ -+ for (i = 0; i < object_only_nsyms; i++) -+ { -+ asection *sec = object_only_syms[i]->section; -+ flagword flags = object_only_syms[i]->flags; -+ asymbol *s; -+ -+ if (bfd_is_com_section (sec)) -+ sec = &bfd_plugin_fake_common_section; -+ else if (bfd_is_und_section (sec)) -+ ; -+ else if ((flags & (BSF_GLOBAL | BSF_WEAK | BSF_GNU_UNIQUE)) != 0) -+ sec = &bfd_plugin_fake_text_section; -+ else -+ continue; -+ -+ s = bfd_alloc (abfd, sizeof (asymbol)); -+ BFD_ASSERT (s); -+ added_syms[added_nsyms++] = s; -+ -+ s->section = sec; -+ s->the_bfd = abfd; -+ s->name = xstrdup (object_only_syms[i]->name); -+ s->value = 0; -+ s->flags = flags; -+ s->udata.p = NULL; -+ } -+ -+ plugin_data->object_only_syms = added_syms; -+ plugin_data->object_only_nsyms = added_nsyms; -+ -+ free (object_only_syms); -+ -+ quit: -+ /* Close and remove the object only section file. */ -+ bfd_close (nbfd); -+ unlink (object_only_file); -+ } -+ - static enum ld_plugin_status - add_symbols (void * handle, - int nsyms, -*************** add_symbols (void * handle, -*** 142,148 **** - plugin_data->nsyms = nsyms; - plugin_data->syms = syms; - -! if (nsyms != 0) - abfd->flags |= HAS_SYMS; - - abfd->tdata.plugin_data = plugin_data; ---- 275,283 ---- - plugin_data->nsyms = nsyms; - plugin_data->syms = syms; - -! bfd_plugin_get_symbols_in_object_only (abfd); -! -! if ((nsyms + plugin_data->object_only_nsyms) != 0) - abfd->flags |= HAS_SYMS; - - abfd->tdata.plugin_data = plugin_data; -*************** static long -*** 389,395 **** - bfd_plugin_get_symtab_upper_bound (bfd *abfd) - { - struct plugin_data_struct *plugin_data = abfd->tdata.plugin_data; -! long nsyms = plugin_data->nsyms; - - BFD_ASSERT (nsyms >= 0); - ---- 524,531 ---- - bfd_plugin_get_symtab_upper_bound (bfd *abfd) - { - struct plugin_data_struct *plugin_data = abfd->tdata.plugin_data; -! /* Add symbols from object only section. */ -! long nsyms = plugin_data->nsyms + plugin_data->object_only_nsyms; - - BFD_ASSERT (nsyms >= 0); - -*************** bfd_plugin_canonicalize_symtab (bfd *abf -*** 423,434 **** - struct plugin_data_struct *plugin_data = abfd->tdata.plugin_data; - long nsyms = plugin_data->nsyms; - const struct ld_plugin_symbol *syms = plugin_data->syms; -! static asection fake_section; -! static asection fake_common_section; -! int i; -! -! fake_section.name = ".text"; -! fake_common_section.flags = SEC_IS_COMMON; - - for (i = 0; i < nsyms; i++) - { ---- 559,565 ---- - struct plugin_data_struct *plugin_data = abfd->tdata.plugin_data; - long nsyms = plugin_data->nsyms; - const struct ld_plugin_symbol *syms = plugin_data->syms; -! int i, j; - - for (i = 0; i < nsyms; i++) - { -*************** bfd_plugin_canonicalize_symtab (bfd *abf -*** 441,450 **** - s->name = syms[i].name; - s->value = 0; - s->flags = convert_flags (&syms[i]); - switch (syms[i].def) - { - case LDPK_COMMON: -! s->section = &fake_common_section; - break; - case LDPK_UNDEF: - case LDPK_WEAKUNDEF: ---- 572,582 ---- - s->name = syms[i].name; - s->value = 0; - s->flags = convert_flags (&syms[i]); -+ s->udata.p = NULL; - switch (syms[i].def) - { - case LDPK_COMMON: -! s->section = &bfd_plugin_fake_common_section; - break; - case LDPK_UNDEF: - case LDPK_WEAKUNDEF: -*************** bfd_plugin_canonicalize_symtab (bfd *abf -*** 452,466 **** - break; - case LDPK_DEF: - case LDPK_WEAKDEF: -! s->section = &fake_section; - break; - default: - BFD_ASSERT (0); - } -- -- s->udata.p = (void *) &syms[i]; - } - - return nsyms; - } - ---- 584,601 ---- - break; - case LDPK_DEF: - case LDPK_WEAKDEF: -! s->section = &bfd_plugin_fake_text_section; - break; - default: - BFD_ASSERT (0); - } - } - -+ /* Copy symbols from object only section. */ -+ nsyms += plugin_data->object_only_nsyms; -+ for (j = 0; j < plugin_data->object_only_nsyms; j++, i++) -+ alocation[i] = plugin_data->object_only_syms[j]; -+ - return nsyms; - } - +--- a/bfd/plugin.c 2013-05-14 16:39:25.137717772 +0100 ++++ b/bfd/plugin.c 2013-05-14 16:40:07.010718933 +0100 +@@ -130,6 +130,139 @@ + return LDPS_OK; + } + ++static asection bfd_plugin_fake_text_section ++ = BFD_FAKE_SECTION (bfd_plugin_fake_text_section, 0, 0, ".text", 0); ++static asection bfd_plugin_fake_common_section ++ = BFD_FAKE_SECTION (bfd_plugin_fake_common_section, SEC_IS_COMMON, 0, ++ NULL, 0); ++ ++/* Get symbols from object only section. */ ++ ++static void ++bfd_plugin_get_symbols_in_object_only (bfd *abfd) ++{ ++ struct plugin_data_struct *plugin_data = abfd->tdata.plugin_data; ++ const char *object_only_file; ++ bfd *nbfd; ++ long storage; ++ long object_only_nsyms, added_nsyms, i; ++ asymbol **object_only_syms, **added_syms; ++ ++ plugin_data->object_only_syms = NULL; ++ plugin_data->object_only_nsyms = 0; ++ ++ if (abfd->sections == NULL && abfd->my_archive == NULL) ++ { ++ nbfd = bfd_openr (abfd->filename, NULL); ++ if (nbfd == NULL || !bfd_check_format (nbfd, bfd_object)) ++ { ++ (*_bfd_error_handler) ++ (_("%s: failed to open to extract object only section: %s"), ++ abfd->filename, bfd_errmsg (bfd_get_error ())); ++ bfd_close (nbfd); ++ return; ++ } ++ } ++ else ++ { ++ if (!bfd_check_format (abfd, bfd_object)) ++ { ++ (*_bfd_error_handler) ++ (_("%B: invalid file to extract object only section: %s"), ++ abfd, bfd_errmsg (bfd_get_error ())); ++ return; ++ } ++ nbfd = abfd; ++ } ++ ++ if (nbfd->lto_type == lto_mixed_object ++ && (nbfd->flags & HAS_SYMS) != 0) ++ { ++ object_only_file = bfd_extract_object_only_section (nbfd); ++ if (object_only_file == NULL) ++ (*_bfd_error_handler) ++ (_("%B: failed to extract object only section: %s"), ++ abfd, bfd_errmsg (bfd_get_error ())); ++ } ++ else ++ object_only_file = NULL; ++ ++ /* Close the new bfd we just opened. */ ++ if (nbfd != abfd) ++ bfd_close (nbfd); ++ ++ /* Return if there is no object only section or there is no ++ symbol in object only section. */ ++ if (!object_only_file) ++ return; ++ ++ /* Open the file containing object only section. */ ++ nbfd = bfd_openr (object_only_file, NULL); ++ if (!bfd_check_format (nbfd, bfd_object)) ++ { ++ (*_bfd_error_handler) ++ (_("%B: failed to open object only section: %s"), ++ abfd, bfd_errmsg (bfd_get_error ())); ++ goto quit; ++ } ++ ++ storage = bfd_get_symtab_upper_bound (nbfd); ++ if (storage <= 0) ++ { ++ if (storage < 0) ++ (*_bfd_error_handler) ++ (_("%B: failed to get symbol table in object only section: %s"), ++ abfd, bfd_errmsg (bfd_get_error ())); ++ ++ goto quit; ++ } ++ ++ object_only_syms = (asymbol **) bfd_malloc (storage); ++ object_only_nsyms = bfd_canonicalize_symtab (nbfd, object_only_syms); ++ ++ /* FIXME: We waste some spaces if not all symbols are copied. */ ++ added_syms = (asymbol **) bfd_alloc (abfd, storage); ++ added_nsyms = 0; ++ ++ /* Copy only global symbols from object only section. */ ++ for (i = 0; i < object_only_nsyms; i++) ++ { ++ asection *sec = object_only_syms[i]->section; ++ flagword flags = object_only_syms[i]->flags; ++ asymbol *s; ++ ++ if (bfd_is_com_section (sec)) ++ sec = &bfd_plugin_fake_common_section; ++ else if (bfd_is_und_section (sec)) ++ ; ++ else if ((flags & (BSF_GLOBAL | BSF_WEAK | BSF_GNU_UNIQUE)) != 0) ++ sec = &bfd_plugin_fake_text_section; ++ else ++ continue; ++ ++ s = bfd_alloc (abfd, sizeof (asymbol)); ++ BFD_ASSERT (s); ++ added_syms[added_nsyms++] = s; ++ ++ s->section = sec; ++ s->the_bfd = abfd; ++ s->name = xstrdup (object_only_syms[i]->name); ++ s->value = 0; ++ s->flags = flags; ++ s->udata.p = NULL; ++ } ++ ++ plugin_data->object_only_syms = added_syms; ++ plugin_data->object_only_nsyms = added_nsyms; ++ ++ free (object_only_syms); ++ ++quit: ++ /* Close and remove the object only section file. */ ++ bfd_close (nbfd); ++ unlink (object_only_file); ++} ++ + static enum ld_plugin_status + add_symbols (void * handle, + int nsyms, +@@ -142,7 +275,9 @@ + plugin_data->nsyms = nsyms; + plugin_data->syms = syms; + +- if (nsyms != 0) ++ bfd_plugin_get_symbols_in_object_only (abfd); ++ ++ if ((nsyms + plugin_data->object_only_nsyms) != 0) + abfd->flags |= HAS_SYMS; + + abfd->tdata.plugin_data = plugin_data; +@@ -389,7 +524,8 @@ + bfd_plugin_get_symtab_upper_bound (bfd *abfd) + { + struct plugin_data_struct *plugin_data = abfd->tdata.plugin_data; +- long nsyms = plugin_data->nsyms; ++ /* Add symbols from object only section. */ ++ long nsyms = plugin_data->nsyms + plugin_data->object_only_nsyms; + + BFD_ASSERT (nsyms >= 0); + +@@ -423,12 +559,7 @@ + struct plugin_data_struct *plugin_data = abfd->tdata.plugin_data; + long nsyms = plugin_data->nsyms; + const struct ld_plugin_symbol *syms = plugin_data->syms; +- static asection fake_section; +- static asection fake_common_section; +- int i; +- +- fake_section.name = ".text"; +- fake_common_section.flags = SEC_IS_COMMON; ++ int i, j; + + for (i = 0; i < nsyms; i++) + { +@@ -441,10 +572,11 @@ + s->name = syms[i].name; + s->value = 0; + s->flags = convert_flags (&syms[i]); ++ s->udata.p = NULL; + switch (syms[i].def) + { + case LDPK_COMMON: +- s->section = &fake_common_section; ++ s->section = &bfd_plugin_fake_common_section; + break; + case LDPK_UNDEF: + case LDPK_WEAKUNDEF: +@@ -452,15 +584,18 @@ + break; + case LDPK_DEF: + case LDPK_WEAKDEF: +- s->section = &fake_section; ++ s->section = &bfd_plugin_fake_text_section; + break; + default: + BFD_ASSERT (0); + } +- +- s->udata.p = (void *) &syms[i]; + } + ++ /* Copy symbols from object only section. */ ++ nsyms += plugin_data->object_only_nsyms; ++ for (j = 0; j < plugin_data->object_only_nsyms; j++, i++) ++ alocation[i] = plugin_data->object_only_syms[j]; ++ + return nsyms; + } + diff -cpr ../binutils-2.23.2.orig/bfd/plugin.h bfd/plugin.h -*** ../binutils-2.23.2.orig/bfd/plugin.h 2013-05-14 16:39:25.481717782 +0100 ---- bfd/plugin.h 2013-05-14 16:40:07.010718933 +0100 -*************** typedef struct plugin_data_struct -*** 30,35 **** ---- 30,37 ---- - { - int nsyms; - const struct ld_plugin_symbol *syms; -+ int object_only_nsyms; -+ asymbol **object_only_syms; - } - plugin_data_struct; - +--- a/bfd/plugin.h 2013-05-14 16:39:25.481717782 +0100 ++++ b/bfd/plugin.h 2013-05-14 16:40:07.010718933 +0100 +@@ -30,6 +30,8 @@ + { + int nsyms; + const struct ld_plugin_symbol *syms; ++ int object_only_nsyms; ++ asymbol **object_only_syms; + } + plugin_data_struct; + diff -cpr ../binutils-2.23.2.orig/bfd/section.c bfd/section.c -*** ../binutils-2.23.2.orig/bfd/section.c 2013-05-14 16:39:26.180717801 +0100 ---- bfd/section.c 2013-05-14 16:43:06.082723897 +0100 -*************** CODE_FRAGMENT -*** 571,576 **** ---- 571,579 ---- - . || ((SEC) == bfd_com_section_ptr) \ - . || ((SEC) == bfd_ind_section_ptr)) - . -+ .{* GNU object-only section name. *} -+ .#define GNU_OBJECT_ONLY_SECTION_NAME ".gnu_object_only" -+ . - .{* Macros to handle insertion and deletion of a bfd's sections. These - . only handle the list pointers, ie. do not adjust section_count, - . target_index etc. *} +--- a/bfd/section.c 2013-05-14 16:39:26.180717801 +0100 ++++ b/bfd/section.c 2013-05-14 16:43:06.082723897 +0100 +@@ -571,6 +571,9 @@ + . || ((SEC) == bfd_com_section_ptr) \ + . || ((SEC) == bfd_ind_section_ptr)) + . ++.{* GNU object-only section name. *} ++.#define GNU_OBJECT_ONLY_SECTION_NAME ".gnu_object_only" ++. + .{* Macros to handle insertion and deletion of a bfd's sections. These + . only handle the list pointers, ie. do not adjust section_count, + . target_index etc. *} diff -cpr ../binutils-2.23.2.orig/binutils/objcopy.c binutils/objcopy.c -*** ../binutils-2.23.2.orig/binutils/objcopy.c 2013-05-14 16:39:36.214718079 +0100 ---- binutils/objcopy.c 2013-05-14 16:45:04.631727183 +0100 -*************** is_specified_symbol (const char *name, h -*** 943,972 **** - return htab_find (htab, name) != NULL; - } - -- /* Return a pointer to the symbol used as a signature for GROUP. */ -- -- static asymbol * -- group_signature (asection *group) -- { -- bfd *abfd = group->owner; -- Elf_Internal_Shdr *ghdr; -- -- if (bfd_get_flavour (abfd) != bfd_target_elf_flavour) -- return NULL; -- -- ghdr = &elf_section_data (group)->this_hdr; -- if (ghdr->sh_link < elf_numsections (abfd)) -- { -- const struct elf_backend_data *bed = get_elf_backend_data (abfd); -- Elf_Internal_Shdr *symhdr = elf_elfsections (abfd) [ghdr->sh_link]; -- -- if (symhdr->sh_type == SHT_SYMTAB -- && ghdr->sh_info < symhdr->sh_size / bed->s->sizeof_sym) -- return isympp[ghdr->sh_info - 1]; -- } -- return NULL; -- } -- - /* Return TRUE if the section is a DWO section. */ - - static bfd_boolean ---- 943,948 ---- -*************** is_strip_section (bfd *abfd ATTRIBUTE_UN -*** 1034,1040 **** - /* PR binutils/3181 - If we are going to strip the group signature symbol, then - strip the group section too. */ -! gsym = group_signature (sec); - if (gsym != NULL) - gname = gsym->name; - else ---- 1010,1016 ---- - /* PR binutils/3181 - If we are going to strip the group signature symbol, then - strip the group section too. */ -! gsym = bfd_group_signature (sec, isympp); - if (gsym != NULL) - gname = gsym->name; - else -*************** setup_section (bfd *ibfd, sec_ptr isecti -*** 2633,2639 **** - - if ((isection->flags & SEC_GROUP) != 0) - { -! asymbol *gsym = group_signature (isection); - - if (gsym != NULL) - { ---- 2609,2615 ---- - - if ((isection->flags & SEC_GROUP) != 0) - { -! asymbol *gsym = bfd_group_signature (isection, isympp); - - if (gsym != NULL) - { +--- a/binutils/objcopy.c 2013-05-14 16:39:36.214718079 +0100 ++++ b/binutils/objcopy.c 2013-05-14 16:45:04.631727183 +0100 +@@ -943,30 +943,6 @@ + return htab_find (htab, name) != NULL; + } + +-/* Return a pointer to the symbol used as a signature for GROUP. */ +- +-static asymbol * +-group_signature (asection *group) +-{ +- bfd *abfd = group->owner; +- Elf_Internal_Shdr *ghdr; +- +- if (bfd_get_flavour (abfd) != bfd_target_elf_flavour) +- return NULL; +- +- ghdr = &elf_section_data (group)->this_hdr; +- if (ghdr->sh_link < elf_numsections (abfd)) +- { +- const struct elf_backend_data *bed = get_elf_backend_data (abfd); +- Elf_Internal_Shdr *symhdr = elf_elfsections (abfd) [ghdr->sh_link]; +- +- if (symhdr->sh_type == SHT_SYMTAB +- && ghdr->sh_info < symhdr->sh_size / bed->s->sizeof_sym) +- return isympp[ghdr->sh_info - 1]; +- } +- return NULL; +-} +- + /* Return TRUE if the section is a DWO section. */ + + static bfd_boolean +@@ -1034,7 +1010,7 @@ + /* PR binutils/3181 + If we are going to strip the group signature symbol, then + strip the group section too. */ +- gsym = group_signature (sec); ++ gsym = bfd_group_signature (sec, isympp); + if (gsym != NULL) + gname = gsym->name; + else +@@ -2633,7 +2609,7 @@ + + if ((isection->flags & SEC_GROUP) != 0) + { +- asymbol *gsym = group_signature (isection); ++ asymbol *gsym = bfd_group_signature (isection, isympp); + + if (gsym != NULL) + { diff -cpr ../binutils-2.23.2.orig/binutils/readelf.c binutils/readelf.c -*** ../binutils-2.23.2.orig/binutils/readelf.c 2013-05-14 16:39:35.668718064 +0100 ---- binutils/readelf.c 2013-05-14 16:40:07.022718933 +0100 -*************** get_section_type_name (unsigned int sh_t -*** 3101,3106 **** ---- 3101,3107 ---- - case 0x7ffffffd: return "AUXILIARY"; - case 0x7fffffff: return "FILTER"; - case SHT_GNU_LIBLIST: return "GNU_LIBLIST"; -+ case SHT_GNU_OBJECT_ONLY: return "GNU_OBJECT_ONLY"; - - default: - if ((sh_type >= SHT_LOPROC) && (sh_type <= SHT_HIPROC)) +--- a/binutils/readelf.c 2013-05-14 16:39:35.668718064 +0100 ++++ b/binutils/readelf.c 2013-05-14 16:40:07.022718933 +0100 +@@ -3101,6 +3101,7 @@ + case 0x7ffffffd: return "AUXILIARY"; + case 0x7fffffff: return "FILTER"; + case SHT_GNU_LIBLIST: return "GNU_LIBLIST"; ++ case SHT_GNU_OBJECT_ONLY: return "GNU_OBJECT_ONLY"; + + default: + if ((sh_type >= SHT_LOPROC) && (sh_type <= SHT_HIPROC)) diff -cpr ../binutils-2.23.2.orig/include/bfdlink.h include/bfdlink.h -*** ../binutils-2.23.2.orig/include/bfdlink.h 2013-05-14 16:39:19.745717623 +0100 ---- include/bfdlink.h 2013-05-14 16:40:07.023718933 +0100 -*************** struct bfd_link_info -*** 380,385 **** ---- 380,391 ---- - /* TRUE if ok to have multiple definition. */ - unsigned int allow_multiple_definition: 1; - -+ /* TRUE if .gnu_object_only section should be created. */ -+ unsigned int emit_gnu_object_only: 1; -+ -+ /* TRUE if .gnu_object_only section is being created. */ -+ unsigned int emitting_gnu_object_only: 1; -+ - /* TRUE if ok to have version with no definition. */ - unsigned int allow_undefined_version: 1; - +--- a/include/bfdlink.h 2013-05-14 16:39:19.745717623 +0100 ++++ b/include/bfdlink.h 2013-05-14 16:40:07.023718933 +0100 +@@ -380,6 +380,12 @@ + /* TRUE if ok to have multiple definition. */ + unsigned int allow_multiple_definition: 1; + ++ /* TRUE if .gnu_object_only section should be created. */ ++ unsigned int emit_gnu_object_only: 1; ++ ++ /* TRUE if .gnu_object_only section is being created. */ ++ unsigned int emitting_gnu_object_only: 1; ++ + /* TRUE if ok to have version with no definition. */ + unsigned int allow_undefined_version: 1; + diff -cpr ../binutils-2.23.2.orig/include/elf/common.h include/elf/common.h -*** ../binutils-2.23.2.orig/include/elf/common.h 2013-05-14 16:39:19.628717619 +0100 ---- include/elf/common.h 2013-05-14 16:40:07.023718933 +0100 -*************** -*** 472,477 **** ---- 472,478 ---- - #define SHT_GNU_ATTRIBUTES 0x6ffffff5 /* Object attributes */ - #define SHT_GNU_HASH 0x6ffffff6 /* GNU style symbol hash table */ - #define SHT_GNU_LIBLIST 0x6ffffff7 /* List of prelink dependencies */ -+ #define SHT_GNU_OBJECT_ONLY 0x6ffffff8 /* Object only */ - - /* The next three section types are defined by Solaris, and are named - SHT_SUNW*. We use them in GNU code, so we also define SHT_GNU* +--- a/include/elf/common.h 2013-05-14 16:39:19.628717619 +0100 ++++ b/include/elf/common.h 2013-05-14 16:40:07.023718933 +0100 +@@ -472,6 +472,7 @@ + #define SHT_GNU_ATTRIBUTES 0x6ffffff5 /* Object attributes */ + #define SHT_GNU_HASH 0x6ffffff6 /* GNU style symbol hash table */ + #define SHT_GNU_LIBLIST 0x6ffffff7 /* List of prelink dependencies */ ++#define SHT_GNU_OBJECT_ONLY 0x6ffffff8 /* Object only */ + + /* The next three section types are defined by Solaris, and are named + SHT_SUNW*. We use them in GNU code, so we also define SHT_GNU* diff -cpr ../binutils-2.23.2.orig/ld/emultempl/alphaelf.em ld/emultempl/alphaelf.em -*** ../binutils-2.23.2.orig/ld/emultempl/alphaelf.em 2013-05-14 16:39:37.461718114 +0100 ---- ld/emultempl/alphaelf.em 2013-05-14 16:40:07.030718933 +0100 -*************** alpha_finish (void) -*** 100,106 **** - if (limit_32bit) - elf_elfheader (link_info.output_bfd)->e_flags |= EF_ALPHA_32BIT; - -! finish_default (); - } - EOF - ---- 100,106 ---- - if (limit_32bit) - elf_elfheader (link_info.output_bfd)->e_flags |= EF_ALPHA_32BIT; - -! gld${EMULATION_NAME}_finish (); - } - EOF - +--- a/ld/emultempl/alphaelf.em 2013-05-14 16:39:37.461718114 +0100 ++++ b/ld/emultempl/alphaelf.em 2013-05-14 16:40:07.030718933 +0100 +@@ -100,7 +100,7 @@ + if (limit_32bit) + elf_elfheader (link_info.output_bfd)->e_flags |= EF_ALPHA_32BIT; + +- finish_default (); ++ gld${EMULATION_NAME}_finish (); + } + EOF + diff -cpr ../binutils-2.23.2.orig/ld/emultempl/armelf.em ld/emultempl/armelf.em -*** ../binutils-2.23.2.orig/ld/emultempl/armelf.em 2013-05-14 16:39:37.458718114 +0100 ---- ld/emultempl/armelf.em 2013-05-14 16:40:07.033718933 +0100 -*************** gld${EMULATION_NAME}_after_allocation (v -*** 366,372 **** - } - - static void -! gld${EMULATION_NAME}_finish (void) - { - struct bfd_link_hash_entry * h; - ---- 366,372 ---- - } - - static void -! arm_finish (void) - { - struct bfd_link_hash_entry * h; - -*************** gld${EMULATION_NAME}_finish (void) -*** 389,395 **** - } - } - -! finish_default (); - - if (thumb_entry_symbol) - { ---- 389,395 ---- - } - } - -! gld${EMULATION_NAME}_finish (); - - if (thumb_entry_symbol) - { -*************** LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS= -*** 690,693 **** - LDEMUL_BEFORE_PARSE=gld"${EMULATION_NAME}"_before_parse - - # Call the extra arm-elf function -! LDEMUL_FINISH=gld${EMULATION_NAME}_finish ---- 690,693 ---- - LDEMUL_BEFORE_PARSE=gld"${EMULATION_NAME}"_before_parse - - # Call the extra arm-elf function -! LDEMUL_FINISH=arm_finish +--- a/ld/emultempl/armelf.em 2013-05-14 16:39:37.458718114 +0100 ++++ b/ld/emultempl/armelf.em 2013-05-14 16:40:07.033718933 +0100 +@@ -366,7 +366,7 @@ + } + + static void +-gld${EMULATION_NAME}_finish (void) ++arm_finish (void) + { + struct bfd_link_hash_entry * h; + +@@ -389,7 +389,7 @@ + } + } + +- finish_default (); ++ gld${EMULATION_NAME}_finish (); + + if (thumb_entry_symbol) + { +@@ -690,4 +690,4 @@ + LDEMUL_BEFORE_PARSE=gld"${EMULATION_NAME}"_before_parse + + # Call the extra arm-elf function +-LDEMUL_FINISH=gld${EMULATION_NAME}_finish ++LDEMUL_FINISH=arm_finish diff -cpr ../binutils-2.23.2.orig/ld/emultempl/elf32.em ld/emultempl/elf32.em -*** ../binutils-2.23.2.orig/ld/emultempl/elf32.em 2013-05-14 16:39:37.465718114 +0100 ---- ld/emultempl/elf32.em 2013-05-14 16:40:07.035718933 +0100 -*************** static void gld${EMULATION_NAME}_before_ -*** 68,73 **** ---- 68,74 ---- - static void gld${EMULATION_NAME}_after_allocation (void); - static lang_output_section_statement_type *gld${EMULATION_NAME}_place_orphan - (asection *, const char *, int); -+ static void gld${EMULATION_NAME}_finish (void); - EOF - - if [ "x${USE_LIBPATH}" = xyes ] ; then -*************** output_rel_find (asection *sec, int isdy -*** 1764,1769 **** ---- 1765,1772 ---- - return last; - } - -+ static int orphan_init_done = 0; -+ - /* Place an orphan section. We use this to put random SHF_ALLOC - sections in the right segment. */ - -*************** gld${EMULATION_NAME}_place_orphan (asect -*** 1772,1778 **** - const char *secname, - int constraint) - { -! static struct orphan_save hold[] = - { - { ".text", - SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE, ---- 1775,1781 ---- - const char *secname, - int constraint) - { -! static struct orphan_save orig_hold[] = - { - { ".text", - SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE, -*************** gld${EMULATION_NAME}_place_orphan (asect -*** 1799,1804 **** ---- 1802,1808 ---- - SEC_HAS_CONTENTS, - 0, 0, 0, 0 }, - }; -+ static struct orphan_save hold[ARRAY_SIZE (orig_hold)]; - enum orphan_save_index - { - orphan_text = 0, -*************** gld${EMULATION_NAME}_place_orphan (asect -*** 1810,1816 **** - orphan_sdata, - orphan_nonalloc - }; -- static int orphan_init_done = 0; - struct orphan_save *place; - lang_output_section_statement_type *after; - lang_output_section_statement_type *os; ---- 1814,1819 ---- -*************** gld${EMULATION_NAME}_place_orphan (asect -*** 1887,1901 **** - - if (!orphan_init_done) - { -! struct orphan_save *ho; - - for (ho = hold; ho < hold + sizeof (hold) / sizeof (hold[0]); ++ho) - if (ho->name != NULL) - { - ho->os = lang_output_section_find (ho->name); - if (ho->os != NULL && ho->os->flags == 0) - ho->os->flags = ho->flags; - } - orphan_init_done = 1; - } - ---- 1890,1911 ---- - - if (!orphan_init_done) - { -! struct orphan_save *ho, *horig; - - for (ho = hold; ho < hold + sizeof (hold) / sizeof (hold[0]); ++ho) -+ for (ho = hold, horig = orig_hold; -+ ho < hold + ARRAY_SIZE (hold); -+ ++ho, ++horig) -+ { -+ *ho = *horig; -+ if (ho->name != NULL) - if (ho->name != NULL) - { - ho->os = lang_output_section_find (ho->name); - if (ho->os != NULL && ho->os->flags == 0) - ho->os->flags = ho->flags; - } -+ } - orphan_init_done = 1; - } - -*************** gld${EMULATION_NAME}_place_orphan (asect -*** 1965,1970 **** ---- 1975,2001 ---- - EOF - fi - -+ fragment <name != NULL) + if (ho->name != NULL) + { + ho->os = lang_output_section_find (ho->name); + if (ho->os != NULL && ho->os->flags == 0) + ho->os->flags = ho->flags; + } ++ } + orphan_init_done = 1; + } + +@@ -1965,6 +1975,27 @@ + EOF + fi + ++fragment <header.type = cmdline_is_bfd_enum; -+ new_opt->header.next = NULL; -+ new_opt->abfd.abfd = (bfd *) data; -+ -+ c = cmdline_object_only_archive_list.head; -+ if (c == NULL) -+ { -+ cmdline_object_only_archive_list.head = new_opt; -+ cmdline_object_only_archive_list.tail = &new_opt->header.next; -+ return; -+ } -+ -+ prev = NULL; -+ origin = abfd->origin; -+ for (; c != NULL; c = next) -+ { -+ if (c->header.type != cmdline_is_bfd_enum) -+ abort (); -+ -+ next = c->header.next; -+ -+ obfd = c->abfd.abfd; -+ oarchive = bfd_my_archive (obfd); -+ -+ if (strcmp (archive->filename, oarchive->filename) == 0) -+ { -+ bfd_boolean after; -+ -+ if (origin < obfd->origin) -+ { -+ /* Insert it before the current. */ -+ new_opt->header.next = c; -+ if (prev) -+ *prev = new_opt; -+ else -+ cmdline_object_only_archive_list.head = new_opt; -+ return; -+ } -+ -+ after = TRUE; -+ -+ /* Check origin. */ -+ while (next) -+ { -+ if (next->header.type != cmdline_is_bfd_enum) -+ abort (); -+ -+ nbfd = next->abfd.abfd; -+ norigin = nbfd->origin; -+ if (origin > norigin) -+ { -+ /* Insert it after NEXT. */ -+ break; -+ } -+ -+ narchive = bfd_my_archive (nbfd); -+ if (strcmp (archive->filename, narchive->filename) != 0) -+ { -+ /* Insert it befor NEXT. */ -+ after = FALSE; -+ break; -+ } -+ -+ c = next; -+ next = next->header.next; -+ } -+ -+ if (after && next) -+ { -+ c = next; -+ next = next->header.next; -+ } -+ -+ if (*cmdline_object_only_archive_list.tail == c->header.next) -+ cmdline_object_only_archive_list.tail -+ = &new_opt->header.next; -+ -+ prev = &c->header.next; -+ new_opt->header.next = next; -+ *prev = new_opt; -+ return; -+ } -+ -+ prev = &c->header.next; -+ } -+ -+ *cmdline_object_only_archive_list.tail = new_opt; -+ cmdline_object_only_archive_list.tail = &new_opt->header.next; -+ } -+ -+ -+ static void -+ cmdline_get_object_only_input_files (void) -+ { -+ cmdline_union_type *c, *next; -+ bfd *abfd, *archive; -+ bfd *nbfd, *narchive; -+ -+ /* Add files first. */ -+ for (c = cmdline_object_only_file_list.head; -+ c != NULL; c = c->header.next) -+ switch (c->header.type) -+ { -+ default: -+ abort (); -+ case cmdline_is_file_enum: -+ lang_add_input_file (c->file.filename, -+ lang_input_file_is_file_enum, NULL); -+ break; -+ case cmdline_is_bfd_enum: -+ abfd = c->abfd.abfd; -+ if (bfd_my_archive (abfd)) -+ abort (); -+ lang_add_input_file (abfd->filename, -+ lang_input_file_is_file_enum, NULL); -+ break; -+ } -+ -+ /* Add archive members next. */ -+ for (c = cmdline_object_only_archive_list.head; c != NULL; c = next) -+ { -+ if (c->header.type != cmdline_is_bfd_enum) -+ abort (); -+ -+ next = c->header.next; -+ -+ abfd = c->abfd.abfd; -+ archive = bfd_my_archive (abfd); -+ -+ /* Add the first archive of the archive member group. */ -+ lang_add_input_file (archive->filename, -+ lang_input_file_is_file_enum, NULL); -+ -+ /* Skip the rest members in the archive member group. */ -+ do -+ { -+ if (!next) -+ break; -+ -+ if (next->header.type != cmdline_is_bfd_enum) -+ abort (); -+ -+ next = next->header.next; -+ if (!next) -+ break; -+ nbfd = next->abfd.abfd; -+ narchive = bfd_my_archive (nbfd); -+ } -+ while (strcmp (archive->filename, narchive->filename) == 0); -+ } -+ } -+ -+ struct cmdline_arg -+ { -+ bfd *obfd; -+ asymbol **isympp; -+ int status; -+ }; -+ -+ /* Create a section in OBFD with the same -+ name and attributes as ISECTION in IBFD. */ -+ -+ static void -+ setup_section (bfd *ibfd, sec_ptr isection, void *p) -+ { -+ struct cmdline_arg *arg = (struct cmdline_arg *) p; -+ bfd *obfd = arg->obfd; -+ asymbol **isympp = arg->isympp; -+ const char *name = isection->name; -+ sec_ptr osection; -+ const char *err; -+ -+ /* Skip the object-only section. */ -+ if (ibfd->object_only_section == isection) -+ return; -+ -+ /* If we have already failed earlier on, do not keep on generating -+ complaints now. */ -+ if (arg->status) -+ return; -+ -+ osection = bfd_make_section_anyway_with_flags (obfd, name, -+ isection->flags); -+ -+ if (osection == NULL) -+ { -+ err = _("failed to create output section"); -+ goto loser; -+ } -+ -+ osection->size = isection->size; -+ osection->vma = isection->vma; -+ osection->lma = isection->lma; -+ osection->alignment_power = isection->alignment_power; -+ -+ /* Copy merge entity size. */ -+ osection->entsize = isection->entsize; -+ -+ /* This used to be mangle_section; we do here to avoid using -+ bfd_get_section_by_name since some formats allow multiple -+ sections with the same name. */ -+ isection->output_section = osection; -+ isection->output_offset = 0; -+ -+ if ((isection->flags & SEC_GROUP) != 0) -+ { -+ asymbol *gsym = bfd_group_signature (isection, isympp); -+ -+ if (gsym != NULL) -+ { -+ gsym->flags |= BSF_KEEP; -+ if (ibfd->xvec->flavour == bfd_target_elf_flavour) -+ elf_group_id (isection) = gsym; -+ } -+ } -+ -+ /* Allow the BFD backend to copy any private data it understands -+ from the input section to the output section. */ -+ if (!bfd_copy_private_section_data (ibfd, isection, obfd, osection)) -+ { -+ err = _("failed to copy private data"); -+ goto loser; -+ } -+ -+ /* All went well. */ -+ return; -+ -+ loser: -+ arg->status = 1; -+ einfo (_("%P%F: setup_section: %s: %s\n"), err, name); -+ } -+ -+ /* Copy the data of input section ISECTION of IBFD -+ to an output section with the same name in OBFD. -+ If stripping then don't copy any relocation info. */ -+ -+ static void -+ copy_section (bfd *ibfd, sec_ptr isection, void *p) -+ { -+ struct cmdline_arg *arg = (struct cmdline_arg *) p; -+ bfd *obfd = arg->obfd; -+ asymbol **isympp = arg->isympp; -+ arelent **relpp; -+ long relcount; -+ sec_ptr osection; -+ bfd_size_type size; -+ long relsize; -+ flagword flags; -+ const char *err; -+ -+ /* Skip the object-only section. */ -+ if (ibfd->object_only_section == isection) -+ return; -+ -+ /* If we have already failed earlier on, do not keep on generating -+ complaints now. */ -+ if (arg->status) -+ return; -+ -+ flags = bfd_get_section_flags (ibfd, isection); -+ if ((flags & SEC_GROUP) != 0) -+ return; -+ -+ osection = isection->output_section; -+ size = bfd_get_section_size (isection); -+ -+ if (size == 0 || osection == 0) -+ return; -+ -+ relsize = bfd_get_reloc_upper_bound (ibfd, isection); -+ -+ if (relsize < 0) -+ { -+ /* Do not complain if the target does not support relocations. */ -+ if (relsize == -1 -+ && bfd_get_error () == bfd_error_invalid_operation) -+ relsize = 0; -+ else -+ { -+ err = bfd_errmsg (bfd_get_error ()); -+ goto loser; -+ } -+ } -+ -+ if (relsize == 0) -+ bfd_set_reloc (obfd, osection, NULL, 0); -+ else -+ { -+ relpp = (arelent **) xmalloc (relsize); -+ relcount = bfd_canonicalize_reloc (ibfd, isection, relpp, isympp); -+ if (relcount < 0) -+ { -+ err = _("relocation count is negative"); -+ goto loser; -+ } -+ -+ bfd_set_reloc (obfd, osection, -+ relcount == 0 ? NULL : relpp, relcount); -+ if (relcount == 0) -+ free (relpp); -+ } -+ -+ if (bfd_get_section_flags (ibfd, isection) & SEC_HAS_CONTENTS) -+ { -+ bfd_byte *memhunk = NULL; -+ -+ if (!bfd_get_full_section_contents (ibfd, isection, &memhunk)) -+ { -+ err = bfd_errmsg (bfd_get_error ()); -+ goto loser; -+ } -+ -+ if (!bfd_set_section_contents (obfd, osection, memhunk, 0, size)) -+ { -+ err = bfd_errmsg (bfd_get_error ()); -+ goto loser; -+ } -+ free (memhunk); -+ } -+ -+ /* All went well. */ -+ return; -+ -+ loser: -+ einfo (_("%P%F: copy_section: %s: %s\n"), err, isection->name); -+ } -+ /* Open the temporary bfd created in the same directory as PATH. */ -+ -+ static bfd * -+ cmdline_fopen_temp (const char *path, const char *target, -+ const char *mode) -+ { -+ #define template "ldXXXXXX" -+ const char *slash = strrchr (path, '/'); -+ char *tmpname; -+ size_t len; -+ int fd; -+ -+ #ifdef HAVE_DOS_BASED_FILE_SYSTEM -+ { -+ /* We could have foo/bar\\baz, or foo\\bar, or d:bar. */ -+ char *bslash = strrchr (path, '\\'); -+ -+ if (slash == NULL || (bslash != NULL && bslash > slash)) -+ slash = bslash; -+ if (slash == NULL && path[0] != '\0' && path[1] == ':') -+ slash = path + 1; -+ } -+ #endif -+ -+ if (slash != (char *) NULL) -+ { -+ len = slash - path; -+ tmpname = (char *) xmalloc (len + sizeof (template) + 2); -+ memcpy (tmpname, path, len); -+ -+ #ifdef HAVE_DOS_BASED_FILE_SYSTEM -+ /* If tmpname is "X:", appending a slash will make it a root -+ directory on drive X, which is NOT the same as the current -+ directory on drive X. */ -+ if (len == 2 && tmpname[1] == ':') -+ tmpname[len++] = '.'; -+ #endif -+ tmpname[len++] = '/'; -+ } -+ else -+ { -+ tmpname = (char *) xmalloc (sizeof (template)); -+ len = 0; -+ } -+ -+ memcpy (tmpname + len, template, sizeof (template)); -+ #undef template -+ -+ #ifdef HAVE_MKSTEMP -+ fd = mkstemp (tmpname); -+ #else -+ tmpname = mktemp (tmpname); -+ if (tmpname == NULL) -+ return NULL; -+ fd = open (tmpname, O_RDWR | O_CREAT | O_EXCL, 0600); -+ #endif -+ if (fd == -1) -+ return NULL; -+ return bfd_fopen (tmpname, target, mode, fd); -+ } -+ -+ /* Add the object-only section. */ -+ -+ static void -+ cmdline_add_object_only_section (bfd_byte *contents, size_t size) -+ { -+ bfd_vma start; -+ flagword flags; -+ enum bfd_architecture iarch; -+ unsigned int imach; -+ long symcount; -+ long symsize; -+ asymbol **isympp = NULL; -+ asymbol **osympp = NULL; -+ bfd *obfd = NULL, *ibfd; -+ const char *err; -+ struct arg -+ { -+ bfd *obfd; -+ asymbol **isympp; -+ int status; -+ } arg; -+ char **matching; -+ const char *ofilename = NULL; -+ asection *sec; -+ -+ ibfd = bfd_openr (output_filename, output_target); -+ if (!ibfd) -+ { -+ err = bfd_errmsg (bfd_get_error ()); -+ goto loser; -+ } -+ -+ if (!bfd_check_format_matches (ibfd, bfd_object, &matching)) -+ { -+ err = bfd_errmsg (bfd_get_error ()); -+ goto loser; -+ } -+ -+ obfd = cmdline_fopen_temp (output_filename, output_target, "w"); -+ if (!obfd) -+ { -+ err = bfd_errmsg (bfd_get_error ()); -+ goto loser; -+ } -+ ofilename = bfd_get_filename (obfd); -+ -+ if (!bfd_set_format (obfd, bfd_object)) -+ { -+ err = bfd_errmsg (bfd_get_error ()); -+ goto loser; -+ } -+ -+ /* Copy the start address, flags and architecture of input file to -+ output file. */ -+ flags = bfd_get_file_flags (ibfd); -+ start = bfd_get_start_address (ibfd); -+ iarch = bfd_get_arch (ibfd); -+ imach = bfd_get_mach (ibfd); -+ if (!bfd_set_start_address (obfd, start) -+ || !bfd_set_file_flags (obfd, flags) -+ || !bfd_set_arch_mach (obfd, iarch, imach)) -+ { -+ err = bfd_errmsg (bfd_get_error ()); -+ goto loser; -+ } -+ -+ symsize = bfd_get_symtab_upper_bound (ibfd); -+ if (symsize < 0) -+ { -+ err = bfd_errmsg (bfd_get_error ()); -+ goto loser; -+ } -+ -+ isympp = (asymbol **) xmalloc (symsize); -+ symcount = bfd_canonicalize_symtab (ibfd, isympp); -+ if (symcount < 0) -+ { -+ err = bfd_errmsg (bfd_get_error ()); -+ goto loser; -+ } -+ -+ arg.obfd = obfd; -+ arg.isympp = isympp; -+ arg.status = 0; -+ -+ /* BFD mandates that all output sections be created and sizes set before -+ any output is done. Thus, we traverse all sections multiple times. */ -+ bfd_map_over_sections (ibfd, setup_section, &arg); -+ -+ if (arg.status) -+ { -+ err = _("error setting up sections"); -+ goto loser; -+ } -+ -+ /* Allow the BFD backend to copy any private data it understands -+ from the input section to the output section. */ -+ if (! bfd_copy_private_header_data (ibfd, obfd)) -+ { -+ err = _("error copying private header data"); -+ goto loser; -+ } -+ -+ /* Create the object-only section. */ -+ sec = bfd_make_section_with_flags (obfd, -+ GNU_OBJECT_ONLY_SECTION_NAME, -+ (SEC_HAS_CONTENTS -+ | SEC_READONLY -+ | SEC_DATA -+ | SEC_LINKER_CREATED)); -+ if (sec == NULL) -+ { -+ err = _("can't create object-only section"); -+ goto loser; -+ } -+ -+ if (! bfd_set_section_size (obfd, sec, size)) -+ { -+ err = _("can't set object-only section size"); -+ goto loser; -+ } -+ -+ if (ibfd->object_only_section) -+ { -+ /* Filter out the object-only section symbol. */ -+ long src_count = 0, dst_count = 0; -+ asymbol **from, **to; -+ -+ osympp = (asymbol **) xmalloc (symcount * sizeof (asymbol *)); -+ from = isympp; -+ to = osympp; -+ for (; src_count < symcount; src_count++) -+ { -+ asymbol *sym = from[src_count]; -+ if (bfd_get_section (sym) != ibfd->object_only_section) -+ to[dst_count++] = sym; -+ } -+ to[dst_count] = NULL; -+ symcount = dst_count; -+ bfd_set_symtab (obfd, osympp, symcount); -+ } -+ else -+ bfd_set_symtab (obfd, isympp, symcount); -+ -+ /* This has to happen after the symbol table has been set. */ -+ bfd_map_over_sections (ibfd, copy_section, &arg); -+ -+ if (arg.status) -+ { -+ err = _("error copying sections"); -+ goto loser; -+ } -+ -+ /* Copy the object-only section to the output. */ -+ if (! bfd_set_section_contents (obfd, sec, contents, 0, size)) -+ { -+ err = _("error adding object-only section"); -+ goto loser; -+ } -+ -+ /* Allow the BFD backend to copy any private data it understands -+ from the input BFD to the output BFD. This is done last to -+ permit the routine to look at the filtered symbol table, which is -+ important for the ECOFF code at least. */ -+ if (! bfd_copy_private_bfd_data (ibfd, obfd)) -+ { -+ err = _("error copying private BFD data"); -+ goto loser; -+ } -+ -+ if (!bfd_close (obfd)) -+ { -+ unlink (ofilename); -+ einfo (_("%P%F: failed to finish output with object-only section\n")); -+ } -+ -+ /* Must be freed after bfd_close (). */ -+ free (isympp); -+ if (osympp) -+ free (osympp); -+ -+ if (rename (ofilename, output_filename)) -+ { -+ unlink (ofilename); -+ einfo (_("%P%F: failed to rename output with object-only section\n")); -+ } -+ -+ return; -+ -+ loser: -+ if (isympp) -+ free (isympp); -+ if (osympp) -+ free (osympp); -+ if (obfd) -+ bfd_close (obfd); -+ if (ofilename) -+ unlink (ofilename); -+ einfo (_("%P%F: failed to add object-only section: %s\n"), err); -+ } -+ -+ /* Emit the final output with object-only section. */ -+ -+ void -+ cmdline_emit_object_only_section (void) -+ { -+ const char *saved_output_filename = output_filename; -+ int fd; -+ size_t size, off; -+ bfd_byte *contents; -+ struct stat st; -+ -+ /* Get a temporary object-only file. */ -+ output_filename = make_temp_file (".obj-only.o"); -+ -+ had_output_filename = FALSE; -+ link_info.input_bfds = NULL; -+ link_info.input_bfds_tail = &link_info.input_bfds; -+ -+ lang_init (TRUE); -+ -+ ld_parse_linker_script (); -+ -+ /* Set up the object-only output. */ -+ lang_final (); -+ -+ /* Open the object-only file for output. */ -+ lang_for_each_statement (ldlang_open_output); -+ -+ ldemul_create_output_section_statements (); -+ -+ if (!bfd_section_already_linked_table_init ()) -+ einfo (_("%P%F: Failed to create hash table\n")); -+ -+ /* Call cmdline_on_object_only_archive_list_p to check which member -+ should be loaded. */ -+ input_flags.whole_archive = TRUE; -+ -+ /* Set it to avoid adding more to cmdline lists. */ -+ link_info.emitting_gnu_object_only = TRUE; -+ -+ cmdline_get_object_only_input_files (); -+ -+ open_input_bfds (statement_list.head, FALSE); -+ -+ ldemul_after_open (); -+ -+ bfd_section_already_linked_table_free (); -+ -+ /* Make sure that we're not mixing architectures. We call this -+ after all the input files have been opened, but before we do any -+ other processing, so that any operations merge_private_bfd_data -+ does on the output file will be known during the rest of the -+ link. */ -+ lang_check (); -+ -+ /* Size up the common data. */ -+ lang_common (); -+ -+ /* Update wild statements. */ -+ update_wild_statements (statement_list.head); -+ -+ /* Run through the contours of the script and attach input sections -+ to the correct output sections. */ -+ map_input_to_output_sections (statement_list.head, NULL, NULL); -+ -+ /* Find any sections not attached explicitly and handle them. */ -+ lang_place_orphans (); -+ -+ /* Do anything special before sizing sections. This is where ELF -+ and other back-ends size dynamic sections. */ -+ ldemul_before_allocation (); -+ -+ /* Size up the sections. */ -+ lang_size_sections (NULL, ! RELAXATION_ENABLED); -+ -+ /* See if anything special should be done now we know how big -+ everything is. This is where relaxation is done. */ -+ ldemul_after_allocation (); -+ -+ ldemul_finish (); -+ -+ /* Make sure that the section addresses make sense. */ -+ if (command_line.check_section_addresses) -+ lang_check_section_addresses (); -+ -+ lang_end (); +--- a/ld/ldlang.c 2013-05-14 16:39:39.704718176 +0100 ++++ b/ld/ldlang.c 2013-05-14 17:03:54.030758491 +0100 +@@ -38,6 +38,7 @@ + #include "ldctor.h" + #include "ldfile.h" + #include "ldemul.h" ++#include "ldwrite.h" + #include "fnmatch.h" + #include "demangle.h" + #include "hashtab.h" +@@ -46,6 +47,9 @@ + #include "plugin.h" + #endif /* ENABLE_PLUGINS */ + ++/* FIXME: Put it here to avoid NAME conflict from ldgram.h. */ ++#include "elf-bfd.h" ++ + #ifndef offsetof + #define offsetof(TYPE, MEMBER) ((size_t) & (((TYPE*) 0)->MEMBER)) + #endif +@@ -69,6 +73,9 @@ + static lang_statement_list_type *stat_save[10]; + static lang_statement_list_type **stat_save_ptr = &stat_save[0]; + static struct unique_sections *unique_section_list; ++static cmdline_list_type cmdline_object_only_file_list; ++static cmdline_list_type cmdline_object_only_archive_list; ++static cmdline_list_type cmdline_temp_object_only_list; + + /* Forward declarations. */ + static void exp_init_os (etree_type *); +@@ -89,6 +96,10 @@ + static void lang_do_version_exports_section (void); + static void lang_finalize_version_expr_head + (struct bfd_elf_version_expr_head *); ++static void cmdline_lists_init (void); ++static void cmdline_get_object_only_input_files (void); ++static void print_cmdline_list (cmdline_union_type *); ++static bfd_boolean cmdline_on_object_only_archive_list_p (bfd *); + + /* Exported variables. */ + const char *output_target; +@@ -1204,14 +1215,17 @@ + /* Build enough state so that the parser can build its tree. */ + + void +-lang_init (void) ++lang_init (bfd_boolean object_only) + { +- obstack_begin (&stat_obstack, 1000); ++ if (!object_only) ++ obstack_begin (&stat_obstack, 1000); + + stat_ptr = &statement_list; + + output_section_statement_table_init (); + ++ cmdline_lists_init (); ++ + lang_list_init (stat_ptr); + + lang_list_init (&input_file_chain); +@@ -1230,10 +1244,11 @@ + simpler to re-use working machinery than using a linked list in terms + of code-complexity here in ld, besides the initialization which just + looks like other code here. */ +- if (!bfd_hash_table_init_n (&lang_definedness_table, +- lang_definedness_newfunc, +- sizeof (struct lang_definedness_hash_entry), +- 3)) ++ if (!object_only ++ && !bfd_hash_table_init_n (&lang_definedness_table, ++ lang_definedness_newfunc, ++ sizeof (struct lang_definedness_hash_entry), ++ 3)) + einfo (_("%P%F: can not create hash table: %E\n")); + } + +@@ -2769,6 +2784,12 @@ + loaded = FALSE; + } + ++ if (link_info.emitting_gnu_object_only) ++ { ++ if (!cmdline_on_object_only_archive_list_p (member)) ++ continue; ++ } ++ + subsbfd = member; + if (!(*link_info.callbacks + ->add_archive_element) (&link_info, member, +@@ -6659,7 +6680,37 @@ + open_input_bfds (statement_list.head, OPEN_BFD_RESCAN); + } + } ++ else + #endif /* ENABLE_PLUGINS */ ++ if (link_info.relocatable) ++ { ++ /* Check if .gnu_object_only section should be created. */ ++ bfd *p; ++ int object_type; ++ ++ object_type = 0; ++ for (p = link_info.input_bfds; p != (bfd *) NULL; p = p->link_next) ++ { ++ object_type |= 1 << p->lto_type; ++ if ((object_type & (1 << lto_mixed_object)) != 0 ++ || ((object_type ++ & (1 << lto_non_ir_object ++ | 1 << lto_ir_object)) ++ == (1 << lto_non_ir_object | 1 << lto_ir_object))) ++ { ++ link_info.emit_gnu_object_only = TRUE; ++ break; ++ } ++ } ++ ++ if (trace_files ++ && (cmdline_object_only_file_list.head ++ || cmdline_object_only_archive_list.head)) ++ { ++ print_cmdline_list (cmdline_object_only_file_list.head); ++ print_cmdline_list (cmdline_object_only_archive_list.head); ++ } ++ } + + link_info.gc_sym_list = &entry_symbol; + if (entry_symbol.name == NULL) +@@ -8059,3 +8111,961 @@ + p = q; + } + } ++ ++static void ++cmdline_lists_init (void) ++{ ++ cmdline_object_only_file_list.tail ++ = &cmdline_object_only_file_list.head; ++ cmdline_object_only_archive_list.tail ++ = &cmdline_object_only_archive_list.head; ++ cmdline_temp_object_only_list.tail ++ = &cmdline_temp_object_only_list.head; ++} ++ ++/* Allocate an item with TYPE and DATA. */ ++ ++static cmdline_union_type * ++cmdline_list_new (cmdline_enum_type type, void *data) ++{ ++ cmdline_union_type *new_opt; ++ ++ new_opt = (cmdline_union_type *) stat_alloc (sizeof (*new_opt)); ++ new_opt->header.type = type; ++ switch (type) ++ { ++ default: ++ break; ++ case cmdline_is_file_enum: ++ new_opt->file.filename = (const char *) data; ++ break; ++ case cmdline_is_bfd_enum: ++ new_opt->abfd.abfd = (bfd *) data; ++ break; ++ } ++ return new_opt; ++} ++ ++/* Append an item with TYPE and DATA to LIST. */ ++ ++static void ++cmdline_list_append (cmdline_list_type *list, cmdline_enum_type type, ++ void *data) ++{ ++ cmdline_union_type *new_opt = cmdline_list_new (type, data); ++ new_opt->header.next = NULL; ++ *list->tail = new_opt; ++ list->tail = &new_opt->header.next; ++} ++ ++static void ++print_cmdline_list (cmdline_union_type *c) ++{ ++ for (; c != NULL; c = c->header.next) ++ switch (c->header.type) ++ { ++ default: ++ abort (); ++ case cmdline_is_file_enum: ++ info_msg (" %s", c->file.filename); ++ break; ++ case cmdline_is_bfd_enum: ++ info_msg (" [%B]", c->abfd.abfd); ++ break; ++ } ++ ++ info_msg ("\n"); ++} ++ ++/* Return TRUE if ABFD is on cmdline_object_only_archive_list. */ ++ ++static bfd_boolean ++cmdline_on_object_only_archive_list_p (bfd *abfd) ++{ ++ cmdline_union_type *c, *next; ++ bfd *archive, *obfd, *oarchive; ++ ufile_ptr origin = abfd->origin; ++ ++ archive = bfd_my_archive (abfd); ++ for (c = cmdline_object_only_archive_list.head; c != NULL; c = next) ++ { ++ if (c->header.type != cmdline_is_bfd_enum) ++ abort (); ++ ++ next = c->header.next; ++ obfd = c->abfd.abfd; ++ oarchive = bfd_my_archive (obfd); ++ ++ /* The list is grouped by archive file name and sorted by member ++ origin. */ ++ if (strcmp (archive->filename, oarchive->filename) != 0) ++ continue; ++ ++ if (origin == obfd->origin) ++ return TRUE; ++ else if (origin < obfd->origin) ++ return FALSE; ++ } ++ ++ return FALSE; ++} ++ ++/* Append an item with TYPE and DATA to cmdline_object_only_file_list ++ or cmdline_object_only_archive_list if needed. */ ++ ++static void ++cmdline_object_only_list_append (cmdline_enum_type type, void *data) ++{ ++ cmdline_union_type *c; ++ cmdline_union_type *new_opt, *next, **prev; ++ bfd *abfd, *archive; ++ bfd *obfd, *oarchive; ++ bfd *nbfd, *narchive; ++ ufile_ptr origin, norigin; ++ ++ /* Put it on cmdline_object_only_file_list if it isn't an archive ++ member. */ ++ switch (type) ++ { ++ default: ++ abort (); ++ case cmdline_is_bfd_enum: ++ abfd = (bfd *) data; ++ archive = bfd_my_archive (abfd); ++ if (archive) ++ break; ++ case cmdline_is_file_enum: ++ cmdline_list_append (&cmdline_object_only_file_list, type, data); ++ return; ++ } ++ ++ /* Put archive member on cmdline_object_only_archive_list and sort ++ the list by archive name and archive member origin. */ ++ new_opt = (cmdline_union_type *) stat_alloc (sizeof (*new_opt)); ++ new_opt->header.type = cmdline_is_bfd_enum; ++ new_opt->header.next = NULL; ++ new_opt->abfd.abfd = (bfd *) data; ++ ++ c = cmdline_object_only_archive_list.head; ++ if (c == NULL) ++ { ++ cmdline_object_only_archive_list.head = new_opt; ++ cmdline_object_only_archive_list.tail = &new_opt->header.next; ++ return; ++ } ++ ++ prev = NULL; ++ origin = abfd->origin; ++ for (; c != NULL; c = next) ++ { ++ if (c->header.type != cmdline_is_bfd_enum) ++ abort (); ++ ++ next = c->header.next; ++ ++ obfd = c->abfd.abfd; ++ oarchive = bfd_my_archive (obfd); ++ ++ if (strcmp (archive->filename, oarchive->filename) == 0) ++ { ++ bfd_boolean after; ++ ++ if (origin < obfd->origin) ++ { ++ /* Insert it before the current. */ ++ new_opt->header.next = c; ++ if (prev) ++ *prev = new_opt; ++ else ++ cmdline_object_only_archive_list.head = new_opt; ++ return; ++ } ++ ++ after = TRUE; ++ ++ /* Check origin. */ ++ while (next) ++ { ++ if (next->header.type != cmdline_is_bfd_enum) ++ abort (); ++ ++ nbfd = next->abfd.abfd; ++ norigin = nbfd->origin; ++ if (origin > norigin) ++ { ++ /* Insert it after NEXT. */ ++ break; ++ } ++ ++ narchive = bfd_my_archive (nbfd); ++ if (strcmp (archive->filename, narchive->filename) != 0) ++ { ++ /* Insert it befor NEXT. */ ++ after = FALSE; ++ break; ++ } ++ ++ c = next; ++ next = next->header.next; ++ } ++ ++ if (after && next) ++ { ++ c = next; ++ next = next->header.next; ++ } ++ ++ if (*cmdline_object_only_archive_list.tail == c->header.next) ++ cmdline_object_only_archive_list.tail ++ = &new_opt->header.next; ++ ++ prev = &c->header.next; ++ new_opt->header.next = next; ++ *prev = new_opt; ++ return; ++ } ++ ++ prev = &c->header.next; ++ } ++ ++ *cmdline_object_only_archive_list.tail = new_opt; ++ cmdline_object_only_archive_list.tail = &new_opt->header.next; ++} ++ ++ ++static void ++cmdline_get_object_only_input_files (void) ++{ ++ cmdline_union_type *c, *next; ++ bfd *abfd, *archive; ++ bfd *nbfd, *narchive; ++ ++ /* Add files first. */ ++ for (c = cmdline_object_only_file_list.head; ++ c != NULL; c = c->header.next) ++ switch (c->header.type) ++ { ++ default: ++ abort (); ++ case cmdline_is_file_enum: ++ lang_add_input_file (c->file.filename, ++ lang_input_file_is_file_enum, NULL); ++ break; ++ case cmdline_is_bfd_enum: ++ abfd = c->abfd.abfd; ++ if (bfd_my_archive (abfd)) ++ abort (); ++ lang_add_input_file (abfd->filename, ++ lang_input_file_is_file_enum, NULL); ++ break; ++ } ++ ++ /* Add archive members next. */ ++ for (c = cmdline_object_only_archive_list.head; c != NULL; c = next) ++ { ++ if (c->header.type != cmdline_is_bfd_enum) ++ abort (); ++ ++ next = c->header.next; ++ ++ abfd = c->abfd.abfd; ++ archive = bfd_my_archive (abfd); + -+ ldwrite (); -+ -+ lang_finish (); -+ -+ if (! bfd_close (link_info.output_bfd)) -+ einfo (_("%P%F:%s: final close failed on object-only output: %E\n"), -+ output_filename); -+ -+ /* Read in the object-only file. */ -+ fd = open (output_filename, O_RDONLY | O_BINARY); -+ if (fd < 0) -+ { -+ bfd_set_error (bfd_error_system_call); -+ einfo (_("%P%F:%s: cannot open object-only output: %E"), -+ output_filename); -+ } -+ -+ /* Get the object-only file size. */ -+ if (fstat (fd, &st) != 0) -+ { -+ bfd_set_error (bfd_error_system_call); -+ einfo (_("%P%F:%s: cannot stat object-only output: %E"), -+ output_filename); -+ } -+ -+ size = st.st_size; -+ off = 0; -+ contents = (bfd_byte *) xmalloc (size); -+ while (off != size) -+ { -+ ssize_t got; -+ -+ got = read (fd, contents + off, size - off); -+ if (got < 0) -+ { -+ bfd_set_error (bfd_error_system_call); -+ einfo (_("%P%F:%s: read failed on object-only output: %E"), -+ output_filename); -+ } -+ -+ off += got; -+ } -+ -+ close (fd); -+ -+ /* Remove the temporary object-only file. */ -+ unlink (output_filename); -+ -+ output_filename = saved_output_filename; -+ -+ cmdline_add_object_only_section (contents, size); -+ -+ free (contents); -+ } -+ -+ /* Extract the object-only section. */ -+ -+ static const char * -+ cmdline_extract_object_only_section (bfd *abfd) -+ { -+ const char *name = bfd_extract_object_only_section (abfd); -+ -+ if (name == NULL) -+ einfo (_("%P%F: cannot extract object-only section from %B: %E"), -+ abfd); -+ -+ /* It should be removed after it is done. */ -+ cmdline_list_append (&cmdline_temp_object_only_list, -+ cmdline_is_file_enum, (void *) name); -+ -+ return name; -+ } -+ -+ /* Check and handle the object-only section. */ -+ -+ void -+ cmdline_check_object_only_section (bfd *abfd, bfd_boolean lto) -+ { -+ const char *filename; -+ -+ if (link_info.emitting_gnu_object_only -+ || abfd->format != bfd_object) -+ return; -+ -+ if (lto) -+ { -+ /* For LTO link, we only need to extract object-only section -+ from the mixed object, add it to input, and put it on LTO -+ claimed output. */ -+ switch (abfd->lto_type) -+ { -+ default: -+ abort (); -+ case lto_mixed_object: -+ filename = cmdline_extract_object_only_section (abfd); -+ lang_add_input_file (filename, -+ lang_input_file_is_file_enum, NULL); -+ break; -+ case lto_non_ir_object: -+ case lto_ir_object: -+ break; -+ } -+ } -+ else if (link_info.relocatable) -+ { -+ /* For non-LTO relocatable link, we need to append non-IR object -+ file and the object file in object-only section to the object -+ only list. */ -+ switch (abfd->lto_type) -+ { -+ default: -+ abort (); -+ case lto_mixed_object: -+ filename = cmdline_extract_object_only_section (abfd); -+ cmdline_object_only_list_append (cmdline_is_file_enum, -+ (void *) filename); -+ break; -+ case lto_non_ir_object: -+ cmdline_object_only_list_append (cmdline_is_bfd_enum, abfd); -+ break; -+ case lto_ir_object: -+ break; -+ } -+ } -+ } -+ -+ /* Remove temporary object-only files. */ -+ -+ void -+ cmdline_remove_object_only_files (void) -+ { -+ cmdline_union_type *c; -+ -+ #ifdef ENABLE_PLUGINS -+ if (plugin_save_temps) -+ return; -+ #endif -+ -+ c = cmdline_temp_object_only_list.head; -+ for (; c != NULL; c = c->header.next) -+ switch (c->header.type) -+ { -+ default: -+ abort (); -+ case cmdline_is_file_enum: -+ unlink (c->file.filename); -+ break; -+ } -+ } -+ -+ -+ ++ /* Add the first archive of the archive member group. */ ++ lang_add_input_file (archive->filename, ++ lang_input_file_is_file_enum, NULL); ++ ++ /* Skip the rest members in the archive member group. */ ++ do ++ { ++ if (!next) ++ break; ++ ++ if (next->header.type != cmdline_is_bfd_enum) ++ abort (); ++ ++ next = next->header.next; ++ if (!next) ++ break; ++ nbfd = next->abfd.abfd; ++ narchive = bfd_my_archive (nbfd); ++ } ++ while (strcmp (archive->filename, narchive->filename) == 0); ++ } ++} ++ ++struct cmdline_arg ++{ ++ bfd *obfd; ++ asymbol **isympp; ++ int status; ++}; ++ ++/* Create a section in OBFD with the same ++ name and attributes as ISECTION in IBFD. */ ++ ++static void ++setup_section (bfd *ibfd, sec_ptr isection, void *p) ++{ ++ struct cmdline_arg *arg = (struct cmdline_arg *) p; ++ bfd *obfd = arg->obfd; ++ asymbol **isympp = arg->isympp; ++ const char *name = isection->name; ++ sec_ptr osection; ++ const char *err; ++ ++ /* Skip the object-only section. */ ++ if (ibfd->object_only_section == isection) ++ return; ++ ++ /* If we have already failed earlier on, do not keep on generating ++ complaints now. */ ++ if (arg->status) ++ return; ++ ++ osection = bfd_make_section_anyway_with_flags (obfd, name, ++ isection->flags); ++ ++ if (osection == NULL) ++ { ++ err = _("failed to create output section"); ++ goto loser; ++ } ++ ++ osection->size = isection->size; ++ osection->vma = isection->vma; ++ osection->lma = isection->lma; ++ osection->alignment_power = isection->alignment_power; ++ ++ /* Copy merge entity size. */ ++ osection->entsize = isection->entsize; ++ ++ /* This used to be mangle_section; we do here to avoid using ++ bfd_get_section_by_name since some formats allow multiple ++ sections with the same name. */ ++ isection->output_section = osection; ++ isection->output_offset = 0; ++ ++ if ((isection->flags & SEC_GROUP) != 0) ++ { ++ asymbol *gsym = bfd_group_signature (isection, isympp); ++ ++ if (gsym != NULL) ++ { ++ gsym->flags |= BSF_KEEP; ++ if (ibfd->xvec->flavour == bfd_target_elf_flavour) ++ elf_group_id (isection) = gsym; ++ } ++ } ++ ++ /* Allow the BFD backend to copy any private data it understands ++ from the input section to the output section. */ ++ if (!bfd_copy_private_section_data (ibfd, isection, obfd, osection)) ++ { ++ err = _("failed to copy private data"); ++ goto loser; ++ } ++ ++ /* All went well. */ ++ return; ++ ++loser: ++ arg->status = 1; ++ einfo (_("%P%F: setup_section: %s: %s\n"), err, name); ++} ++ ++/* Copy the data of input section ISECTION of IBFD ++ to an output section with the same name in OBFD. ++ If stripping then don't copy any relocation info. */ ++ ++static void ++copy_section (bfd *ibfd, sec_ptr isection, void *p) ++{ ++ struct cmdline_arg *arg = (struct cmdline_arg *) p; ++ bfd *obfd = arg->obfd; ++ asymbol **isympp = arg->isympp; ++ arelent **relpp; ++ long relcount; ++ sec_ptr osection; ++ bfd_size_type size; ++ long relsize; ++ flagword flags; ++ const char *err; ++ ++ /* Skip the object-only section. */ ++ if (ibfd->object_only_section == isection) ++ return; ++ ++ /* If we have already failed earlier on, do not keep on generating ++ complaints now. */ ++ if (arg->status) ++ return; ++ ++ flags = bfd_get_section_flags (ibfd, isection); ++ if ((flags & SEC_GROUP) != 0) ++ return; ++ ++ osection = isection->output_section; ++ size = bfd_get_section_size (isection); ++ ++ if (size == 0 || osection == 0) ++ return; ++ ++ relsize = bfd_get_reloc_upper_bound (ibfd, isection); ++ ++ if (relsize < 0) ++ { ++ /* Do not complain if the target does not support relocations. */ ++ if (relsize == -1 ++ && bfd_get_error () == bfd_error_invalid_operation) ++ relsize = 0; ++ else ++ { ++ err = bfd_errmsg (bfd_get_error ()); ++ goto loser; ++ } ++ } ++ ++ if (relsize == 0) ++ bfd_set_reloc (obfd, osection, NULL, 0); ++ else ++ { ++ relpp = (arelent **) xmalloc (relsize); ++ relcount = bfd_canonicalize_reloc (ibfd, isection, relpp, isympp); ++ if (relcount < 0) ++ { ++ err = _("relocation count is negative"); ++ goto loser; ++ } ++ ++ bfd_set_reloc (obfd, osection, ++ relcount == 0 ? NULL : relpp, relcount); ++ if (relcount == 0) ++ free (relpp); ++ } ++ ++ if (bfd_get_section_flags (ibfd, isection) & SEC_HAS_CONTENTS) ++ { ++ bfd_byte *memhunk = NULL; ++ ++ if (!bfd_get_full_section_contents (ibfd, isection, &memhunk)) ++ { ++ err = bfd_errmsg (bfd_get_error ()); ++ goto loser; ++ } ++ ++ if (!bfd_set_section_contents (obfd, osection, memhunk, 0, size)) ++ { ++ err = bfd_errmsg (bfd_get_error ()); ++ goto loser; ++ } ++ free (memhunk); ++ } ++ ++ /* All went well. */ ++ return; ++ ++loser: ++ einfo (_("%P%F: copy_section: %s: %s\n"), err, isection->name); ++} ++/* Open the temporary bfd created in the same directory as PATH. */ ++ ++static bfd * ++cmdline_fopen_temp (const char *path, const char *target, ++ const char *mode) ++{ ++#define template "ldXXXXXX" ++ const char *slash = strrchr (path, '/'); ++ char *tmpname; ++ size_t len; ++ int fd; ++ ++#ifdef HAVE_DOS_BASED_FILE_SYSTEM ++ { ++ /* We could have foo/bar\\baz, or foo\\bar, or d:bar. */ ++ char *bslash = strrchr (path, '\\'); ++ ++ if (slash == NULL || (bslash != NULL && bslash > slash)) ++ slash = bslash; ++ if (slash == NULL && path[0] != '\0' && path[1] == ':') ++ slash = path + 1; ++ } ++#endif ++ ++ if (slash != (char *) NULL) ++ { ++ len = slash - path; ++ tmpname = (char *) xmalloc (len + sizeof (template) + 2); ++ memcpy (tmpname, path, len); ++ ++#ifdef HAVE_DOS_BASED_FILE_SYSTEM ++ /* If tmpname is "X:", appending a slash will make it a root ++ directory on drive X, which is NOT the same as the current ++ directory on drive X. */ ++ if (len == 2 && tmpname[1] == ':') ++ tmpname[len++] = '.'; ++#endif ++ tmpname[len++] = '/'; ++ } ++ else ++ { ++ tmpname = (char *) xmalloc (sizeof (template)); ++ len = 0; ++ } ++ ++ memcpy (tmpname + len, template, sizeof (template)); ++#undef template ++ ++#ifdef HAVE_MKSTEMP ++ fd = mkstemp (tmpname); ++#else ++ tmpname = mktemp (tmpname); ++ if (tmpname == NULL) ++ return NULL; ++ fd = open (tmpname, O_RDWR | O_CREAT | O_EXCL, 0600); ++#endif ++ if (fd == -1) ++ return NULL; ++ return bfd_fopen (tmpname, target, mode, fd); ++} ++ ++/* Add the object-only section. */ ++ ++static void ++cmdline_add_object_only_section (bfd_byte *contents, size_t size) ++{ ++ bfd_vma start; ++ flagword flags; ++ enum bfd_architecture iarch; ++ unsigned int imach; ++ long symcount; ++ long symsize; ++ asymbol **isympp = NULL; ++ asymbol **osympp = NULL; ++ bfd *obfd = NULL, *ibfd; ++ const char *err; ++ struct arg ++ { ++ bfd *obfd; ++ asymbol **isympp; ++ int status; ++ } arg; ++ char **matching; ++ const char *ofilename = NULL; ++ asection *sec; ++ ++ ibfd = bfd_openr (output_filename, output_target); ++ if (!ibfd) ++ { ++ err = bfd_errmsg (bfd_get_error ()); ++ goto loser; ++ } ++ ++ if (!bfd_check_format_matches (ibfd, bfd_object, &matching)) ++ { ++ err = bfd_errmsg (bfd_get_error ()); ++ goto loser; ++ } ++ ++ obfd = cmdline_fopen_temp (output_filename, output_target, "w"); ++ if (!obfd) ++ { ++ err = bfd_errmsg (bfd_get_error ()); ++ goto loser; ++ } ++ ofilename = bfd_get_filename (obfd); ++ ++ if (!bfd_set_format (obfd, bfd_object)) ++ { ++ err = bfd_errmsg (bfd_get_error ()); ++ goto loser; ++ } ++ ++ /* Copy the start address, flags and architecture of input file to ++ output file. */ ++ flags = bfd_get_file_flags (ibfd); ++ start = bfd_get_start_address (ibfd); ++ iarch = bfd_get_arch (ibfd); ++ imach = bfd_get_mach (ibfd); ++ if (!bfd_set_start_address (obfd, start) ++ || !bfd_set_file_flags (obfd, flags) ++ || !bfd_set_arch_mach (obfd, iarch, imach)) ++ { ++ err = bfd_errmsg (bfd_get_error ()); ++ goto loser; ++ } ++ ++ symsize = bfd_get_symtab_upper_bound (ibfd); ++ if (symsize < 0) ++ { ++ err = bfd_errmsg (bfd_get_error ()); ++ goto loser; ++ } ++ ++ isympp = (asymbol **) xmalloc (symsize); ++ symcount = bfd_canonicalize_symtab (ibfd, isympp); ++ if (symcount < 0) ++ { ++ err = bfd_errmsg (bfd_get_error ()); ++ goto loser; ++ } ++ ++ arg.obfd = obfd; ++ arg.isympp = isympp; ++ arg.status = 0; ++ ++ /* BFD mandates that all output sections be created and sizes set before ++ any output is done. Thus, we traverse all sections multiple times. */ ++ bfd_map_over_sections (ibfd, setup_section, &arg); ++ ++ if (arg.status) ++ { ++ err = _("error setting up sections"); ++ goto loser; ++ } ++ ++ /* Allow the BFD backend to copy any private data it understands ++ from the input section to the output section. */ ++ if (! bfd_copy_private_header_data (ibfd, obfd)) ++ { ++ err = _("error copying private header data"); ++ goto loser; ++ } ++ ++ /* Create the object-only section. */ ++ sec = bfd_make_section_with_flags (obfd, ++ GNU_OBJECT_ONLY_SECTION_NAME, ++ (SEC_HAS_CONTENTS ++ | SEC_READONLY ++ | SEC_DATA ++ | SEC_LINKER_CREATED)); ++ if (sec == NULL) ++ { ++ err = _("can't create object-only section"); ++ goto loser; ++ } ++ ++ if (! bfd_set_section_size (obfd, sec, size)) ++ { ++ err = _("can't set object-only section size"); ++ goto loser; ++ } ++ ++ if (ibfd->object_only_section) ++ { ++ /* Filter out the object-only section symbol. */ ++ long src_count = 0, dst_count = 0; ++ asymbol **from, **to; ++ ++ osympp = (asymbol **) xmalloc (symcount * sizeof (asymbol *)); ++ from = isympp; ++ to = osympp; ++ for (; src_count < symcount; src_count++) ++ { ++ asymbol *sym = from[src_count]; ++ if (bfd_get_section (sym) != ibfd->object_only_section) ++ to[dst_count++] = sym; ++ } ++ to[dst_count] = NULL; ++ symcount = dst_count; ++ bfd_set_symtab (obfd, osympp, symcount); ++ } ++ else ++ bfd_set_symtab (obfd, isympp, symcount); ++ ++ /* This has to happen after the symbol table has been set. */ ++ bfd_map_over_sections (ibfd, copy_section, &arg); ++ ++ if (arg.status) ++ { ++ err = _("error copying sections"); ++ goto loser; ++ } ++ ++ /* Copy the object-only section to the output. */ ++ if (! bfd_set_section_contents (obfd, sec, contents, 0, size)) ++ { ++ err = _("error adding object-only section"); ++ goto loser; ++ } ++ ++ /* Allow the BFD backend to copy any private data it understands ++ from the input BFD to the output BFD. This is done last to ++ permit the routine to look at the filtered symbol table, which is ++ important for the ECOFF code at least. */ ++ if (! bfd_copy_private_bfd_data (ibfd, obfd)) ++ { ++ err = _("error copying private BFD data"); ++ goto loser; ++ } ++ ++ if (!bfd_close (obfd)) ++ { ++ unlink (ofilename); ++ einfo (_("%P%F: failed to finish output with object-only section\n")); ++ } ++ ++ /* Must be freed after bfd_close (). */ ++ free (isympp); ++ if (osympp) ++ free (osympp); ++ ++ if (rename (ofilename, output_filename)) ++ { ++ unlink (ofilename); ++ einfo (_("%P%F: failed to rename output with object-only section\n")); ++ } ++ ++ return; ++ ++loser: ++ if (isympp) ++ free (isympp); ++ if (osympp) ++ free (osympp); ++ if (obfd) ++ bfd_close (obfd); ++ if (ofilename) ++ unlink (ofilename); ++ einfo (_("%P%F: failed to add object-only section: %s\n"), err); ++} ++ ++/* Emit the final output with object-only section. */ ++ ++void ++cmdline_emit_object_only_section (void) ++{ ++ const char *saved_output_filename = output_filename; ++ int fd; ++ size_t size, off; ++ bfd_byte *contents; ++ struct stat st; ++ ++ /* Get a temporary object-only file. */ ++ output_filename = make_temp_file (".obj-only.o"); ++ ++ had_output_filename = FALSE; ++ link_info.input_bfds = NULL; ++ link_info.input_bfds_tail = &link_info.input_bfds; ++ ++ lang_init (TRUE); ++ ++ ld_parse_linker_script (); ++ ++ /* Set up the object-only output. */ ++ lang_final (); ++ ++ /* Open the object-only file for output. */ ++ lang_for_each_statement (ldlang_open_output); ++ ++ ldemul_create_output_section_statements (); ++ ++ if (!bfd_section_already_linked_table_init ()) ++ einfo (_("%P%F: Failed to create hash table\n")); ++ ++ /* Call cmdline_on_object_only_archive_list_p to check which member ++ should be loaded. */ ++ input_flags.whole_archive = TRUE; ++ ++ /* Set it to avoid adding more to cmdline lists. */ ++ link_info.emitting_gnu_object_only = TRUE; ++ ++ cmdline_get_object_only_input_files (); ++ ++ open_input_bfds (statement_list.head, FALSE); ++ ++ ldemul_after_open (); ++ ++ bfd_section_already_linked_table_free (); ++ ++ /* Make sure that we're not mixing architectures. We call this ++ after all the input files have been opened, but before we do any ++ other processing, so that any operations merge_private_bfd_data ++ does on the output file will be known during the rest of the ++ link. */ ++ lang_check (); ++ ++ /* Size up the common data. */ ++ lang_common (); ++ ++ /* Update wild statements. */ ++ update_wild_statements (statement_list.head); ++ ++ /* Run through the contours of the script and attach input sections ++ to the correct output sections. */ ++ map_input_to_output_sections (statement_list.head, NULL, NULL); ++ ++ /* Find any sections not attached explicitly and handle them. */ ++ lang_place_orphans (); ++ ++ /* Do anything special before sizing sections. This is where ELF ++ and other back-ends size dynamic sections. */ ++ ldemul_before_allocation (); ++ ++ /* Size up the sections. */ ++ lang_size_sections (NULL, ! RELAXATION_ENABLED); ++ ++ /* See if anything special should be done now we know how big ++ everything is. This is where relaxation is done. */ ++ ldemul_after_allocation (); ++ ++ ldemul_finish (); ++ ++ /* Make sure that the section addresses make sense. */ ++ if (command_line.check_section_addresses) ++ lang_check_section_addresses (); ++ ++ lang_end (); ++ ++ ldwrite (); ++ ++ lang_finish (); ++ ++ if (! bfd_close (link_info.output_bfd)) ++ einfo (_("%P%F:%s: final close failed on object-only output: %E\n"), ++ output_filename); ++ ++ /* Read in the object-only file. */ ++ fd = open (output_filename, O_RDONLY | O_BINARY); ++ if (fd < 0) ++ { ++ bfd_set_error (bfd_error_system_call); ++ einfo (_("%P%F:%s: cannot open object-only output: %E"), ++ output_filename); ++ } ++ ++ /* Get the object-only file size. */ ++ if (fstat (fd, &st) != 0) ++ { ++ bfd_set_error (bfd_error_system_call); ++ einfo (_("%P%F:%s: cannot stat object-only output: %E"), ++ output_filename); ++ } ++ ++ size = st.st_size; ++ off = 0; ++ contents = (bfd_byte *) xmalloc (size); ++ while (off != size) ++ { ++ ssize_t got; ++ ++ got = read (fd, contents + off, size - off); ++ if (got < 0) ++ { ++ bfd_set_error (bfd_error_system_call); ++ einfo (_("%P%F:%s: read failed on object-only output: %E"), ++ output_filename); ++ } ++ ++ off += got; ++ } ++ ++ close (fd); ++ ++ /* Remove the temporary object-only file. */ ++ unlink (output_filename); ++ ++ output_filename = saved_output_filename; ++ ++ cmdline_add_object_only_section (contents, size); ++ ++ free (contents); ++} ++ ++/* Extract the object-only section. */ ++ ++static const char * ++cmdline_extract_object_only_section (bfd *abfd) ++{ ++ const char *name = bfd_extract_object_only_section (abfd); ++ ++ if (name == NULL) ++ einfo (_("%P%F: cannot extract object-only section from %B: %E"), ++ abfd); ++ ++ /* It should be removed after it is done. */ ++ cmdline_list_append (&cmdline_temp_object_only_list, ++ cmdline_is_file_enum, (void *) name); ++ ++ return name; ++} ++ ++/* Check and handle the object-only section. */ ++ ++void ++cmdline_check_object_only_section (bfd *abfd, bfd_boolean lto) ++{ ++ const char *filename; ++ ++ if (link_info.emitting_gnu_object_only ++ || abfd->format != bfd_object) ++ return; ++ ++ if (lto) ++ { ++ /* For LTO link, we only need to extract object-only section ++ from the mixed object, add it to input, and put it on LTO ++ claimed output. */ ++ switch (abfd->lto_type) ++ { ++ default: ++ abort (); ++ case lto_mixed_object: ++ filename = cmdline_extract_object_only_section (abfd); ++ lang_add_input_file (filename, ++ lang_input_file_is_file_enum, NULL); ++ break; ++ case lto_non_ir_object: ++ case lto_ir_object: ++ break; ++ } ++ } ++ else if (link_info.relocatable) ++ { ++ /* For non-LTO relocatable link, we need to append non-IR object ++ file and the object file in object-only section to the object ++ only list. */ ++ switch (abfd->lto_type) ++ { ++ default: ++ abort (); ++ case lto_mixed_object: ++ filename = cmdline_extract_object_only_section (abfd); ++ cmdline_object_only_list_append (cmdline_is_file_enum, ++ (void *) filename); ++ break; ++ case lto_non_ir_object: ++ cmdline_object_only_list_append (cmdline_is_bfd_enum, abfd); ++ break; ++ case lto_ir_object: ++ break; ++ } ++ } ++} ++ ++/* Remove temporary object-only files. */ ++ ++void ++cmdline_remove_object_only_files (void) ++{ ++ cmdline_union_type *c; ++ ++#ifdef ENABLE_PLUGINS ++ if (plugin_save_temps) ++ return; ++#endif ++ ++ c = cmdline_temp_object_only_list.head; ++ for (; c != NULL; c = c->header.next) ++ switch (c->header.type) ++ { ++ default: ++ abort (); ++ case cmdline_is_file_enum: ++ unlink (c->file.filename); ++ break; ++ } ++} ++ ++ ++ diff -cpr ../binutils-2.23.2.orig/ld/ldlang.h ld/ldlang.h -*** ../binutils-2.23.2.orig/ld/ldlang.h 2013-05-14 16:39:36.861718097 +0100 ---- ld/ldlang.h 2013-05-14 16:40:07.053718934 +0100 -*************** extern lang_statement_list_type input_fi -*** 488,494 **** - extern int lang_statement_iteration; - - extern void lang_init -! (void); - extern void lang_finish - (void); - extern lang_memory_region_type * lang_memory_region_lookup ---- 488,494 ---- - extern int lang_statement_iteration; - - extern void lang_init -! (bfd_boolean); - extern void lang_finish - (void); - extern lang_memory_region_type * lang_memory_region_lookup -*************** ldlang_override_segment_assignment -*** 664,667 **** ---- 664,708 ---- - extern void - lang_ld_feature (char *); - -+ typedef enum -+ { -+ cmdline_is_file_enum, -+ cmdline_is_bfd_enum -+ } cmdline_enum_type; -+ -+ typedef struct cmdline_header_struct -+ { -+ union cmdline_union *next; -+ cmdline_enum_type type; -+ } cmdline_header_type; -+ -+ typedef struct cmdline_file_struct -+ { -+ cmdline_header_type header; -+ const char *filename; -+ } cmdline_file_type; -+ -+ typedef struct cmdline_bfd_struct -+ { -+ cmdline_header_type header; -+ bfd *abfd; -+ } cmdline_bfd_type; -+ -+ typedef union cmdline_union -+ { -+ cmdline_header_type header; -+ cmdline_file_type file; -+ cmdline_bfd_type abfd; -+ } cmdline_union_type; -+ -+ typedef struct cmdline_list -+ { -+ cmdline_union_type *head; -+ cmdline_union_type **tail; -+ } cmdline_list_type; -+ -+ extern void cmdline_emit_object_only_section (void); -+ extern void cmdline_check_object_only_section (bfd *, bfd_boolean); -+ extern void cmdline_remove_object_only_files (void); -+ - #endif +--- a/ld/ldlang.h 2013-05-14 16:39:36.861718097 +0100 ++++ b/ld/ldlang.h 2013-05-14 16:40:07.053718934 +0100 +@@ -488,7 +488,7 @@ + extern int lang_statement_iteration; + + extern void lang_init +- (void); ++ (bfd_boolean); + extern void lang_finish + (void); + extern lang_memory_region_type * lang_memory_region_lookup +@@ -664,4 +664,45 @@ + extern void + lang_ld_feature (char *); + ++typedef enum ++{ ++ cmdline_is_file_enum, ++ cmdline_is_bfd_enum ++} cmdline_enum_type; ++ ++typedef struct cmdline_header_struct ++{ ++ union cmdline_union *next; ++ cmdline_enum_type type; ++} cmdline_header_type; ++ ++typedef struct cmdline_file_struct ++{ ++ cmdline_header_type header; ++ const char *filename; ++} cmdline_file_type; ++ ++typedef struct cmdline_bfd_struct ++{ ++ cmdline_header_type header; ++ bfd *abfd; ++} cmdline_bfd_type; ++ ++typedef union cmdline_union ++{ ++ cmdline_header_type header; ++ cmdline_file_type file; ++ cmdline_bfd_type abfd; ++} cmdline_union_type; ++ ++typedef struct cmdline_list ++{ ++ cmdline_union_type *head; ++ cmdline_union_type **tail; ++} cmdline_list_type; ++ ++extern void cmdline_emit_object_only_section (void); ++extern void cmdline_check_object_only_section (bfd *, bfd_boolean); ++extern void cmdline_remove_object_only_files (void); ++ + #endif diff -cpr ../binutils-2.23.2.orig/ld/ldlex.h ld/ldlex.h -*** ../binutils-2.23.2.orig/ld/ldlex.h 2013-05-14 16:39:39.789718178 +0100 ---- ld/ldlex.h 2013-05-14 16:47:18.651730898 +0100 -*************** enum option_values -*** 133,138 **** ---- 133,139 ---- - #ifdef ENABLE_PLUGINS - OPTION_PLUGIN, - OPTION_PLUGIN_OPT, -+ OPTION_PLUGIN_SAVE_TEMPS, - #endif /* ENABLE_PLUGINS */ - OPTION_DEFAULT_SCRIPT, - OPTION_PRINT_OUTPUT_FORMAT, +--- a/ld/ldlex.h 2013-05-14 16:39:39.789718178 +0100 ++++ b/ld/ldlex.h 2013-05-14 16:47:18.651730898 +0100 +@@ -133,6 +133,7 @@ + #ifdef ENABLE_PLUGINS + OPTION_PLUGIN, + OPTION_PLUGIN_OPT, ++ OPTION_PLUGIN_SAVE_TEMPS, + #endif /* ENABLE_PLUGINS */ + OPTION_DEFAULT_SCRIPT, + OPTION_PRINT_OUTPUT_FORMAT, diff -cpr ../binutils-2.23.2.orig/ld/ldmain.c ld/ldmain.c -*** ../binutils-2.23.2.orig/ld/ldmain.c 2013-05-14 16:39:36.862718097 +0100 ---- ld/ldmain.c 2013-05-14 16:40:07.055718934 +0100 -*************** main (int argc, char **argv) -*** 219,224 **** ---- 219,227 ---- - - xatexit (ld_cleanup); - -+ /* Remove temporary object-only files. */ -+ xatexit (cmdline_remove_object_only_files); -+ - /* Set up the sysroot directory. */ - ld_sysroot = get_sysroot (argc, argv); - if (*ld_sysroot) -*************** main (int argc, char **argv) -*** 295,301 **** - default_target = ldemul_choose_target (argc, argv); - config.maxpagesize = bfd_emul_get_maxpagesize (default_target); - config.commonpagesize = bfd_emul_get_commonpagesize (default_target); -! lang_init (); - ldemul_before_parse (); - lang_has_input_file = FALSE; - parse_args (argc, argv); ---- 298,304 ---- - default_target = ldemul_choose_target (argc, argv); - config.maxpagesize = bfd_emul_get_maxpagesize (default_target); - config.commonpagesize = bfd_emul_get_commonpagesize (default_target); -! lang_init (FALSE); - ldemul_before_parse (); - lang_has_input_file = FALSE; - parse_args (argc, argv); -*************** main (int argc, char **argv) -*** 310,343 **** - - ldemul_set_symbols (); - -! /* If we have not already opened and parsed a linker script, -! try the default script from command line first. */ -! if (saved_script_handle == NULL -! && command_line.default_script != NULL) -! { -! ldfile_open_command_file (command_line.default_script); -! parser_input = input_script; -! yyparse (); -! } -! -! /* If we have not already opened and parsed a linker script -! read the emulation's appropriate default script. */ -! if (saved_script_handle == NULL) -! { -! int isfile; -! char *s = ldemul_get_script (&isfile); -! -! if (isfile) -! ldfile_open_default_command_file (s); -! else -! { -! lex_string = s; -! lex_redirect (s, _("built in linker script"), 1); -! } -! parser_input = input_script; -! yyparse (); -! lex_string = NULL; -! } - - if (verbose) - { ---- 313,319 ---- - - ldemul_set_symbols (); - -! ld_parse_linker_script (); - - if (verbose) - { -*************** main (int argc, char **argv) -*** 444,449 **** ---- 420,427 ---- - if (! bfd_close (link_info.output_bfd)) - einfo (_("%F%B: final close failed: %E\n"), link_info.output_bfd); - -+ link_info.output_bfd = NULL; -+ - /* If the --force-exe-suffix is enabled, and we're making an - executable file and it doesn't end in .exe, copy it to one - which does. */ -*************** main (int argc, char **argv) -*** 490,495 **** ---- 468,476 ---- - } - } - -+ if (link_info.emit_gnu_object_only) -+ cmdline_emit_object_only_section (); -+ - END_PROGRESS (program_name); - - if (config.stats) -*************** add_archive_element (struct bfd_link_inf -*** 779,785 **** ---- 760,768 ---- - } - } - } -+ else - #endif /* ENABLE_PLUGINS */ -+ cmdline_check_object_only_section (input->the_bfd, FALSE); - - ldlang_add_file (input); - -*************** warning_callback (struct bfd_link_info * -*** 1152,1158 **** - einfo ("%P: %s%s\n", _("warning: "), warning); - else if (symbol == NULL) - einfo ("%B: %s%s\n", abfd, _("warning: "), warning); -! else - { - struct warning_callback_info cinfo; - ---- 1135,1141 ---- - einfo ("%P: %s%s\n", _("warning: "), warning); - else if (symbol == NULL) - einfo ("%B: %s%s\n", abfd, _("warning: "), warning); -! else if ((abfd->flags & BFD_PLUGIN) == 0) - { - struct warning_callback_info cinfo; - -*************** notice (struct bfd_link_info *info, -*** 1459,1461 **** ---- 1442,1479 ---- - - return TRUE; - } -+ -+ /* Parse the linker script. */ -+ -+ void -+ ld_parse_linker_script () -+ { -+ /* If we have not already opened and parsed a linker script, -+ try the default script from command line first. */ -+ if (saved_script_handle == NULL -+ && command_line.default_script != NULL) -+ { -+ ldfile_open_command_file (command_line.default_script); -+ parser_input = input_script; -+ yyparse (); -+ } -+ -+ /* If we have not already opened and parsed a linker script -+ read the emulation's appropriate default script. */ -+ if (saved_script_handle == NULL) -+ { -+ int isfile; -+ char *s = ldemul_get_script (&isfile); -+ -+ if (isfile) -+ ldfile_open_default_command_file (s); -+ else -+ { -+ lex_string = s; -+ lex_redirect (s, _("built in linker script"), 1); -+ } -+ parser_input = input_script; -+ yyparse (); -+ lex_string = NULL; -+ } -+ } +--- a/ld/ldmain.c 2013-05-14 16:39:36.862718097 +0100 ++++ b/ld/ldmain.c 2013-05-14 16:40:07.055718934 +0100 +@@ -219,6 +219,9 @@ + + xatexit (ld_cleanup); + ++ /* Remove temporary object-only files. */ ++ xatexit (cmdline_remove_object_only_files); ++ + /* Set up the sysroot directory. */ + ld_sysroot = get_sysroot (argc, argv); + if (*ld_sysroot) +@@ -295,7 +298,7 @@ + default_target = ldemul_choose_target (argc, argv); + config.maxpagesize = bfd_emul_get_maxpagesize (default_target); + config.commonpagesize = bfd_emul_get_commonpagesize (default_target); +- lang_init (); ++ lang_init (FALSE); + ldemul_before_parse (); + lang_has_input_file = FALSE; + parse_args (argc, argv); +@@ -310,34 +313,7 @@ + + ldemul_set_symbols (); + +- /* If we have not already opened and parsed a linker script, +- try the default script from command line first. */ +- if (saved_script_handle == NULL +- && command_line.default_script != NULL) +- { +- ldfile_open_command_file (command_line.default_script); +- parser_input = input_script; +- yyparse (); +- } +- +- /* If we have not already opened and parsed a linker script +- read the emulation's appropriate default script. */ +- if (saved_script_handle == NULL) +- { +- int isfile; +- char *s = ldemul_get_script (&isfile); +- +- if (isfile) +- ldfile_open_default_command_file (s); +- else +- { +- lex_string = s; +- lex_redirect (s, _("built in linker script"), 1); +- } +- parser_input = input_script; +- yyparse (); +- lex_string = NULL; +- } ++ ld_parse_linker_script (); + + if (verbose) + { +@@ -444,6 +420,8 @@ + if (! bfd_close (link_info.output_bfd)) + einfo (_("%F%B: final close failed: %E\n"), link_info.output_bfd); + ++ link_info.output_bfd = NULL; ++ + /* If the --force-exe-suffix is enabled, and we're making an + executable file and it doesn't end in .exe, copy it to one + which does. */ +@@ -490,6 +468,9 @@ + } + } + ++ if (link_info.emit_gnu_object_only) ++ cmdline_emit_object_only_section (); ++ + END_PROGRESS (program_name); + + if (config.stats) +@@ -779,7 +760,9 @@ + } + } + } ++ else + #endif /* ENABLE_PLUGINS */ ++ cmdline_check_object_only_section (input->the_bfd, FALSE); + + ldlang_add_file (input); + +@@ -1152,7 +1135,7 @@ + einfo ("%P: %s%s\n", _("warning: "), warning); + else if (symbol == NULL) + einfo ("%B: %s%s\n", abfd, _("warning: "), warning); +- else ++ else if ((abfd->flags & BFD_PLUGIN) == 0) + { + struct warning_callback_info cinfo; + +@@ -1459,3 +1442,38 @@ + + return TRUE; + } ++ ++/* Parse the linker script. */ ++ ++void ++ld_parse_linker_script () ++{ ++ /* If we have not already opened and parsed a linker script, ++ try the default script from command line first. */ ++ if (saved_script_handle == NULL ++ && command_line.default_script != NULL) ++ { ++ ldfile_open_command_file (command_line.default_script); ++ parser_input = input_script; ++ yyparse (); ++ } ++ ++ /* If we have not already opened and parsed a linker script ++ read the emulation's appropriate default script. */ ++ if (saved_script_handle == NULL) ++ { ++ int isfile; ++ char *s = ldemul_get_script (&isfile); ++ ++ if (isfile) ++ ldfile_open_default_command_file (s); ++ else ++ { ++ lex_string = s; ++ lex_redirect (s, _("built in linker script"), 1); ++ } ++ parser_input = input_script; ++ yyparse (); ++ lex_string = NULL; ++ } ++} diff -cpr ../binutils-2.23.2.orig/ld/ldmain.h ld/ldmain.h -*** ../binutils-2.23.2.orig/ld/ldmain.h 2013-05-14 16:39:39.810718179 +0100 ---- ld/ldmain.h 2013-05-14 16:40:07.055718934 +0100 -*************** extern void add_ysym (const char *); -*** 43,46 **** ---- 43,48 ---- - extern void add_ignoresym (struct bfd_link_info *, const char *); - extern void add_keepsyms_file (const char *); - -+ extern void ld_parse_linker_script (void); -+ - #endif +--- a/ld/ldmain.h 2013-05-14 16:39:39.810718179 +0100 ++++ b/ld/ldmain.h 2013-05-14 16:40:07.055718934 +0100 +@@ -43,4 +43,6 @@ + extern void add_ignoresym (struct bfd_link_info *, const char *); + extern void add_keepsyms_file (const char *); + ++extern void ld_parse_linker_script (void); ++ + #endif diff -cpr ../binutils-2.23.2.orig/ld/lexsup.c ld/lexsup.c -*** ../binutils-2.23.2.orig/ld/lexsup.c 2013-05-14 16:39:36.709718093 +0100 ---- ld/lexsup.c 2013-05-14 16:40:07.058718934 +0100 -*************** static const struct ld_option ld_options -*** 168,173 **** ---- 168,176 ---- - '\0', N_("PLUGIN"), N_("Load named plugin"), ONE_DASH }, - { {"plugin-opt", required_argument, NULL, OPTION_PLUGIN_OPT}, - '\0', N_("ARG"), N_("Send arg to last-loaded plugin"), ONE_DASH }, -+ { {"plugin-save-temps", no_argument, NULL, OPTION_PLUGIN_SAVE_TEMPS}, -+ '\0', NULL, N_("Store plugin intermediate files permanently"), -+ ONE_DASH }, - { {"flto", optional_argument, NULL, OPTION_IGNORE}, - '\0', NULL, N_("Ignored for GCC LTO option compatibility"), - ONE_DASH }, -*************** parse_args (unsigned argc, char **argv) -*** 958,963 **** ---- 961,969 ---- - if (plugin_opt_plugin_arg (optarg)) - einfo(_("%P%F: bad -plugin-opt option\n")); - break; -+ case OPTION_PLUGIN_SAVE_TEMPS: -+ plugin_save_temps = TRUE; -+ break; - #endif /* ENABLE_PLUGINS */ - case 'q': - link_info.emitrelocations = TRUE; +--- a/ld/lexsup.c 2013-05-14 16:39:36.709718093 +0100 ++++ b/ld/lexsup.c 2013-05-14 16:40:07.058718934 +0100 +@@ -168,6 +168,9 @@ + '\0', N_("PLUGIN"), N_("Load named plugin"), ONE_DASH }, + { {"plugin-opt", required_argument, NULL, OPTION_PLUGIN_OPT}, + '\0', N_("ARG"), N_("Send arg to last-loaded plugin"), ONE_DASH }, ++ { {"plugin-save-temps", no_argument, NULL, OPTION_PLUGIN_SAVE_TEMPS}, ++ '\0', NULL, N_("Store plugin intermediate files permanently"), ++ ONE_DASH }, + { {"flto", optional_argument, NULL, OPTION_IGNORE}, + '\0', NULL, N_("Ignored for GCC LTO option compatibility"), + ONE_DASH }, +@@ -958,6 +961,9 @@ + if (plugin_opt_plugin_arg (optarg)) + einfo(_("%P%F: bad -plugin-opt option\n")); + break; ++ case OPTION_PLUGIN_SAVE_TEMPS: ++ plugin_save_temps = TRUE; ++ break; + #endif /* ENABLE_PLUGINS */ + case 'q': + link_info.emitrelocations = TRUE; diff -cpr ../binutils-2.23.2.orig/ld/plugin.c ld/plugin.c -*** ../binutils-2.23.2.orig/ld/plugin.c 2013-05-14 16:39:37.435718113 +0100 ---- ld/plugin.c 2013-05-14 16:48:59.039733681 +0100 -*************** -*** 39,44 **** ---- 39,47 ---- - /* Report plugin symbols. */ - bfd_boolean report_plugin_symbols; - -+ /* Store plugin intermediate files permanently. */ -+ bfd_boolean plugin_save_temps; -+ - /* The suffix to append to the name of the real (claimed) object file - when generating a dummy BFD to hold the IR symbols sent from the - plugin. For cosmetic use only; appears in maps, crefs etc. */ -*************** plugin_opt_plugin_arg (const char *arg) -*** 217,222 **** ---- 220,236 ---- - if (!last_plugin) - return set_plugin_error (_("")); - -+ /* Ignore -pass-through= from GCC driver. */ -+ if (*arg == '-') -+ { -+ const char *p; -+ for (p = arg + 1; p; p++) -+ if (*p != '-') -+ break; -+ if (strncmp (p, "pass-through=", 13) == 0) -+ return 0; -+ } -+ - newarg = xmalloc (sizeof *newarg); - newarg->arg = arg; - newarg->next = NULL; -*************** plugin_maybe_claim (struct ld_plugin_inp -*** 876,881 **** ---- 890,898 ---- - close (file->fd); - if (claimed) - { -+ /* Check object only section. */ -+ cmdline_check_object_only_section (entry->the_bfd, TRUE); -+ - /* Discard the real file's BFD and substitute the dummy one. */ - - /* BFD archive handling caches elements so we can't call -*************** plugin_call_cleanup (void) -*** 929,942 **** - { - if (curplug->cleanup_handler && !curplug->cleanup_done) - { -! enum ld_plugin_status rv; -! curplug->cleanup_done = TRUE; -! called_plugin = curplug; -! rv = (*curplug->cleanup_handler) (); -! called_plugin = NULL; -! if (rv != LDPS_OK) -! info_msg (_("%P: %s: error in plugin cleanup: %d (ignored)\n"), -! curplug->name, rv); - dlclose (curplug->dlhandle); - } - curplug = curplug->next; ---- 946,962 ---- - { - if (curplug->cleanup_handler && !curplug->cleanup_done) - { -! if (!plugin_save_temps) -! { -! enum ld_plugin_status rv; -! curplug->cleanup_done = TRUE; -! called_plugin = curplug; -! rv = (*curplug->cleanup_handler) (); -! called_plugin = NULL; -! if (rv != LDPS_OK) -! info_msg (_("%P: %s: error in plugin cleanup: %d (ignored)\n"), -! curplug->name, rv); -! } - dlclose (curplug->dlhandle); - } - curplug = curplug->next; +--- a/ld/plugin.c 2013-05-14 16:39:37.435718113 +0100 ++++ b/ld/plugin.c 2013-05-14 16:48:59.039733681 +0100 +@@ -39,6 +39,9 @@ + /* Report plugin symbols. */ + bfd_boolean report_plugin_symbols; + ++/* Store plugin intermediate files permanently. */ ++bfd_boolean plugin_save_temps; ++ + /* The suffix to append to the name of the real (claimed) object file + when generating a dummy BFD to hold the IR symbols sent from the + plugin. For cosmetic use only; appears in maps, crefs etc. */ +@@ -217,6 +220,17 @@ + if (!last_plugin) + return set_plugin_error (_("")); + ++ /* Ignore -pass-through= from GCC driver. */ ++ if (*arg == '-') ++ { ++ const char *p; ++ for (p = arg + 1; p; p++) ++ if (*p != '-') ++ break; ++ if (strncmp (p, "pass-through=", 13) == 0) ++ return 0; ++ } ++ + newarg = xmalloc (sizeof *newarg); + newarg->arg = arg; + newarg->next = NULL; +@@ -876,6 +890,9 @@ + close (file->fd); + if (claimed) + { ++ /* Check object only section. */ ++ cmdline_check_object_only_section (entry->the_bfd, TRUE); ++ + /* Discard the real file's BFD and substitute the dummy one. */ + + /* BFD archive handling caches elements so we can't call +@@ -929,14 +946,17 @@ + { + if (curplug->cleanup_handler && !curplug->cleanup_done) + { +- enum ld_plugin_status rv; +- curplug->cleanup_done = TRUE; +- called_plugin = curplug; +- rv = (*curplug->cleanup_handler) (); +- called_plugin = NULL; +- if (rv != LDPS_OK) +- info_msg (_("%P: %s: error in plugin cleanup: %d (ignored)\n"), +- curplug->name, rv); ++ if (!plugin_save_temps) ++ { ++ enum ld_plugin_status rv; ++ curplug->cleanup_done = TRUE; ++ called_plugin = curplug; ++ rv = (*curplug->cleanup_handler) (); ++ called_plugin = NULL; ++ if (rv != LDPS_OK) ++ info_msg (_("%P: %s: error in plugin cleanup: %d (ignored)\n"), ++ curplug->name, rv); ++ } + dlclose (curplug->dlhandle); + } + curplug = curplug->next; diff -cpr ../binutils-2.23.2.orig/ld/plugin.h ld/plugin.h -*** ../binutils-2.23.2.orig/ld/plugin.h 2013-05-14 16:39:39.705718176 +0100 ---- ld/plugin.h 2013-05-14 16:40:07.059718934 +0100 -*************** -*** 24,29 **** ---- 24,32 ---- - /* Report plugin symbols. */ - extern bfd_boolean report_plugin_symbols; - -+ /* Store plugin intermediate files permanently. */ -+ extern bfd_boolean plugin_save_temps; -+ - /* Set at all symbols read time, to avoid recursively offering the plugin - its own newly-added input files and libs to claim. */ - extern bfd_boolean no_more_claiming; +--- a/ld/plugin.h 2013-05-14 16:39:39.705718176 +0100 ++++ b/ld/plugin.h 2013-05-14 16:40:07.059718934 +0100 +@@ -24,6 +24,9 @@ + /* Report plugin symbols. */ + extern bfd_boolean report_plugin_symbols; + ++/* Store plugin intermediate files permanently. */ ++extern bfd_boolean plugin_save_temps; ++ + /* Set at all symbols read time, to avoid recursively offering the plugin + its own newly-added input files and libs to claim. */ + extern bfd_boolean no_more_claiming; diff -cpr ../binutils-2.23.2.orig/ld/scripttempl/armbpabi.sc ld/scripttempl/armbpabi.sc -*** ../binutils-2.23.2.orig/ld/scripttempl/armbpabi.sc 2013-05-14 16:39:39.758718177 +0100 ---- ld/scripttempl/armbpabi.sc 2013-05-14 16:54:15.657742458 +0100 -*************** INTERP=".interp 0 : { *(.interp) } -*** 30,36 **** - PLT=".plt ${RELOCATING-0} : { *(.plt) }" - RODATA=".rodata ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }" - DATARELRO=".data.rel.ro : { *(.data.rel.ro.local) *(.data.rel.ro .data.rel.ro.*) }" -! DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }" - if test -z "${NO_SMALL_DATA}"; then - SBSS=".sbss ${RELOCATING-0} : - { ---- 30,36 ---- - PLT=".plt ${RELOCATING-0} : { *(.plt) }" - RODATA=".rodata ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }" - DATARELRO=".data.rel.ro : { *(.data.rel.ro.local) *(.data.rel.ro .data.rel.ro.*) }" -! DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) *(.gnu_object_only) }" - if test -z "${NO_SMALL_DATA}"; then - SBSS=".sbss ${RELOCATING-0} : - { +--- a/ld/scripttempl/armbpabi.sc 2013-05-14 16:39:39.758718177 +0100 ++++ b/ld/scripttempl/armbpabi.sc 2013-05-14 16:54:15.657742458 +0100 +@@ -30,7 +30,7 @@ + PLT=".plt ${RELOCATING-0} : { *(.plt) }" + RODATA=".rodata ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }" + DATARELRO=".data.rel.ro : { *(.data.rel.ro.local) *(.data.rel.ro .data.rel.ro.*) }" +-DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }" ++DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) *(.gnu_object_only) }" + if test -z "${NO_SMALL_DATA}"; then + SBSS=".sbss ${RELOCATING-0} : + { diff -cpr ../binutils-2.23.2.orig/ld/scripttempl/elf32sh-symbian.sc ld/scripttempl/elf32sh-symbian.sc -*** ../binutils-2.23.2.orig/ld/scripttempl/elf32sh-symbian.sc 2013-05-14 16:39:39.759718177 +0100 ---- ld/scripttempl/elf32sh-symbian.sc 2013-05-14 16:40:07.062718934 +0100 -*************** fi -*** 83,89 **** - PLT=".plt : { *(.plt) } :dynamic :dyn" - DYNAMIC=".dynamic : { *(.dynamic) } :dynamic :dyn" - RODATA=".rodata ALIGN(4) : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }" -! DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.directive) *(.gnu.lto_*) }" - test -z "$GOT" && GOT=".got ${RELOCATING-0} : { *(.got.plt) *(.got) } :dynamic :dyn" - INIT_ARRAY=".init_array ${RELOCATING-0} : - { ---- 83,89 ---- - PLT=".plt : { *(.plt) } :dynamic :dyn" - DYNAMIC=".dynamic : { *(.dynamic) } :dynamic :dyn" - RODATA=".rodata ALIGN(4) : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }" -! DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.directive) *(.gnu.lto_*) *(.gnu_object_only) }" - test -z "$GOT" && GOT=".got ${RELOCATING-0} : { *(.got.plt) *(.got) } :dynamic :dyn" - INIT_ARRAY=".init_array ${RELOCATING-0} : - { +--- a/ld/scripttempl/elf32sh-symbian.sc 2013-05-14 16:39:39.759718177 +0100 ++++ b/ld/scripttempl/elf32sh-symbian.sc 2013-05-14 16:40:07.062718934 +0100 +@@ -83,7 +83,7 @@ + PLT=".plt : { *(.plt) } :dynamic :dyn" + DYNAMIC=".dynamic : { *(.dynamic) } :dynamic :dyn" + RODATA=".rodata ALIGN(4) : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }" +-DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.directive) *(.gnu.lto_*) }" ++DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.directive) *(.gnu.lto_*) *(.gnu_object_only) }" + test -z "$GOT" && GOT=".got ${RELOCATING-0} : { *(.got.plt) *(.got) } :dynamic :dyn" + INIT_ARRAY=".init_array ${RELOCATING-0} : + { diff -cpr ../binutils-2.23.2.orig/ld/scripttempl/elf64hppa.sc ld/scripttempl/elf64hppa.sc -*** ../binutils-2.23.2.orig/ld/scripttempl/elf64hppa.sc 2013-05-14 16:39:39.733718177 +0100 ---- ld/scripttempl/elf64hppa.sc 2013-05-14 16:55:16.076744133 +0100 -*************** fi -*** 127,133 **** - DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }" - RODATA=".rodata ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .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_*) }" - if test -z "${NO_SMALL_DATA}"; then - SBSS=".sbss ${RELOCATING-0} : - { ---- 127,133 ---- - DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }" - RODATA=".rodata ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .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_*) *(.gnu_object_only) }" - if test -z "${NO_SMALL_DATA}"; then - SBSS=".sbss ${RELOCATING-0} : - { +--- a/ld/scripttempl/elf64hppa.sc 2013-05-14 16:39:39.733718177 +0100 ++++ b/ld/scripttempl/elf64hppa.sc 2013-05-14 16:55:16.076744133 +0100 +@@ -127,7 +127,7 @@ + DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }" + RODATA=".rodata ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .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_*) *(.gnu_object_only) }" + if test -z "${NO_SMALL_DATA}"; then + SBSS=".sbss ${RELOCATING-0} : + { diff -cpr ../binutils-2.23.2.orig/ld/scripttempl/elf.sc ld/scripttempl/elf.sc -*** ../binutils-2.23.2.orig/ld/scripttempl/elf.sc 2013-05-14 16:39:39.755718177 +0100 ---- ld/scripttempl/elf.sc 2013-05-14 16:54:44.618743261 +0100 -*************** RELA_IPLT=".rela.iplt ${RELOCATING-0} -*** 158,164 **** - 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_*) }" - if test -z "${NO_SMALL_DATA}"; then - SBSS=".${SBSS_NAME} ${RELOCATING-0} : - { ---- 158,164 ---- - 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_*) *(.gnu_object_only) }" - if test -z "${NO_SMALL_DATA}"; then - SBSS=".${SBSS_NAME} ${RELOCATING-0} : - { +--- a/ld/scripttempl/elf.sc 2013-05-14 16:39:39.755718177 +0100 ++++ b/ld/scripttempl/elf.sc 2013-05-14 16:54:44.618743261 +0100 +@@ -158,7 +158,7 @@ + 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_*) *(.gnu_object_only) }" + if test -z "${NO_SMALL_DATA}"; then + SBSS=".${SBSS_NAME} ${RELOCATING-0} : + { diff -cpr ../binutils-2.23.2.orig/ld/scripttempl/elfxtensa.sc ld/scripttempl/elfxtensa.sc -*** ../binutils-2.23.2.orig/ld/scripttempl/elfxtensa.sc 2013-05-14 16:39:39.754718177 +0100 ---- ld/scripttempl/elfxtensa.sc 2013-05-14 16:55:44.908744932 +0100 -*************** fi -*** 140,146 **** - DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }" - RODATA=".rodata ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .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_*) }" - INIT_LIT=".init.literal 0 : { *(.init.literal) }" - INIT=".init 0 : { *(.init) }" - FINI_LIT=".fini.literal 0 : { *(.fini.literal) }" ---- 140,146 ---- - DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }" - RODATA=".rodata ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .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_*) *(.gnu_object_only) }" - INIT_LIT=".init.literal 0 : { *(.init.literal) }" - INIT=".init 0 : { *(.init) }" - FINI_LIT=".fini.literal 0 : { *(.fini.literal) }" +--- a/ld/scripttempl/elfxtensa.sc 2013-05-14 16:39:39.754718177 +0100 ++++ b/ld/scripttempl/elfxtensa.sc 2013-05-14 16:55:44.908744932 +0100 +@@ -140,7 +140,7 @@ + DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }" + RODATA=".rodata ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .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_*) *(.gnu_object_only) }" + INIT_LIT=".init.literal 0 : { *(.init.literal) }" + INIT=".init 0 : { *(.init) }" + FINI_LIT=".fini.literal 0 : { *(.fini.literal) }" diff -cpr ../binutils-2.23.2.orig/ld/scripttempl/mep.sc ld/scripttempl/mep.sc -*** ../binutils-2.23.2.orig/ld/scripttempl/mep.sc 2013-05-14 16:39:39.755718177 +0100 ---- ld/scripttempl/mep.sc 2013-05-14 16:56:08.605745589 +0100 -*************** fi -*** 114,120 **** - DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }" - RODATA=".rodata ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }" - DATARELRO=".data.rel.ro : { *(.data.rel.ro.local) *(.data.rel.ro .data.rel.ro.*) }" -! DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }" - if test -z "${NO_SMALL_DATA}"; then - SBSS=".sbss ${RELOCATING-0} : - { ---- 114,120 ---- - DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }" - RODATA=".rodata ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }" - DATARELRO=".data.rel.ro : { *(.data.rel.ro.local) *(.data.rel.ro .data.rel.ro.*) }" -! DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) *(.gnu_object_only) }" - if test -z "${NO_SMALL_DATA}"; then - SBSS=".sbss ${RELOCATING-0} : - { +--- a/ld/scripttempl/mep.sc 2013-05-14 16:39:39.755718177 +0100 ++++ b/ld/scripttempl/mep.sc 2013-05-14 16:56:08.605745589 +0100 +@@ -114,7 +114,7 @@ + DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }" + RODATA=".rodata ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }" + DATARELRO=".data.rel.ro : { *(.data.rel.ro.local) *(.data.rel.ro .data.rel.ro.*) }" +-DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }" ++DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) *(.gnu_object_only) }" + if test -z "${NO_SMALL_DATA}"; then + SBSS=".sbss ${RELOCATING-0} : + { diff -cpr ../binutils-2.23.2.orig/ld/scripttempl/pep.sc ld/scripttempl/pep.sc -*** ../binutils-2.23.2.orig/ld/scripttempl/pep.sc 2013-05-14 16:39:39.755718177 +0100 ---- ld/scripttempl/pep.sc 2013-05-14 16:40:07.064718934 +0100 -*************** SECTIONS -*** 154,159 **** ---- 154,160 ---- - *(.drectve) - ${RELOCATING+ *(.note.GNU-stack)} - ${RELOCATING+ *(.gnu.lto_*)} -+ ${RELOCATING+ *(.gnu_object_only)} - } - - .idata ${RELOCATING+BLOCK(__section_alignment__)} : +--- a/ld/scripttempl/pep.sc 2013-05-14 16:39:39.755718177 +0100 ++++ b/ld/scripttempl/pep.sc 2013-05-14 16:40:07.064718934 +0100 +@@ -154,6 +154,7 @@ + *(.drectve) + ${RELOCATING+ *(.note.GNU-stack)} + ${RELOCATING+ *(.gnu.lto_*)} ++ ${RELOCATING+ *(.gnu_object_only)} + } + + .idata ${RELOCATING+BLOCK(__section_alignment__)} : diff -cpr ../binutils-2.23.2.orig/ld/scripttempl/pe.sc ld/scripttempl/pe.sc -*** ../binutils-2.23.2.orig/ld/scripttempl/pe.sc 2013-05-14 16:39:39.758718177 +0100 ---- ld/scripttempl/pe.sc 2013-05-14 16:40:07.064718934 +0100 -*************** SECTIONS -*** 148,153 **** ---- 148,154 ---- - *(.drectve) - ${RELOCATING+ *(.note.GNU-stack)} - ${RELOCATING+ *(.gnu.lto_*)} -+ ${RELOCATING+ *(.gnu_object_only)} - } - - .idata ${RELOCATING+BLOCK(__section_alignment__)} : +--- a/ld/scripttempl/pe.sc 2013-05-14 16:39:39.758718177 +0100 ++++ b/ld/scripttempl/pe.sc 2013-05-14 16:40:07.064718934 +0100 +@@ -148,6 +148,7 @@ + *(.drectve) + ${RELOCATING+ *(.note.GNU-stack)} + ${RELOCATING+ *(.gnu.lto_*)} ++ ${RELOCATING+ *(.gnu_object_only)} + } + + .idata ${RELOCATING+BLOCK(__section_alignment__)} : diff --git a/binutils-2.23.52.0.1-addr2line-dynsymtab.patch b/binutils-2.23.52.0.1-addr2line-dynsymtab.patch index 68f0470..944f4fd 100644 --- a/binutils-2.23.52.0.1-addr2line-dynsymtab.patch +++ b/binutils-2.23.52.0.1-addr2line-dynsymtab.patch @@ -1,122 +1,38 @@ -*** ../binutils-2.23.52.0.1.orig/bfd/opncls.c 2013-03-14 11:25:30.338306122 +0000 ---- bfd/opncls.c 2013-03-14 12:20:21.686397360 +0000 -*************** find_separate_debug_file (bfd *abfd, con -*** 1297,1302 **** ---- 1297,1304 ---- - bfd_malloc (strlen (debug_file_directory) + 1 - + (canon_dirlen > dirlen ? canon_dirlen : dirlen) - + strlen (".debug/") -+ #define FEDORA_LIB_DEBUG_DIR "/usr/lib/debug/" -+ + strlen (FEDORA_LIB_DEBUG_DIR) + strlen ("usr/") - + strlen (base) - + 1); - if (debugfile == NULL) -*************** find_separate_debug_file (bfd *abfd, con -*** 1332,1337 **** ---- 1334,1359 ---- - if (check_func (debugfile, crc32)) - goto found; - -+ /* Then try in the global debug dir for Fedora libraries. */ -+ sprintf (debugfile, "%s%s%s", FEDORA_LIB_DEBUG_DIR, dir, base); -+ if (separate_debug_file_exists (debugfile, crc32)) -+ { -+ free (base); -+ free (dir); -+ free (canon_dir); -+ return debugfile; -+ } -+ -+ /* Then try in the usr subdirectory of the global debug dir for Fedora libraries. */ -+ sprintf (debugfile, "%s/usr%s%s", FEDORA_LIB_DEBUG_DIR, dir, base); -+ if (separate_debug_file_exists (debugfile, crc32)) -+ { -+ free (base); -+ free (dir); -+ free (canon_dir); -+ return debugfile; -+ } -+ - /* Then try in the global debugfile directory. */ - strcpy (debugfile, debug_file_directory); - dirlen = strlen (debug_file_directory) - 1; -*** ../binutils-2.23.52.0.1.orig/bfd/dwarf2.c 2013-03-14 11:25:30.608306129 +0000 ---- bfd/dwarf2.c 2013-03-14 13:14:18.102487075 +0000 -*************** find_line (bfd *abfd, -*** 3339,3346 **** ---- 3339,3349 ---- - struct dwarf2_debug *stash; - /* What address are we looking for? */ - bfd_vma addr; -+ /* What is the address without relocation ? */ -+ bfd_vma unrelocated_addr; - struct comp_unit* each; - bfd_vma found = FALSE; -+ bfd_vma possible_find = FALSE; - bfd_boolean do_line; - - *filename_ptr = NULL; -*************** find_line (bfd *abfd, -*** 3380,3385 **** ---- 3383,3394 ---- - else - abort (); - -+ /* If we are dealing with PIC code then the debug information -+ will be based on unrelocated addresses. Since we cannot be -+ sure if this is a PIC address we test both with and without -+ relocation. */ -+ unrelocated_addr = addr; -+ - if (section->output_section) - addr += section->output_section->vma + section->output_offset; - else -*************** find_line (bfd *abfd, -*** 3442,3447 **** ---- 3451,3466 ---- - stash)); - if (found) - goto done; -+ -+ if (! possible_find) -+ possible_find = ((each->arange.high == 0 -+ || comp_unit_contains_address (each, unrelocated_addr)) -+ && comp_unit_find_nearest_line (each, unrelocated_addr, -+ filename_ptr, -+ functionname_ptr, -+ linenumber_ptr, -+ discriminator_ptr, -+ stash)); - } - } - -*************** find_line (bfd *abfd, -*** 3535,3540 **** ---- 3554,3569 ---- - discriminator_ptr, - stash)); - -+ if (! found && ! do_line && ! possible_find) -+ possible_find = ((each->arange.high == 0 -+ || comp_unit_contains_address (each, unrelocated_addr)) -+ && comp_unit_find_nearest_line (each, unrelocated_addr, -+ filename_ptr, -+ functionname_ptr, -+ linenumber_ptr, -+ discriminator_ptr, -+ stash)); -+ - if ((bfd_vma) (stash->info_ptr - stash->sec_info_ptr) - == stash->sec->size) - { -*************** find_line (bfd *abfd, -*** 3552,3557 **** ---- 3581,3588 ---- - if ((abfd->flags & (EXEC_P | DYNAMIC)) == 0) - unset_sections (stash); - -+ if (! found) -+ return possible_find; - return found; - } - +--- a/bfd/opncls.c 2013-03-14 11:25:30.338306122 +0000 ++++ b/bfd/opncls.c 2013-03-14 12:20:21.686397360 +0000 +@@ -1297,6 +1297,8 @@ + bfd_malloc (strlen (debug_file_directory) + 1 + + (canon_dirlen > dirlen ? canon_dirlen : dirlen) + + strlen (".debug/") ++#define FEDORA_LIB_DEBUG_DIR "/usr/lib/debug/" ++ + strlen (FEDORA_LIB_DEBUG_DIR) + strlen ("usr/") + + strlen (base) + + 1); + if (debugfile == NULL) +@@ -1332,6 +1334,26 @@ + if (check_func (debugfile, crc32)) + goto found; + ++ /* Then try in the global debug dir for Fedora libraries. */ ++ sprintf (debugfile, "%s%s%s", FEDORA_LIB_DEBUG_DIR, dir, base); ++ if (separate_debug_file_exists (debugfile, crc32)) ++ { ++ free (base); ++ free (dir); ++ free (canon_dir); ++ return debugfile; ++ } ++ ++ /* Then try in the usr subdirectory of the global debug dir for Fedora libraries. */ ++ sprintf (debugfile, "%s/usr%s%s", FEDORA_LIB_DEBUG_DIR, dir, base); ++ if (separate_debug_file_exists (debugfile, crc32)) ++ { ++ free (base); ++ free (dir); ++ free (canon_dir); ++ return debugfile; ++ } ++ + /* Then try in the global debugfile directory. */ + strcpy (debugfile, debug_file_directory); + dirlen = strlen (debug_file_directory) - 1; diff --git a/binutils-2.24-DW_FORM_ref_addr.patch b/binutils-2.24-DW_FORM_ref_addr.patch deleted file mode 100644 index 92ef150..0000000 --- a/binutils-2.24-DW_FORM_ref_addr.patch +++ /dev/null @@ -1,44 +0,0 @@ -*** ../binutils-2.24.orig/bfd/dwarf2.c 2014-01-28 11:58:02.072737296 +0000 ---- bfd/dwarf2.c 2014-01-28 11:59:38.575739971 +0000 -*************** find_abstract_instance_name (struct comp -*** 2126,2131 **** ---- 2126,2153 ---- - abort (); - - info_ptr = unit->sec_info_ptr + die_ref; -+ -+ /* Now find the CU containing this pointer. */ -+ if (info_ptr >= unit->info_ptr_unit && info_ptr < unit->end_ptr) -+ ; -+ else -+ { -+ /* Check other CUs to see if they contain the abbrev. */ -+ struct comp_unit * u; -+ -+ for (u = unit->prev_unit; u != NULL; u = u->prev_unit) -+ if (info_ptr >= u->info_ptr_unit && info_ptr < u->end_ptr) -+ break; -+ -+ if (u == NULL) -+ for (u = unit->next_unit; u != NULL; u = u->next_unit) -+ if (info_ptr >= u->info_ptr_unit && info_ptr < u->end_ptr) -+ break; -+ -+ if (u) -+ unit = u; -+ /* else FIXME: What do we do now ? */ -+ } - } - else if (attr_ptr->form == DW_FORM_GNU_ref_alt) - { -*************** find_abstract_instance_name (struct comp -*** 2137,2142 **** ---- 2159,2166 ---- - bfd_set_error (bfd_error_bad_value); - return name; - } -+ /* FIXME: Do we need to locate the correct CU, in a similar -+ fashion to the code in the DW_FORM_ref_addr case above ? */ - } - else - info_ptr = unit->info_ptr_unit + die_ref; diff --git a/binutils-2.24-aarch64-fix-final_link_relocate.patch b/binutils-2.24-aarch64-fix-final_link_relocate.patch deleted file mode 100644 index 8c2d37b..0000000 --- a/binutils-2.24-aarch64-fix-final_link_relocate.patch +++ /dev/null @@ -1,54 +0,0 @@ -commit f44a1f8e513b37bcc52ba9ea0c172c3e94852756 -Author: Christophe Lyon -Date: Tue Jan 14 15:53:50 2014 +0100 - - 2014-01-14 Michael Hudson-Doyle - Kugan Vivekanandarajah - - bfd/ - * elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Use correct - offset while calculating relocation address. - (elfNN_aarch64_create_small_pltn_entry): Likewise. - (elfNN_aarch64_init_small_plt0_entry): Likewise. - ---- a/bfd/elfnn-aarch64.c -+++ b/bfd/elfnn-aarch64.c -@@ -3844,7 +3844,7 @@ elfNN_aarch64_final_link_relocate (reloc_howto_type *howto, - - value = (symbol_got_offset (input_bfd, h, r_symndx) - + globals->root.sgot->output_section->vma -- + globals->root.sgot->output_section->output_offset); -+ + globals->root.sgot->output_offset); - - value = _bfd_aarch64_elf_resolve_relocation (bfd_r_type, place, value, - 0, weak_undef_p); -@@ -3873,10 +3873,9 @@ elfNN_aarch64_final_link_relocate (reloc_howto_type *howto, - case BFD_RELOC_AARCH64_TLSDESC_LDR: - if (globals->root.sgot == NULL) - return bfd_reloc_notsupported; -- - value = (symbol_tlsdesc_got_offset (input_bfd, h, r_symndx) - + globals->root.sgotplt->output_section->vma -- + globals->root.sgotplt->output_section->output_offset -+ + globals->root.sgotplt->output_offset - + globals->sgotplt_jump_table_size); - - value = _bfd_aarch64_elf_resolve_relocation (bfd_r_type, place, value, -@@ -6627,7 +6626,7 @@ elfNN_aarch64_create_small_pltn_entry (struct elf_link_hash_entry *h, - - plt_entry = plt->contents + h->plt.offset; - plt_entry_address = plt->output_section->vma -- + plt->output_section->output_offset + h->plt.offset; -+ + plt->output_offset + h->plt.offset; - gotplt_entry_address = gotplt->output_section->vma + - gotplt->output_offset + got_offset; - -@@ -6934,7 +6933,7 @@ elfNN_aarch64_init_small_plt0_entry (bfd *output_bfd ATTRIBUTE_UNUSED, - + GOT_ENTRY_SIZE * 2); - - plt_base = htab->root.splt->output_section->vma + -- htab->root.splt->output_section->output_offset; -+ htab->root.splt->output_offset; - - /* Fill in the top 21 bits for this: ADRP x16, PLT_GOT + n * 8. - ADRP: ((PG(S+A)-PG(P)) >> 12) & 0x1fffff */ diff --git a/binutils-2.24-aarch64-fix-gotplt-offset-ifunc.patch b/binutils-2.24-aarch64-fix-gotplt-offset-ifunc.patch deleted file mode 100644 index 64a1d9c..0000000 --- a/binutils-2.24-aarch64-fix-gotplt-offset-ifunc.patch +++ /dev/null @@ -1,103 +0,0 @@ -commit 67428c4aa56d4183d0f531e0d752040745a94423 -Author: Will Newton -Date: Mon Nov 25 11:07:07 2013 +0000 - - bfd/elfnn-aarch64.c: Fix miscalculation of GOTPLT offset for ifunc syms. - - The .got.plt header size was not being correctly taken into account - when calculating the offset for relocations against ifunc symbols. - - bfd/ChangeLog: - - 2013-11-26 Will Newton - - * elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Ensure - PLT_INDEX is calculated using correct header size. - - ld/testsuite/ChangeLog: - - 2013-11-26 Will Newton - - * ld-aarch64/aarch64-elf.exp: Add ifunc-21 test. - * ld-aarch64/ifunc-21.d: New file. - * ld-aarch64/ifunc-21.s: Likewise. - -diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c -index 6bc414e..3cd3a18 100644 ---- a/bfd/elfnn-aarch64.c -+++ b/bfd/elfnn-aarch64.c -@@ -3589,7 +3589,8 @@ elfNN_aarch64_final_link_relocate (reloc_howto_type *howto, - - if (globals->root.splt != NULL) - { -- plt_index = h->plt.offset / globals->plt_entry_size - 1; -+ plt_index = ((h->plt.offset - globals->plt_header_size) / -+ globals->plt_entry_size); - off = (plt_index + 3) * GOT_ENTRY_SIZE; - base_got = globals->root.sgotplt; - } -diff --git a/ld/testsuite/ld-aarch64/aarch64-elf.exp b/ld/testsuite/ld-aarch64/aarch64-elf.exp -index 5c150dd..a6b3ea2 100644 ---- a/ld/testsuite/ld-aarch64/aarch64-elf.exp -+++ b/ld/testsuite/ld-aarch64/aarch64-elf.exp -@@ -155,3 +155,4 @@ run_dump_test "ifunc-18b" - run_dump_test "ifunc-19a" - run_dump_test "ifunc-19b" - run_dump_test "ifunc-20" -+run_dump_test "ifunc-21" -diff --git a/ld/testsuite/ld-aarch64/ifunc-21.d b/ld/testsuite/ld-aarch64/ifunc-21.d -new file mode 100644 -index 0000000..fa139b2 ---- /dev/null -+++ b/ld/testsuite/ld-aarch64/ifunc-21.d -@@ -0,0 +1,31 @@ -+#source: ifunc-21.s -+#ld: -shared -z nocombreloc -+#objdump: -d -s -j .got.plt -j .text -+#target: aarch64*-*-* -+ -+# Ensure the .got.plt slot used is correct -+ -+.*: file format elf64-(little|big)aarch64 -+ -+Contents of section .text: -+ 02a0 .* -+Contents of section .got.plt: -+ 103a8 0+ 0+ 0+ 0+ .* -+ 103b8 0+ 0+ [0-9a-f]+ 0+ .* -+ -+Disassembly of section .text: -+ -+0+2a0 : -+ 2a0: d65f03c0 ret -+ -+0+2a4 : -+ 2a4: 90000080 adrp x0, 10000 <.*> -+ 2a8: f941e000 ldr x0, \[x0,#960\] -+ 2ac: d65f03c0 ret -+ -+Disassembly of section .got.plt: -+ -+.*: -+.* -+.* -+.* -diff --git a/ld/testsuite/ld-aarch64/ifunc-21.s b/ld/testsuite/ld-aarch64/ifunc-21.s -new file mode 100644 -index 0000000..a1563dc ---- /dev/null -+++ b/ld/testsuite/ld-aarch64/ifunc-21.s -@@ -0,0 +1,13 @@ -+ .text -+ .type ifunc, @gnu_indirect_function -+ .hidden ifunc -+ifunc: -+ ret -+ .size ifunc, .-ifunc -+ .type bar, @function -+ .globl bar -+bar: -+ adrp x0, :got:ifunc -+ ldr x0, [x0, #:got_lo12:ifunc] -+ ret -+ .size bar, .-bar diff --git a/binutils-2.24-aarch64-fix-ie-relax.patch b/binutils-2.24-aarch64-fix-ie-relax.patch deleted file mode 100644 index d9157ea..0000000 --- a/binutils-2.24-aarch64-fix-ie-relax.patch +++ /dev/null @@ -1,40 +0,0 @@ -commit 44f814ce5066f10a3bed29c45d10e0d38f4fa433 -Author: Marcus Shawcroft -Date: Tue Apr 15 17:46:07 2014 +0100 - - [AArch64] Fix off by one error in instruction relaxation mask. - - The AArch64 TLSDESC to IE relaxation code uses a bit mask intended to - ensure that destination register in a relaxed ldr instruction is - always X0. The mask has an off by one error resulting in the most - significant bit of the destination register being retained in the - relaxed instruction. The issue generally appears when the compiler - emits TLS accesses code under high register pressure resulting in a - broken code sequence. - -diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c -index 42c83fb..8503419 100644 ---- a/bfd/elfnn-aarch64.c -+++ b/bfd/elfnn-aarch64.c -@@ -3957,7 +3957,7 @@ elfNN_aarch64_tls_relax (struct elf_aarch64_link_hash_table *globals, - ldr xd, [x0, #:tlsdesc_lo12:var] => ldr x0, [x0, #:gottprel_lo12:var] - */ - insn = bfd_getl32 (contents + rel->r_offset); -- insn &= 0xfffffff0; -+ insn &= 0xffffffe0; - bfd_putl32 (insn, contents + rel->r_offset); - return bfd_reloc_continue; - } -diff --git a/ld/testsuite/ld-aarch64/tls-relax-gdesc-ie.s b/ld/testsuite/ld-aarch64/tls-relax-gdesc-ie.s -index c20690c..38b3721 100644 ---- a/ld/testsuite/ld-aarch64/tls-relax-gdesc-ie.s -+++ b/ld/testsuite/ld-aarch64/tls-relax-gdesc-ie.s -@@ -4,7 +4,7 @@ var: - .word 2 - .text - adrp x0, :tlsdesc:var -- ldr x1, [x0, #:tlsdesc_lo12:var] -+ ldr x17, [x0, #:tlsdesc_lo12:var] - add x0, x0, :tlsdesc_lo12:var - .tlsdesccall var - blr x1 diff --git a/binutils-2.24-aarch64-fix-static-ifunc.patch b/binutils-2.24-aarch64-fix-static-ifunc.patch deleted file mode 100644 index 296f162..0000000 --- a/binutils-2.24-aarch64-fix-static-ifunc.patch +++ /dev/null @@ -1,118 +0,0 @@ -commit 14d96265dd8fd934d868c0b8e1991e2fefbe9fc8 -Author: Will Newton -Date: Mon Nov 25 14:44:59 2013 +0000 - - bfd/elfnn-aarch64.c: Handle static links with ifunc correctly. - - The code for handling GOT references to ifunc symbols in static links - was missing. - - bfd/ChangeLog: - - 2013-11-26 Will Newton - - * elfnn-aarch64.c (elfNN_aarch64_finish_dynamic_symbol): - Handle STT_GNU_IFUNC symbols correctly in static links. - - ld/testsuite/ChangeLog: - - 2013-11-26 Will Newton - - * ld-aarch64/aarch64-elf.exp: Add ifunc-22. - * ld-aarch64/ifunc-22.d: New file. - * ld-aarch64/ifunc-22.s: Likewise. - -diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c -index 3cd3a18..9053635 100644 ---- a/bfd/elfnn-aarch64.c -+++ b/bfd/elfnn-aarch64.c -@@ -6824,7 +6824,34 @@ elfNN_aarch64_finish_dynamic_symbol (bfd *output_bfd, - + htab->root.sgot->output_offset - + (h->got.offset & ~(bfd_vma) 1)); - -- if (info->shared && SYMBOL_REFERENCES_LOCAL (info, h)) -+ if (h->def_regular -+ && h->type == STT_GNU_IFUNC) -+ { -+ if (info->shared) -+ { -+ /* Generate R_AARCH64_GLOB_DAT. */ -+ goto do_glob_dat; -+ } -+ else -+ { -+ asection *plt; -+ -+ if (!h->pointer_equality_needed) -+ abort (); -+ -+ /* For non-shared object, we can't use .got.plt, which -+ contains the real function address if we need pointer -+ equality. We load the GOT entry with the PLT entry. */ -+ plt = htab->root.splt ? htab->root.splt : htab->root.iplt; -+ bfd_put_NN (output_bfd, (plt->output_section->vma -+ + plt->output_offset -+ + h->plt.offset), -+ htab->root.sgot->contents -+ + (h->got.offset & ~(bfd_vma) 1)); -+ return TRUE; -+ } -+ } -+ else if (info->shared && SYMBOL_REFERENCES_LOCAL (info, h)) - { - if (!h->def_regular) - return FALSE; -@@ -6837,6 +6864,7 @@ elfNN_aarch64_finish_dynamic_symbol (bfd *output_bfd, - } - else - { -+do_glob_dat: - BFD_ASSERT ((h->got.offset & 1) == 0); - bfd_put_NN (output_bfd, (bfd_vma) 0, - htab->root.sgot->contents + h->got.offset); -diff --git a/ld/testsuite/ld-aarch64/aarch64-elf.exp b/ld/testsuite/ld-aarch64/aarch64-elf.exp -index a6b3ea2..692bf34 100644 ---- a/ld/testsuite/ld-aarch64/aarch64-elf.exp -+++ b/ld/testsuite/ld-aarch64/aarch64-elf.exp -@@ -156,3 +156,4 @@ run_dump_test "ifunc-19a" - run_dump_test "ifunc-19b" - run_dump_test "ifunc-20" - run_dump_test "ifunc-21" -+run_dump_test "ifunc-22" -diff --git a/ld/testsuite/ld-aarch64/ifunc-22.d b/ld/testsuite/ld-aarch64/ifunc-22.d -new file mode 100644 -index 0000000..f28b039 ---- /dev/null -+++ b/ld/testsuite/ld-aarch64/ifunc-22.d -@@ -0,0 +1,11 @@ -+#source: ifunc-22.s -+#objdump: -s -j .got -+#ld: -static -+#target: aarch64*-*-* -+ -+# Ensure GOT is populated correctly in static link -+ -+.*: file format elf64-(little|big)aarch64 -+ -+Contents of section \.got: -+ 4100f0 00000000 00000000 d0004000 00000000 ..........@..... -diff --git a/ld/testsuite/ld-aarch64/ifunc-22.s b/ld/testsuite/ld-aarch64/ifunc-22.s -new file mode 100644 -index 0000000..69a87bb ---- /dev/null -+++ b/ld/testsuite/ld-aarch64/ifunc-22.s -@@ -0,0 +1,14 @@ -+ .text -+ .type ifunc, @gnu_indirect_function -+ .global ifunc -+ifunc: -+ ret -+ .size ifunc, .-ifunc -+ .type _start, @function -+ .globl _start -+_start: -+ adrp x0, :got:ifunc -+ ldr x0, [x0, #:got_lo12:ifunc] -+ .size _start, .-_start -+ .data -+ .xword ifunc diff --git a/binutils-2.24-aarch64-ld-shared-non-PIC-xfail.patch b/binutils-2.24-aarch64-ld-shared-non-PIC-xfail.patch deleted file mode 100644 index 8525596..0000000 --- a/binutils-2.24-aarch64-ld-shared-non-PIC-xfail.patch +++ /dev/null @@ -1,55 +0,0 @@ -commit 273dc279306c2b69fbc1407cc695397e4b015152 -Author: Will Newton -Date: Fri May 16 15:22:58 2014 +0100 - - ld/aarch64: xfail non-PIC shared object tests on aarch64 - - aarch64 does not support building non-PIC shared objects, so mark - tests for these as xfail. - - ld/testsuite/ChangeLog: - - 2014-05-20 Will Newton - - * ld-shared/shared.exp: Mark non-PIC shared object tests - as xfail on aarch64. - -#-- a/ld/testsuite/ChangeLog -#++ b/ld/testsuite/ChangeLog -#@ -1,3 +1,8 @@ -+2014-05-20 Will Newton -+ -+ * ld-shared/shared.exp: Mark non-PIC shared object tests -+ as xfail on aarch64. -+ - 2014-05-19 Andreas Tobler - - * ld-elf/shared.exp: Introduce the extralibs variable to control -diff --git a/ld/testsuite/ld-shared/shared.exp b/ld/testsuite/ld-shared/shared.exp -index 9996ece..c723ef7 100644 ---- a/ld/testsuite/ld-shared/shared.exp -+++ b/ld/testsuite/ld-shared/shared.exp -@@ -244,6 +244,7 @@ if ![ld_compile "$CC $CFLAGS $SHCFLAG" $srcdir/$subdir/main.c $tmpdir/mainnp.o] - if [ string match $shared_needs_pic "yes" ] { - setup_xfail "arm*-*-linux*" - } -+ setup_xfail "aarch64*-*-linux*" - shared_test shnp "shared (non PIC)" mainnp.o sh1np.o sh2np.o shared - - # Test ELF shared library relocations with a non-zero load -@@ -270,6 +271,7 @@ if ![ld_compile "$CC $CFLAGS $SHCFLAG" $srcdir/$subdir/main.c $tmpdir/mainnp.o] - if [ string match $shared_needs_pic "yes" ] { - setup_xfail "arm*-*-linux*" - } -+ setup_xfail "aarch64*-*-linux*" - shared_test shnp "shared (non PIC, load offset)" \ - mainnp.o sh1np.o sh2np.o shared \ - "-T $srcdir/$subdir/elf-offset.ld" -@@ -326,6 +328,7 @@ if ![ld_compile "$CC $CFLAGS $SHCFLAG $picflag" $srcdir/$subdir/main.c $tmpdir/m - if [ string match $shared_needs_pic "yes" ] { - setup_xfail "arm*-*-linux*" - } -+ setup_xfail "aarch64*-*-linux*" - shared_test shmpnp "shared (PIC main, non PIC so)" mainp.o sh1np.o sh2np.o shared - } - } else { diff --git a/binutils-2.24-arm-static-tls.patch b/binutils-2.24-arm-static-tls.patch deleted file mode 100644 index 2b580f1..0000000 --- a/binutils-2.24-arm-static-tls.patch +++ /dev/null @@ -1,42 +0,0 @@ -commit eea6dad2b3ae91189caa91145dd133bae0398d21 -Author: Kyle McMartin -Date: Fri Jun 20 11:14:09 2014 +0100 - - Similarly to the AArch64 patch, set DF_STATIC_TLS for consistency with - other architectures when we emit IE relocs in a shared library. - - * elf32-arm.c (elf32_arm_check_relocs): Set DF_STATIC_TLS when - emitting initial-exec relocs when not linking an executable. - ---- a/bfd/elf32-arm.c -+++ b/bfd/elf32-arm.c -@@ -12711,6 +12711,9 @@ elf32_arm_check_relocs (bfd *abfd, struct bfd_link_info *info, - default: tls_type = GOT_NORMAL; break; - } - -+ if (!info->executable && (tls_type & GOT_TLS_IE)) -+ info->flags |= DF_STATIC_TLS; -+ - if (h != NULL) - { - h->got.refcount++; ---- a/ld/testsuite/ld-arm/tls-gdierelax2.d -+++ b/ld/testsuite/ld-arm/tls-gdierelax2.d -@@ -11,13 +11,13 @@ Disassembly of section .text: - [0-9a-f]+: e59f0004 ldr r0, \[pc, #4\] ; .* - [0-9a-f]+: e79f0000 ldr r0, \[pc, r0\] - [0-9a-f]+: e1a00000 nop ; .* -- [0-9a-f]+: 00008098 .word 0x00008098 -- [0-9a-f]+: 0000809c .word 0x0000809c -+ [0-9a-f]+: 000080a0 .word 0x000080a0 -+ [0-9a-f]+: 000080a4 .word 0x000080a4 - - [0-9a-f]+ : - [0-9a-f]+: 4801 ldr r0, \[pc, #4\] ; .* - [0-9a-f]+: 4478 add r0, pc - [0-9a-f]+: 6800 ldr r0, \[r0, #0\] - [0-9a-f]+: 46c0 nop ; .* -- [0-9a-f]+: 0000808a .word 0x0000808a -- [0-9a-f]+: 0000808c .word 0x0000808c -+ [0-9a-f]+: 00008092 .word 0x00008092 -+ [0-9a-f]+: 00008094 .word 0x00008094 diff --git a/binutils-2.24-corrupt-ar.patch b/binutils-2.24-corrupt-ar.patch deleted file mode 100644 index 8c2f77c..0000000 --- a/binutils-2.24-corrupt-ar.patch +++ /dev/null @@ -1,199 +0,0 @@ -diff -cpr ../binutils-2.24.orig/bfd/archive.c ./bfd/archive.c -*** ../binutils-2.24.orig/bfd/archive.c 2014-11-13 11:08:46.720741346 +0000 ---- ./bfd/archive.c 2014-11-13 11:12:38.908876606 +0000 -*************** _bfd_slurp_extended_name_table (bfd *abf -*** 1299,1304 **** ---- 1299,1306 ---- - { - byebye: - free (namedata); -+ bfd_ardata (abfd)->extended_names = NULL; -+ bfd_ardata (abfd)->extended_names_size = 0; - return FALSE; - } - -diff -cpr ../binutils-2.24.orig/binutils/ar.c ./binutils/ar.c -*** ../binutils-2.24.orig/binutils/ar.c 2014-11-13 11:08:46.808741776 +0000 ---- ./binutils/ar.c 2014-11-13 11:10:10.510151199 +0000 -*************** extract_file (bfd *abfd) -*** 1031,1036 **** ---- 1031,1045 ---- - bfd_size_type size; - struct stat buf; - -+ /* PR binutils/17533: Do not allow directory traversal -+ outside of the current directory tree. */ -+ if (! is_valid_archive_path (bfd_get_filename (abfd))) -+ { -+ non_fatal (_("illegal pathname found in archive member: %s"), -+ bfd_get_filename (abfd)); -+ return; -+ } -+ - if (bfd_stat_arch_elt (abfd, &buf) != 0) - /* xgettext:c-format */ - fatal (_("internal stat error on %s"), bfd_get_filename (abfd)); -Only in ./binutils: ar.c.orig -diff -cpr ../binutils-2.24.orig/binutils/bucomm.c ./binutils/bucomm.c -*** ../binutils-2.24.orig/binutils/bucomm.c 2014-11-13 11:08:46.791741693 +0000 ---- ./binutils/bucomm.c 2014-11-13 11:10:10.511151188 +0000 -*************** bfd_get_archive_filename (const bfd *abf -*** 624,626 **** ---- 624,652 ---- - bfd_get_filename (abfd)); - return buf; - } -+ -+ /* Returns TRUE iff PATHNAME, a filename of an archive member, -+ is valid for writing. For security reasons absolute paths -+ and paths containing /../ are not allowed. See PR 17533. */ -+ -+ bfd_boolean -+ is_valid_archive_path (char const * pathname) -+ { -+ const char * n = pathname; -+ -+ if (IS_ABSOLUTE_PATH (n)) -+ return FALSE; -+ -+ while (*n) -+ { -+ if (*n == '.' && *++n == '.' && ( ! *++n || IS_DIR_SEPARATOR (*n))) -+ return FALSE; -+ -+ while (*n && ! IS_DIR_SEPARATOR (*n)) -+ n++; -+ while (IS_DIR_SEPARATOR (*n)) -+ n++; -+ } -+ -+ return TRUE; -+ } -diff -cpr ../binutils-2.24.orig/binutils/bucomm.h ./binutils/bucomm.h -*** ../binutils-2.24.orig/binutils/bucomm.h 2014-11-13 11:08:46.798741727 +0000 ---- ./binutils/bucomm.h 2014-11-13 11:10:10.511151188 +0000 -*************** bfd_vma parse_vma (const char *, const c -*** 58,63 **** ---- 58,65 ---- - - off_t get_file_size (const char *); - -+ bfd_boolean is_valid_archive_path (char const *); -+ - extern char *program_name; - - /* filemode.c */ -diff -cpr ../binutils-2.24.orig/binutils/doc/binutils.texi ./binutils/doc/binutils.texi -*** ../binutils-2.24.orig/binutils/doc/binutils.texi 2014-11-13 11:08:46.955742495 +0000 ---- ./binutils/doc/binutils.texi 2014-11-13 11:10:10.513151165 +0000 -*************** a normal archive. Instead the elements -*** 234,240 **** - individually to the second archive. - - The paths to the elements of the archive are stored relative to the -! archive itself. - - @cindex compatibility, @command{ar} - @cindex @command{ar} compatibility ---- 234,241 ---- - individually to the second archive. - - The paths to the elements of the archive are stored relative to the -! archive itself. For security reasons absolute paths and paths with a -! @code{/../} component are not allowed. - - @cindex compatibility, @command{ar} - @cindex @command{ar} compatibility -diff -cpr ../binutils-2.24.orig/binutils/objcopy.c ./binutils/objcopy.c -*** ../binutils-2.24.orig/binutils/objcopy.c 2014-11-13 11:08:46.798741727 +0000 ---- ./binutils/objcopy.c 2014-11-13 11:10:10.514151156 +0000 -*************** copy_archive (bfd *ibfd, bfd *obfd, cons -*** 2182,2187 **** ---- 2182,2197 ---- - bfd_boolean del = TRUE; - bfd_boolean ok_object; - -+ /* PR binutils/17533: Do not allow directory traversal -+ outside of the current directory tree by archive members. */ -+ if (! is_valid_archive_path (bfd_get_filename (this_element))) -+ { -+ non_fatal (_("illegal pathname found in archive member: %s"), -+ bfd_get_filename (this_element)); -+ status = 1; -+ goto cleanup_and_exit; -+ } -+ - /* Create an output file for this member. */ - output_name = concat (dir, "/", - bfd_get_filename (this_element), (char *) 0); -*************** copy_archive (bfd *ibfd, bfd *obfd, cons -*** 2191,2198 **** - { - output_name = make_tempdir (output_name); - if (output_name == NULL) -! fatal (_("cannot create tempdir for archive copying (error: %s)"), -! strerror (errno)); - - l = (struct name_list *) xmalloc (sizeof (struct name_list)); - l->name = output_name; ---- 2201,2212 ---- - { - output_name = make_tempdir (output_name); - if (output_name == NULL) -! { -! non_fatal (_("cannot create tempdir for archive copying (error: %s)"), -! strerror (errno)); -! status = 1; -! goto cleanup_and_exit; -! } - - l = (struct name_list *) xmalloc (sizeof (struct name_list)); - l->name = output_name; -*************** copy_archive (bfd *ibfd, bfd *obfd, cons -*** 2234,2240 **** - { - bfd_nonfatal_message (output_name, NULL, NULL, NULL); - status = 1; -! return; - } - - if (ok_object) ---- 2248,2254 ---- - { - bfd_nonfatal_message (output_name, NULL, NULL, NULL); - status = 1; -! goto cleanup_and_exit; - } - - if (ok_object) -*************** copy_archive (bfd *ibfd, bfd *obfd, cons -*** 2295,2301 **** - { - status = 1; - bfd_nonfatal_message (filename, NULL, NULL, NULL); -- return; - } - - filename = bfd_get_filename (ibfd); ---- 2309,2314 ---- -*************** copy_archive (bfd *ibfd, bfd *obfd, cons -*** 2303,2311 **** - { - status = 1; - bfd_nonfatal_message (filename, NULL, NULL, NULL); -- return; - } - - /* Delete all the files that we opened. */ - for (l = list; l != NULL; l = l->next) - { ---- 2316,2324 ---- - { - status = 1; - bfd_nonfatal_message (filename, NULL, NULL, NULL); - } - -+ cleanup_and_exit: - /* Delete all the files that we opened. */ - for (l = list; l != NULL; l = l->next) - { diff --git a/binutils-2.24-corrupt-binaries.patch b/binutils-2.24-corrupt-binaries.patch deleted file mode 100644 index b3985a9..0000000 --- a/binutils-2.24-corrupt-binaries.patch +++ /dev/null @@ -1,1041 +0,0 @@ -diff -cpr ../binutils-2.24.orig/bfd/elf.c bfd/elf.c -*** ../binutils-2.24.orig/bfd/elf.c 2014-10-31 11:50:20.132220820 +0000 ---- bfd/elf.c 2014-10-31 11:53:23.669281197 +0000 -*************** setup_group (bfd *abfd, Elf_Internal_Shd -*** 608,616 **** - if (shdr->contents == NULL) - { - _bfd_error_handler -! (_("%B: Corrupt size field in group section header: 0x%lx"), abfd, shdr->sh_size); - bfd_set_error (bfd_error_bad_value); -! return FALSE; - } - - memset (shdr->contents, 0, amt); ---- 608,617 ---- - if (shdr->contents == NULL) - { - _bfd_error_handler -! (_("%B: corrupt size field in group section header: 0x%lx"), abfd, shdr->sh_size); - bfd_set_error (bfd_error_bad_value); -! -- num_group; -! continue; - } - - memset (shdr->contents, 0, amt); -*************** setup_group (bfd *abfd, Elf_Internal_Shd -*** 618,625 **** - if (bfd_seek (abfd, shdr->sh_offset, SEEK_SET) != 0 - || (bfd_bread (shdr->contents, shdr->sh_size, abfd) - != shdr->sh_size)) -! return FALSE; -! - /* Translate raw contents, a flag word followed by an - array of elf section indices all in target byte order, - to the flag word followed by an array of elf section ---- 619,635 ---- - if (bfd_seek (abfd, shdr->sh_offset, SEEK_SET) != 0 - || (bfd_bread (shdr->contents, shdr->sh_size, abfd) - != shdr->sh_size)) -! { -! _bfd_error_handler -! (_("%B: invalid size field in group section header: 0x%lx"), abfd, shdr->sh_size); -! bfd_set_error (bfd_error_bad_value); -! -- num_group; -! /* PR 17510: If the group contents are even partially -! corrupt, do not allow any of the contents to be used. */ -! memset (shdr->contents, 0, amt); -! continue; -! } -! - /* Translate raw contents, a flag word followed by an - array of elf section indices all in target byte order, - to the flag word followed by an array of elf section -*************** setup_group (bfd *abfd, Elf_Internal_Shd -*** 651,656 **** ---- 661,681 ---- - } - } - } -+ -+ /* PR 17510: Corrupt binaries might contain invalid groups. */ -+ if (num_group != (unsigned) elf_tdata (abfd)->num_group) -+ { -+ elf_tdata (abfd)->num_group = num_group; -+ -+ /* If all groups are invalid then fail. */ -+ if (num_group == 0) -+ { -+ elf_tdata (abfd)->group_sect_ptr = NULL; -+ elf_tdata (abfd)->num_group = num_group = -1; -+ (*_bfd_error_handler) (_("%B: no valid group sections found"), abfd); -+ bfd_set_error (bfd_error_bad_value); -+ } -+ } - } - } - -*************** setup_group (bfd *abfd, Elf_Internal_Shd -*** 716,721 **** ---- 741,747 ---- - { - (*_bfd_error_handler) (_("%B: no group info for section %A"), - abfd, newsect); -+ return FALSE; - } - return TRUE; - } -*************** bfd_section_from_shdr (bfd *abfd, unsign -*** 1556,1593 **** - Elf_Internal_Ehdr *ehdr; - const struct elf_backend_data *bed; - const char *name; - - if (shindex >= elf_numsections (abfd)) - return FALSE; - - hdr = elf_elfsections (abfd)[shindex]; - ehdr = elf_elfheader (abfd); - name = bfd_elf_string_from_elf_section (abfd, ehdr->e_shstrndx, - hdr->sh_name); - if (name == NULL) -! return FALSE; - - bed = get_elf_backend_data (abfd); - switch (hdr->sh_type) - { - case SHT_NULL: - /* Inactive section. Throw it away. */ -! return TRUE; - -! case SHT_PROGBITS: /* Normal section with contents. */ -! case SHT_NOBITS: /* .bss section. */ -! case SHT_HASH: /* .hash section. */ -! case SHT_NOTE: /* .note section. */ - case SHT_INIT_ARRAY: /* .init_array section. */ - case SHT_FINI_ARRAY: /* .fini_array section. */ - case SHT_PREINIT_ARRAY: /* .preinit_array section. */ - case SHT_GNU_LIBLIST: /* .gnu.liblist section. */ - case SHT_GNU_HASH: /* .gnu.hash section. */ -! return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); - - case SHT_DYNAMIC: /* Dynamic linking information. */ - if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex)) -! return FALSE; - if (hdr->sh_link > elf_numsections (abfd)) - { - /* PR 10478: Accept Solaris binaries with a sh_link ---- 1582,1655 ---- - Elf_Internal_Ehdr *ehdr; - const struct elf_backend_data *bed; - const char *name; -+ bfd_boolean ret = TRUE; -+ static bfd_boolean * sections_being_created = NULL; -+ static bfd * sections_being_created_abfd = NULL; -+ static unsigned int nesting = 0; - - if (shindex >= elf_numsections (abfd)) - return FALSE; - -+ if (++ nesting > 3) -+ { -+ /* PR17512: A corrupt ELF binary might contain a recursive group of -+ sections, each the string indicies pointing to the next in the -+ loop. Detect this here, by refusing to load a section that we are -+ already in the process of loading. We only trigger this test if -+ we have nested at least three sections deep as normal ELF binaries -+ can expect to recurse at least once. -+ -+ FIXME: It would be better if this array was attached to the bfd, -+ rather than being held in a static pointer. */ -+ -+ if (sections_being_created_abfd != abfd) -+ sections_being_created = NULL; -+ if (sections_being_created == NULL) -+ { -+ /* FIXME: It would be more efficient to attach this array to the bfd somehow. */ -+ sections_being_created = (bfd_boolean *) -+ bfd_zalloc (abfd, elf_numsections (abfd) * sizeof (bfd_boolean)); -+ sections_being_created_abfd = abfd; -+ } -+ if (sections_being_created [shindex]) -+ { -+ (*_bfd_error_handler) -+ (_("%B: warning: loop in section dependencies detected"), abfd); -+ return FALSE; -+ } -+ sections_being_created [shindex] = TRUE; -+ } -+ - hdr = elf_elfsections (abfd)[shindex]; - ehdr = elf_elfheader (abfd); - name = bfd_elf_string_from_elf_section (abfd, ehdr->e_shstrndx, - hdr->sh_name); - if (name == NULL) -! goto fail; - - bed = get_elf_backend_data (abfd); - switch (hdr->sh_type) - { - case SHT_NULL: - /* Inactive section. Throw it away. */ -! goto success; - -! case SHT_PROGBITS: /* Normal section with contents. */ -! case SHT_NOBITS: /* .bss section. */ -! case SHT_HASH: /* .hash section. */ -! case SHT_NOTE: /* .note section. */ - case SHT_INIT_ARRAY: /* .init_array section. */ - case SHT_FINI_ARRAY: /* .fini_array section. */ - case SHT_PREINIT_ARRAY: /* .preinit_array section. */ - case SHT_GNU_LIBLIST: /* .gnu.liblist section. */ - case SHT_GNU_HASH: /* .gnu.hash section. */ -! ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); -! goto success; - - case SHT_DYNAMIC: /* Dynamic linking information. */ - if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex)) -! goto fail; -! - if (hdr->sh_link > elf_numsections (abfd)) - { - /* PR 10478: Accept Solaris binaries with a sh_link -*************** bfd_section_from_shdr (bfd *abfd, unsign -*** 1601,1611 **** - break; - /* Otherwise fall through. */ - default: -! return FALSE; - } - } - else if (elf_elfsections (abfd)[hdr->sh_link] == NULL) -! return FALSE; - else if (elf_elfsections (abfd)[hdr->sh_link]->sh_type != SHT_STRTAB) - { - Elf_Internal_Shdr *dynsymhdr; ---- 1663,1673 ---- - break; - /* Otherwise fall through. */ - default: -! goto fail; - } - } - else if (elf_elfsections (abfd)[hdr->sh_link] == NULL) -! goto fail; - else if (elf_elfsections (abfd)[hdr->sh_link]->sh_type != SHT_STRTAB) - { - Elf_Internal_Shdr *dynsymhdr; -*************** bfd_section_from_shdr (bfd *abfd, unsign -*** 1634,1657 **** - } - } - } -! break; - -! case SHT_SYMTAB: /* A symbol table */ - if (elf_onesymtab (abfd) == shindex) -! return TRUE; - - if (hdr->sh_entsize != bed->s->sizeof_sym) -! return FALSE; - if (hdr->sh_info * hdr->sh_entsize > hdr->sh_size) - { - if (hdr->sh_size != 0) -! return FALSE; - /* Some assemblers erroneously set sh_info to one with a - zero sh_size. ld sees this as a global symbol count - of (unsigned) -1. Fix it here. */ - hdr->sh_info = 0; -! return TRUE; - } - BFD_ASSERT (elf_onesymtab (abfd) == 0); - elf_onesymtab (abfd) = shindex; - elf_tdata (abfd)->symtab_hdr = *hdr; ---- 1696,1721 ---- - } - } - } -! goto success; - -! case SHT_SYMTAB: /* A symbol table. */ - if (elf_onesymtab (abfd) == shindex) -! goto success; - - if (hdr->sh_entsize != bed->s->sizeof_sym) -! goto fail; -! - if (hdr->sh_info * hdr->sh_entsize > hdr->sh_size) - { - if (hdr->sh_size != 0) -! goto fail; - /* Some assemblers erroneously set sh_info to one with a - zero sh_size. ld sees this as a global symbol count - of (unsigned) -1. Fix it here. */ - hdr->sh_info = 0; -! goto success; - } -+ - BFD_ASSERT (elf_onesymtab (abfd) == 0); - elf_onesymtab (abfd) = shindex; - elf_tdata (abfd)->symtab_hdr = *hdr; -*************** bfd_section_from_shdr (bfd *abfd, unsign -*** 1668,1674 **** - && (abfd->flags & DYNAMIC) != 0 - && ! _bfd_elf_make_section_from_shdr (abfd, hdr, name, - shindex)) -! return FALSE; - - /* Go looking for SHT_SYMTAB_SHNDX too, since if there is one we - can't read symbols without that section loaded as well. It ---- 1732,1738 ---- - && (abfd->flags & DYNAMIC) != 0 - && ! _bfd_elf_make_section_from_shdr (abfd, hdr, name, - shindex)) -! goto fail; - - /* Go looking for SHT_SYMTAB_SHNDX too, since if there is one we - can't read symbols without that section loaded as well. It -*************** bfd_section_from_shdr (bfd *abfd, unsign -*** 1694,1719 **** - break; - } - if (i != shindex) -! return bfd_section_from_shdr (abfd, i); - } -! return TRUE; - -! case SHT_DYNSYM: /* A dynamic symbol table */ - if (elf_dynsymtab (abfd) == shindex) -! return TRUE; - - if (hdr->sh_entsize != bed->s->sizeof_sym) -! return FALSE; - if (hdr->sh_info * hdr->sh_entsize > hdr->sh_size) - { - if (hdr->sh_size != 0) -! return FALSE; - /* Some linkers erroneously set sh_info to one with a - zero sh_size. ld sees this as a global symbol count - of (unsigned) -1. Fix it here. */ - hdr->sh_info = 0; -! return TRUE; - } - BFD_ASSERT (elf_dynsymtab (abfd) == 0); - elf_dynsymtab (abfd) = shindex; - elf_tdata (abfd)->dynsymtab_hdr = *hdr; ---- 1758,1786 ---- - break; - } - if (i != shindex) -! ret = bfd_section_from_shdr (abfd, i); - } -! goto success; - -! case SHT_DYNSYM: /* A dynamic symbol table. */ - if (elf_dynsymtab (abfd) == shindex) -! goto success; - - if (hdr->sh_entsize != bed->s->sizeof_sym) -! goto fail; -! - if (hdr->sh_info * hdr->sh_entsize > hdr->sh_size) - { - if (hdr->sh_size != 0) -! goto fail; -! - /* Some linkers erroneously set sh_info to one with a - zero sh_size. ld sees this as a global symbol count - of (unsigned) -1. Fix it here. */ - hdr->sh_info = 0; -! goto success; - } -+ - BFD_ASSERT (elf_dynsymtab (abfd) == 0); - elf_dynsymtab (abfd) = shindex; - elf_tdata (abfd)->dynsymtab_hdr = *hdr; -*************** bfd_section_from_shdr (bfd *abfd, unsign -*** 1722,1755 **** - - /* Besides being a symbol table, we also treat this as a regular - section, so that objcopy can handle it. */ -! return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); - -! case SHT_SYMTAB_SHNDX: /* Symbol section indices when >64k sections */ - if (elf_symtab_shndx (abfd) == shindex) -! return TRUE; - - BFD_ASSERT (elf_symtab_shndx (abfd) == 0); - elf_symtab_shndx (abfd) = shindex; - elf_tdata (abfd)->symtab_shndx_hdr = *hdr; - elf_elfsections (abfd)[shindex] = &elf_tdata (abfd)->symtab_shndx_hdr; -! return TRUE; - -! case SHT_STRTAB: /* A string table */ - if (hdr->bfd_section != NULL) -! return TRUE; - if (ehdr->e_shstrndx == shindex) - { - elf_tdata (abfd)->shstrtab_hdr = *hdr; - elf_elfsections (abfd)[shindex] = &elf_tdata (abfd)->shstrtab_hdr; -! return TRUE; - } - if (elf_elfsections (abfd)[elf_onesymtab (abfd)]->sh_link == shindex) - { - symtab_strtab: - elf_tdata (abfd)->strtab_hdr = *hdr; - elf_elfsections (abfd)[shindex] = &elf_tdata (abfd)->strtab_hdr; -! return TRUE; - } - if (elf_elfsections (abfd)[elf_dynsymtab (abfd)]->sh_link == shindex) - { - dynsymtab_strtab: ---- 1789,1826 ---- - - /* Besides being a symbol table, we also treat this as a regular - section, so that objcopy can handle it. */ -! ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); -! goto success; - -! case SHT_SYMTAB_SHNDX: /* Symbol section indices when >64k sections. */ - if (elf_symtab_shndx (abfd) == shindex) -! goto success; - - BFD_ASSERT (elf_symtab_shndx (abfd) == 0); - elf_symtab_shndx (abfd) = shindex; - elf_tdata (abfd)->symtab_shndx_hdr = *hdr; - elf_elfsections (abfd)[shindex] = &elf_tdata (abfd)->symtab_shndx_hdr; -! goto success; - -! case SHT_STRTAB: /* A string table. */ - if (hdr->bfd_section != NULL) -! goto success; -! - if (ehdr->e_shstrndx == shindex) - { - elf_tdata (abfd)->shstrtab_hdr = *hdr; - elf_elfsections (abfd)[shindex] = &elf_tdata (abfd)->shstrtab_hdr; -! goto success; - } -+ - if (elf_elfsections (abfd)[elf_onesymtab (abfd)]->sh_link == shindex) - { - symtab_strtab: - elf_tdata (abfd)->strtab_hdr = *hdr; - elf_elfsections (abfd)[shindex] = &elf_tdata (abfd)->strtab_hdr; -! goto success; - } -+ - if (elf_elfsections (abfd)[elf_dynsymtab (abfd)]->sh_link == shindex) - { - dynsymtab_strtab: -*************** bfd_section_from_shdr (bfd *abfd, unsign -*** 1758,1765 **** - elf_elfsections (abfd)[shindex] = hdr; - /* We also treat this as a regular section, so that objcopy - can handle it. */ -! return _bfd_elf_make_section_from_shdr (abfd, hdr, name, -! shindex); - } - - /* If the string table isn't one of the above, then treat it as a ---- 1829,1837 ---- - elf_elfsections (abfd)[shindex] = hdr; - /* We also treat this as a regular section, so that objcopy - can handle it. */ -! ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, -! shindex); -! goto success; - } - - /* If the string table isn't one of the above, then treat it as a -*************** bfd_section_from_shdr (bfd *abfd, unsign -*** 1777,1785 **** - { - /* Prevent endless recursion on broken objects. */ - if (i == shindex) -! return FALSE; - if (! bfd_section_from_shdr (abfd, i)) -! return FALSE; - if (elf_onesymtab (abfd) == i) - goto symtab_strtab; - if (elf_dynsymtab (abfd) == i) ---- 1849,1857 ---- - { - /* Prevent endless recursion on broken objects. */ - if (i == shindex) -! goto fail; - if (! bfd_section_from_shdr (abfd, i)) -! goto fail; - if (elf_onesymtab (abfd) == i) - goto symtab_strtab; - if (elf_dynsymtab (abfd) == i) -*************** bfd_section_from_shdr (bfd *abfd, unsign -*** 1787,1793 **** - } - } - } -! return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); - - case SHT_REL: - case SHT_RELA: ---- 1859,1866 ---- - } - } - } -! ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); -! goto success; - - case SHT_REL: - case SHT_RELA: -*************** bfd_section_from_shdr (bfd *abfd, unsign -*** 1802,1808 **** - if (hdr->sh_entsize - != (bfd_size_type) (hdr->sh_type == SHT_REL - ? bed->s->sizeof_rel : bed->s->sizeof_rela)) -! return FALSE; - - /* Check for a bogus link to avoid crashing. */ - if (hdr->sh_link >= num_sec) ---- 1875,1881 ---- - if (hdr->sh_entsize - != (bfd_size_type) (hdr->sh_type == SHT_REL - ? bed->s->sizeof_rel : bed->s->sizeof_rela)) -! goto fail; - - /* Check for a bogus link to avoid crashing. */ - if (hdr->sh_link >= num_sec) -*************** bfd_section_from_shdr (bfd *abfd, unsign -*** 1810,1817 **** - ((*_bfd_error_handler) - (_("%B: invalid link %lu for reloc section %s (index %u)"), - abfd, hdr->sh_link, name, shindex)); -! return _bfd_elf_make_section_from_shdr (abfd, hdr, name, -! shindex); - } - - /* For some incomprehensible reason Oracle distributes ---- 1883,1891 ---- - ((*_bfd_error_handler) - (_("%B: invalid link %lu for reloc section %s (index %u)"), - abfd, hdr->sh_link, name, shindex)); -! ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, -! shindex); -! goto success; - } - - /* For some incomprehensible reason Oracle distributes -*************** bfd_section_from_shdr (bfd *abfd, unsign -*** 1852,1858 **** - if ((elf_elfsections (abfd)[hdr->sh_link]->sh_type == SHT_SYMTAB - || elf_elfsections (abfd)[hdr->sh_link]->sh_type == SHT_DYNSYM) - && ! bfd_section_from_shdr (abfd, hdr->sh_link)) -! return FALSE; - - /* If this reloc section does not use the main symbol table we - don't treat it as a reloc section. BFD can't adequately ---- 1926,1932 ---- - if ((elf_elfsections (abfd)[hdr->sh_link]->sh_type == SHT_SYMTAB - || elf_elfsections (abfd)[hdr->sh_link]->sh_type == SHT_DYNSYM) - && ! bfd_section_from_shdr (abfd, hdr->sh_link)) -! goto fail; - - /* If this reloc section does not use the main symbol table we - don't treat it as a reloc section. BFD can't adequately -*************** bfd_section_from_shdr (bfd *abfd, unsign -*** 1867,1880 **** - || hdr->sh_info >= num_sec - || elf_elfsections (abfd)[hdr->sh_info]->sh_type == SHT_REL - || elf_elfsections (abfd)[hdr->sh_info]->sh_type == SHT_RELA) -! return _bfd_elf_make_section_from_shdr (abfd, hdr, name, -! shindex); - - if (! bfd_section_from_shdr (abfd, hdr->sh_info)) -! return FALSE; - target_sect = bfd_section_from_elf_index (abfd, hdr->sh_info); - if (target_sect == NULL) -! return FALSE; - - esdt = elf_section_data (target_sect); - if (hdr->sh_type == SHT_RELA) ---- 1941,1958 ---- - || hdr->sh_info >= num_sec - || elf_elfsections (abfd)[hdr->sh_info]->sh_type == SHT_REL - || elf_elfsections (abfd)[hdr->sh_info]->sh_type == SHT_RELA) -! { -! ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, -! shindex); -! goto success; -! } - - if (! bfd_section_from_shdr (abfd, hdr->sh_info)) -! goto fail; -! - target_sect = bfd_section_from_elf_index (abfd, hdr->sh_info); - if (target_sect == NULL) -! goto fail; - - esdt = elf_section_data (target_sect); - if (hdr->sh_type == SHT_RELA) -*************** bfd_section_from_shdr (bfd *abfd, unsign -*** 1886,1892 **** - amt = sizeof (*hdr2); - hdr2 = (Elf_Internal_Shdr *) bfd_alloc (abfd, amt); - if (hdr2 == NULL) -! return FALSE; - *hdr2 = *hdr; - *p_hdr = hdr2; - elf_elfsections (abfd)[shindex] = hdr2; ---- 1964,1970 ---- - amt = sizeof (*hdr2); - hdr2 = (Elf_Internal_Shdr *) bfd_alloc (abfd, amt); - if (hdr2 == NULL) -! goto fail; - *hdr2 = *hdr; - *p_hdr = hdr2; - elf_elfsections (abfd)[shindex] = hdr2; -*************** bfd_section_from_shdr (bfd *abfd, unsign -*** 1902,1935 **** - target_sect->use_rela_p = 1; - } - abfd->flags |= HAS_RELOC; -! return TRUE; - } - - case SHT_GNU_verdef: - elf_dynverdef (abfd) = shindex; - elf_tdata (abfd)->dynverdef_hdr = *hdr; -! return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); - - case SHT_GNU_versym: - if (hdr->sh_entsize != sizeof (Elf_External_Versym)) -! return FALSE; - elf_dynversym (abfd) = shindex; - elf_tdata (abfd)->dynversym_hdr = *hdr; -! return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); - - case SHT_GNU_verneed: - elf_dynverref (abfd) = shindex; - elf_tdata (abfd)->dynverref_hdr = *hdr; -! return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); - - case SHT_SHLIB: -! return TRUE; - - case SHT_GROUP: - if (! IS_VALID_GROUP_SECTION_HEADER (hdr, GRP_ENTRY_SIZE)) -! return FALSE; - if (!_bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex)) -! return FALSE; - if (hdr->contents != NULL) - { - Elf_Internal_Group *idx = (Elf_Internal_Group *) hdr->contents; ---- 1980,2019 ---- - target_sect->use_rela_p = 1; - } - abfd->flags |= HAS_RELOC; -! goto success; - } - - case SHT_GNU_verdef: - elf_dynverdef (abfd) = shindex; - elf_tdata (abfd)->dynverdef_hdr = *hdr; -! ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); -! goto success; - - case SHT_GNU_versym: - if (hdr->sh_entsize != sizeof (Elf_External_Versym)) -! goto fail; -! - elf_dynversym (abfd) = shindex; - elf_tdata (abfd)->dynversym_hdr = *hdr; -! ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); -! goto success; - - case SHT_GNU_verneed: - elf_dynverref (abfd) = shindex; - elf_tdata (abfd)->dynverref_hdr = *hdr; -! ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); -! goto success; - - case SHT_SHLIB: -! goto success; - - case SHT_GROUP: - if (! IS_VALID_GROUP_SECTION_HEADER (hdr, GRP_ENTRY_SIZE)) -! goto fail; -! - if (!_bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex)) -! goto fail; -! - if (hdr->contents != NULL) - { - Elf_Internal_Group *idx = (Elf_Internal_Group *) hdr->contents; -*************** bfd_section_from_shdr (bfd *abfd, unsign -*** 1955,1961 **** - } - } - } -! break; - - default: - /* Possibly an attributes section. */ ---- 2039,2045 ---- - } - } - } -! goto success; - - default: - /* Possibly an attributes section. */ -*************** bfd_section_from_shdr (bfd *abfd, unsign -*** 1963,1976 **** - || hdr->sh_type == bed->obj_attrs_section_type) - { - if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex)) -! return FALSE; - _bfd_elf_parse_attributes (abfd, hdr); -! return TRUE; - } - - /* Check for any processor-specific section types. */ - if (bed->elf_backend_section_from_shdr (abfd, hdr, name, shindex)) -! return TRUE; - - if (hdr->sh_type >= SHT_LOUSER && hdr->sh_type <= SHT_HIUSER) - { ---- 2047,2060 ---- - || hdr->sh_type == bed->obj_attrs_section_type) - { - if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex)) -! goto fail; - _bfd_elf_parse_attributes (abfd, hdr); -! goto success; - } - - /* Check for any processor-specific section types. */ - if (bed->elf_backend_section_from_shdr (abfd, hdr, name, shindex)) -! goto success; - - if (hdr->sh_type >= SHT_LOUSER && hdr->sh_type <= SHT_HIUSER) - { -*************** bfd_section_from_shdr (bfd *abfd, unsign -*** 1982,1990 **** - "specific section `%s' [0x%8x]"), - abfd, name, hdr->sh_type); - else -! /* Allow sections reserved for applications. */ -! return _bfd_elf_make_section_from_shdr (abfd, hdr, name, -! shindex); - } - else if (hdr->sh_type >= SHT_LOPROC - && hdr->sh_type <= SHT_HIPROC) ---- 2066,2077 ---- - "specific section `%s' [0x%8x]"), - abfd, name, hdr->sh_type); - else -! { -! /* Allow sections reserved for applications. */ -! ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, -! shindex); -! goto success; -! } - } - else if (hdr->sh_type >= SHT_LOPROC - && hdr->sh_type <= SHT_HIPROC) -*************** bfd_section_from_shdr (bfd *abfd, unsign -*** 2005,2012 **** - "`%s' [0x%8x]"), - abfd, name, hdr->sh_type); - else -! /* Otherwise it should be processed. */ -! return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); - } - else - /* FIXME: We should handle this section. */ ---- 2092,2102 ---- - "`%s' [0x%8x]"), - abfd, name, hdr->sh_type); - else -! { -! /* Otherwise it should be processed. */ -! ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); -! goto success; -! } - } - else - /* FIXME: We should handle this section. */ -*************** bfd_section_from_shdr (bfd *abfd, unsign -*** 2014,2023 **** - (_("%B: don't know how to handle section `%s' [0x%8x]"), - abfd, name, hdr->sh_type); - -! return FALSE; - } - -! return TRUE; - } - - /* Return the local symbol specified by ABFD, R_SYMNDX. */ ---- 2104,2123 ---- - (_("%B: don't know how to handle section `%s' [0x%8x]"), - abfd, name, hdr->sh_type); - -! goto fail; - } - -! fail: -! ret = FALSE; -! success: -! if (sections_being_created && sections_being_created_abfd == abfd) -! sections_being_created [shindex] = FALSE; -! if (-- nesting == 0) -! { -! sections_being_created = NULL; -! sections_being_created_abfd = abfd; -! } -! return ret; - } - - /* Return the local symbol specified by ABFD, R_SYMNDX. */ -*************** elfcore_write_lwpstatus (bfd *abfd, -*** 9296,9302 **** - lwpstat.pr_lwpid = pid >> 16; - lwpstat.pr_cursig = cursig; - #if defined (HAVE_LWPSTATUS_T_PR_REG) -! memcpy (lwpstat.pr_reg, gregs, sizeof (lwpstat.pr_reg)); - #elif defined (HAVE_LWPSTATUS_T_PR_CONTEXT) - #if !defined(gregs) - memcpy (lwpstat.pr_context.uc_mcontext.gregs, ---- 9396,9402 ---- - lwpstat.pr_lwpid = pid >> 16; - lwpstat.pr_cursig = cursig; - #if defined (HAVE_LWPSTATUS_T_PR_REG) -! memcpy (&lwpstat.pr_reg, gregs, sizeof (lwpstat.pr_reg)); - #elif defined (HAVE_LWPSTATUS_T_PR_CONTEXT) - #if !defined(gregs) - memcpy (lwpstat.pr_context.uc_mcontext.gregs, -diff -cpr ../binutils-2.24.orig/bfd/ihex.c bfd/ihex.c -*** ../binutils-2.24.orig/bfd/ihex.c 2014-10-31 11:50:20.143220890 +0000 ---- bfd/ihex.c 2014-10-31 11:51:45.746721162 +0000 -*************** ihex_scan (bfd *abfd) -*** 322,328 **** - { - if (! ISHEX (buf[i])) - { -! ihex_bad_byte (abfd, lineno, hdr[i], error); - goto error_return; - } - } ---- 322,328 ---- - { - if (! ISHEX (buf[i])) - { -! ihex_bad_byte (abfd, lineno, buf[i], error); - goto error_return; - } - } -diff -cpr ../binutils-2.24.orig/bfd/peXXigen.c bfd/peXXigen.c -*** ../binutils-2.24.orig/bfd/peXXigen.c 2014-10-31 11:50:20.149220928 +0000 ---- bfd/peXXigen.c 2014-10-31 11:51:00.397462266 +0000 -*************** _bfd_XXi_swap_aouthdr_in (bfd * abfd, -*** 460,465 **** ---- 460,476 ---- - { - int idx; - -+ /* PR 17512: Corrupt PE binaries can cause seg-faults. */ -+ if (a->NumberOfRvaAndSizes > 16) -+ { -+ (*_bfd_error_handler) -+ (_("%B: aout header specifies an invalid number of data-directory entries: %d"), -+ abfd, a->NumberOfRvaAndSizes); -+ /* Paranoia: If the number is corrupt, then assume that the -+ actual entries themselves might be corrupt as well. */ -+ a->NumberOfRvaAndSizes = 0; -+ } -+ - for (idx = 0; idx < a->NumberOfRvaAndSizes; idx++) - { - /* If data directory is empty, rva also should be 0. */ -*************** pe_print_edata (bfd * abfd, void * vfile -*** 1364,1370 **** - bfd_size_type datasize = 0; - bfd_size_type dataoff; - bfd_size_type i; -! bfd_signed_vma adj; - struct EDT_type - { - long export_flags; /* Reserved - should be zero. */ ---- 1375,1381 ---- - bfd_size_type datasize = 0; - bfd_size_type dataoff; - bfd_size_type i; -! bfd_vma adj; - struct EDT_type - { - long export_flags; /* Reserved - should be zero. */ -*************** pe_print_edata (bfd * abfd, void * vfile -*** 1414,1419 **** ---- 1425,1437 ---- - _("\nThere is an export table, but the section containing it could not be found\n")); - return TRUE; - } -+ else if (!(section->flags & SEC_HAS_CONTENTS)) -+ { -+ fprintf (file, -+ _("\nThere is an export table in %s, but that section has no contents\n"), -+ section->name); -+ return TRUE; -+ } - - dataoff = addr - section->vma; - datasize = extra->DataDirectory[PE_EXPORT_TABLE].Size; -*************** pe_print_edata (bfd * abfd, void * vfile -*** 1426,1431 **** ---- 1444,1458 ---- - } - } - -+ /* PR 17512: Handle corrupt PE binaries. */ -+ if (datasize < 36) -+ { -+ fprintf (file, -+ _("\nThere is an export table in %s, but it is too small (%d)\n"), -+ section->name, (int) datasize); -+ return TRUE; -+ } -+ - fprintf (file, _("\nThere is an export table in %s at 0x%lx\n"), - section->name, (unsigned long) addr); - -*************** pe_print_edata (bfd * abfd, void * vfile -*** 1469,1476 **** - fprintf (file, - _("Name \t\t\t\t")); - bfd_fprintf_vma (abfd, file, edt.name); -! fprintf (file, -! " %s\n", data + edt.name - adj); - - fprintf (file, - _("Ordinal Base \t\t\t%ld\n"), edt.base); ---- 1496,1506 ---- - fprintf (file, - _("Name \t\t\t\t")); - bfd_fprintf_vma (abfd, file, edt.name); -! -! if ((edt.name >= adj) && (edt.name < adj + datasize)) -! fprintf (file, " %s\n", data + edt.name - adj); -! else -! fprintf (file, "(outside .edata section)\n"); - - fprintf (file, - _("Ordinal Base \t\t\t%ld\n"), edt.base); -*************** pe_print_edata (bfd * abfd, void * vfile -*** 1516,1522 **** - _("\nExport Address Table -- Ordinal Base %ld\n"), - edt.base); - -! for (i = 0; i < edt.num_functions; ++i) - { - bfd_vma eat_member = bfd_get_32 (abfd, - data + edt.eat_addr + (i * 4) - adj); ---- 1546,1557 ---- - _("\nExport Address Table -- Ordinal Base %ld\n"), - edt.base); - -! /* PR 17512: Handle corrupt PE binaries. */ -! if (edt.eat_addr + (edt.num_functions * 4) - adj >= datasize) -! fprintf (file, _("\tInvalid Export Address Table rva (0x%lx) or entry count (0x%lx)\n"), -! (long) edt.eat_addr, -! (long) edt.num_functions); -! else for (i = 0; i < edt.num_functions; ++i) - { - bfd_vma eat_member = bfd_get_32 (abfd, - data + edt.eat_addr + (i * 4) - adj); -*************** pe_print_edata (bfd * abfd, void * vfile -*** 1552,1558 **** - fprintf (file, - _("\n[Ordinal/Name Pointer] Table\n")); - -! for (i = 0; i < edt.num_names; ++i) - { - bfd_vma name_ptr = bfd_get_32 (abfd, - data + ---- 1587,1602 ---- - fprintf (file, - _("\n[Ordinal/Name Pointer] Table\n")); - -! /* PR 17512: Handle corrupt PE binaries. */ -! if (edt.npt_addr + (edt.num_names * 4) - adj >= datasize) -! fprintf (file, _("\tInvalid Name Pointer Table rva (0x%lx) or entry count (0x%lx)\n"), -! (long) edt.npt_addr, -! (long) edt.num_names); -! else if (edt.ot_addr + (edt.num_names * 2) - adj >= datasize) -! fprintf (file, _("\tInvalid Ordinal Table rva (0x%lx) or entry count (0x%lx)\n"), -! (long) edt.ot_addr, -! (long) edt.num_names); -! else for (i = 0; i < edt.num_names; ++i) - { - bfd_vma name_ptr = bfd_get_32 (abfd, - data + -diff -cpr ../binutils-2.24.orig/bfd/srec.c bfd/srec.c -*** ../binutils-2.24.orig/bfd/srec.c 2014-10-31 11:50:20.144220896 +0000 ---- bfd/srec.c 2014-10-31 11:50:55.808436025 +0000 -*************** srec_bad_byte (bfd *abfd, -*** 248,254 **** - } - else - { -! char buf[10]; - - if (! ISPRINT (c)) - sprintf (buf, "\\%03o", (unsigned int) c); ---- 248,254 ---- - } - else - { -! char buf[40]; - - if (! ISPRINT (c)) - sprintf (buf, "\\%03o", (unsigned int) c); -*************** srec_scan (bfd *abfd) -*** 454,461 **** - case 'S': - { - file_ptr pos; -! char hdr[3]; -! unsigned int bytes; - bfd_vma address; - bfd_byte *data; - unsigned char check_sum; ---- 454,461 ---- - case 'S': - { - file_ptr pos; -! unsigned char hdr[3]; -! unsigned int bytes, min_bytes; - bfd_vma address; - bfd_byte *data; - unsigned char check_sum; -*************** srec_scan (bfd *abfd) -*** 478,483 **** ---- 478,496 ---- - } - - check_sum = bytes = HEX (hdr + 1); -+ min_bytes = 3; -+ if (hdr[0] == '2' || hdr[0] == '8') -+ min_bytes = 4; -+ else if (hdr[0] == '3' || hdr[0] == '7') -+ min_bytes = 5; -+ if (bytes < min_bytes) -+ { -+ (*_bfd_error_handler) (_("%B:%d: byte count %d too small\n"), -+ abfd, lineno, bytes); -+ bfd_set_error (bfd_error_bad_value); -+ goto error_return; -+ } -+ - if (bytes * 2 > bufsize) - { - if (buf != NULL) diff --git a/binutils-2.24-elfnn-aarch64.patch b/binutils-2.24-elfnn-aarch64.patch deleted file mode 100644 index 469387b..0000000 --- a/binutils-2.24-elfnn-aarch64.patch +++ /dev/null @@ -1,21 +0,0 @@ -*** ../binutils-2.24.orig/bfd/elfnn-aarch64.c 2013-12-17 11:16:28.723807381 +0000 ---- bfd/elfnn-aarch64.c 2013-12-17 11:18:13.517804067 +0000 -*************** _aarch64_elf_section_data; -*** 1679,1686 **** - #define elf_aarch64_section_data(sec) \ - ((_aarch64_elf_section_data *) elf_section_data (sec)) - -! /* The size of the thread control block. */ -! #define TCB_SIZE 16 - - struct elf_aarch64_local_symbol - { ---- 1679,1686 ---- - #define elf_aarch64_section_data(sec) \ - ((_aarch64_elf_section_data *) elf_section_data (sec)) - -! /* The size of the thread control block which is defined to be two pointers. */ -! #define TCB_SIZE (ARCH_SIZE/8)*2 - - struct elf_aarch64_local_symbol - { diff --git a/binutils-2.24-fake-zlib-sections.patch b/binutils-2.24-fake-zlib-sections.patch deleted file mode 100644 index e02dd51..0000000 --- a/binutils-2.24-fake-zlib-sections.patch +++ /dev/null @@ -1,30 +0,0 @@ -*** ../binutils-2.24.orig/bfd/compress.c 2014-04-28 16:35:20.429816317 +0100 ---- bfd/compress.c 2014-04-28 16:36:06.450963028 +0100 -*************** -*** 25,30 **** ---- 25,31 ---- - #ifdef HAVE_ZLIB_H - #include - #endif -+ #include "safe-ctype.h" - - #ifdef HAVE_ZLIB_H - static bfd_boolean -*************** bfd_is_section_compressed (bfd *abfd, se -*** 304,309 **** ---- 305,319 ---- - compressed = (bfd_get_section_contents (abfd, sec, compressed_buffer, 0, 12) - && CONST_STRNEQ ((char*) compressed_buffer, "ZLIB")); - -+ /* Check for the pathalogical case of a debug string section that -+ contains the string ZLIB.... as the first entry. We assume that -+ no uncompressed .debug_str section would ever be big enough to -+ have the first byte of its (big-endian) size be non-zero. */ -+ if (compressed -+ && strcmp (sec->name, ".debug_str") == 0 -+ && ISPRINT (compressed_buffer[4])) -+ compressed = FALSE; -+ - /* Restore compress_status. */ - sec->compress_status = saved; - return compressed; diff --git a/binutils-2.24-fat-lto-objects.patch b/binutils-2.24-fat-lto-objects.patch deleted file mode 100644 index fe9c334..0000000 --- a/binutils-2.24-fat-lto-objects.patch +++ /dev/null @@ -1,57 +0,0 @@ -commit b35d44f1af711925bfa4344ef00470fee67122f1 -Author: Kyrylo Tkachov -Date: Wed Nov 27 13:43:39 2013 +0000 - - [ld/testsuite/] - 2013-11-27 Kyrylo Tkachov - - * ld-plugin/lto.exp: Add -ffat-lto-objects. - * lib/ld-lib.exp (check_lto_available): Likewise. - ---- a/ld/testsuite/ld-plugin/lto.exp -+++ b/ld/testsuite/ld-plugin/lto.exp -@@ -57,7 +57,7 @@ set lto_link_tests { - "" "-O2" - {lto-3c.c} {} "libdummy.a"} - {"Build liblto-3.a" -- "" "-flto" -+ "" "-flto -ffat-lto-objects" - {lto-3b.c} {} "liblto-3.a"} - {"Build libdummy.a 5a" - "" "-flto" -@@ -111,7 +111,7 @@ set lto_link_tests { - "" "" - {pr12758a.s} {} "libdummy.a"} - {"Build libpr12758.a" -- "" "-flto -O2" -+ "" "-flto -O2 -ffat-lto-objects" - {pr12758b.c} {} "libpr12758.a"} - {"PR ld/12758" - "-O2 -Wl,-e,foo -nostdlib -flto -fuse-linker-plugin tmpdir/pr12758a.o -Wl,--start-group tmpdir/libpr12758.a -Wl,--end-group" "" -@@ -120,13 +120,13 @@ set lto_link_tests { - "" "" - {pr12760a.c} {} "libdummy.a"} - {"Build libpr12760.a" -- "" "-flto -O2" -+ "" "-flto -O2 -ffat-lto-objects" - {pr12760b.c} {} "libpr12760.a"} - {"PR ld/12760" - "-O2 -Wl,-e,foo -nostdlib -flto -fuse-linker-plugin tmpdir/pr12760a.o -Wl,--start-group tmpdir/libpr12760.a -Wl,--end-group" "" - {dummy.c} {} "pr12760.exe" "c" "warning: Bad bar"} - {"Build libpr13183.a" -- "-T" "-flto -O2" -+ "-T" "-flto -O2 -ffat-lto-objects" - {pr13183a.c} {} "libpr13183.a"} - {"Build libdummy.a PR ld/13183" - "" "-flto -O2" ---- a/ld/testsuite/lib/ld-lib.exp -+++ b/ld/testsuite/lib/ld-lib.exp -@@ -1643,7 +1643,7 @@ proc check_lto_available { } { - set f [open $src "w"] - puts $f "" - close $f -- set status [remote_exec host $CC "-shared -B[pwd]/tmpdir/ld/ -flto -fuse-linker-plugin $src -o $output"] -+ set status [remote_exec host $CC "-shared -B[pwd]/tmpdir/ld/ -flto -ffat-lto-objects -fuse-linker-plugin $src -o $output"] - if { [lindex $status 0] == 0 } { - set lto_available_saved 1 - } else { diff --git a/binutils-2.24-indirect-chain.patch b/binutils-2.24-indirect-chain.patch deleted file mode 100644 index b255424..0000000 --- a/binutils-2.24-indirect-chain.patch +++ /dev/null @@ -1,28 +0,0 @@ -*** ../binutils-2.24.orig/bfd/elflink.c 2014-08-21 09:17:27.753408085 +0100 ---- bfd/elflink.c 2014-08-21 10:04:52.174935912 +0100 -*************** _bfd_elf_add_default_symbol (bfd *abfd, -*** 1705,1710 **** ---- 1705,1716 ---- - ht = (struct elf_link_hash_entry *) hi->root.u.i.link; - (*bed->elf_backend_copy_indirect_symbol) (info, ht, hi); - -+ /* A reference to the SHORTNAME symbol from a dynamic library -+ will be satisfied by the versioned symbol at runtime. In -+ effect, we have a reference to the versioned symbol. */ -+ ht->ref_dynamic_nonweak |= hi->ref_dynamic_nonweak; -+ hi->dynamic_def |= ht->dynamic_def; -+ - /* See if the new flags lead us to realize that the symbol must - be dynamic. */ - if (! *dynsym) -*************** nondefault: -*** 1774,1779 **** ---- 1780,1787 ---- - if (hi->root.type == bfd_link_hash_indirect) - { - (*bed->elf_backend_copy_indirect_symbol) (info, h, hi); -+ h->ref_dynamic_nonweak |= hi->ref_dynamic_nonweak; -+ hi->dynamic_def |= h->dynamic_def; - - /* See if the new flags lead us to realize that the symbol - must be dynamic. */ diff --git a/binutils-2.24-ldforcele.patch b/binutils-2.24-ldforcele.patch index 6a46c78..194cf1e 100644 --- a/binutils-2.24-ldforcele.patch +++ b/binutils-2.24-ldforcele.patch @@ -1,54 +1,50 @@ Common subdirectories: ../binutils-2.24.orig/ld/emulparams and ld/emulparams Common subdirectories: ../binutils-2.24.orig/ld/emultempl and ld/emultempl -diff -cp ../binutils-2.24.orig/ld/ldlang.c ld/ldlang.c -*** ../binutils-2.24.orig/ld/ldlang.c 2014-05-09 10:35:04.589504928 +0100 ---- ld/ldlang.c 2014-05-09 10:35:55.515661478 +0100 -*************** lang_add_output_format (const char *form -*** 7096,7101 **** ---- 7096,7113 ---- - && little != NULL) - format = little; - -+ if (getenv ("LD_FORCE_LE") != NULL) -+ { -+ if (strcmp (format, "elf64-powerpc") == 0) -+ format = "elf64-powerpcle"; -+ else if (strcmp (format, "elf32-powerpc") == 0) -+ format = "elf32-powerpcle"; -+ else if (strcmp (format, "elf64-big") == 0) -+ format = "elf64-little"; -+ else if (strcmp (format, "elf32-big") == 0) -+ format = "elf32-little"; -+ } -+ - output_target = format; - } - } +diff -up ../binutils-2.24.orig/ld/ldlang.c ld/ldlang.c +--- a/ld/ldlang.c 2014-05-09 10:35:04.589504928 +0100 ++++ b/ld/ldlang.c 2014-05-09 10:35:55.515661478 +0100 +@@ -7096,6 +7096,18 @@ + && little != NULL) + format = little; + ++ if (getenv ("LD_FORCE_LE") != NULL) ++ { ++ if (strcmp (format, "elf64-powerpc") == 0) ++ format = "elf64-powerpcle"; ++ else if (strcmp (format, "elf32-powerpc") == 0) ++ format = "elf32-powerpcle"; ++ else if (strcmp (format, "elf64-big") == 0) ++ format = "elf64-little"; ++ else if (strcmp (format, "elf32-big") == 0) ++ format = "elf32-little"; ++ } ++ + output_target = format; + } + } Only in ld: ldlang.c.orig -diff -cp ../binutils-2.24.orig/ld/ldmain.c ld/ldmain.c -*** ../binutils-2.24.orig/ld/ldmain.c 2014-05-09 10:35:04.593504941 +0100 ---- ld/ldmain.c 2014-05-09 10:35:55.515661478 +0100 -*************** get_emulation (int argc, char **argv) -*** 603,608 **** ---- 603,620 ---- - } - } - -+ if ((strncmp (emulation, "elf64ppc", 8) == 0 -+ || strncmp (emulation, "elf32ppc", 8) == 0) -+ && getenv ("LD_FORCE_LE") != NULL) -+ { -+ size_t len = strlen (emulation); -+ char *le = xmalloc (len + 2); -+ memcpy (le, emulation, 5); -+ le[5] = 'l'; -+ memcpy (le + 6, emulation + 5, len - 4); -+ emulation = le; -+ } -+ - return emulation; - } - +diff -up ../binutils-2.24.orig/ld/ldmain.c ld/ldmain.c +--- a/ld/ldmain.c 2014-05-09 10:35:04.593504941 +0100 ++++ b/ld/ldmain.c 2014-05-09 10:35:55.515661478 +0100 +@@ -603,6 +603,18 @@ + } + } + ++ if ((strncmp (emulation, "elf64ppc", 8) == 0 ++ || strncmp (emulation, "elf32ppc", 8) == 0) ++ && getenv ("LD_FORCE_LE") != NULL) ++ { ++ size_t len = strlen (emulation); ++ char *le = xmalloc (len + 2); ++ memcpy (le, emulation, 5); ++ le[5] = 'l'; ++ memcpy (le + 6, emulation + 5, len - 4); ++ emulation = le; ++ } ++ + return emulation; + } + Only in ld: ldmain.c.orig Common subdirectories: ../binutils-2.24.orig/ld/ldscripts and ld/ldscripts Common subdirectories: ../binutils-2.24.orig/ld/.libs and ld/.libs diff --git a/binutils-2.24-s390-mkopc.patch b/binutils-2.24-s390-mkopc.patch deleted file mode 100644 index 33deda8..0000000 --- a/binutils-2.24-s390-mkopc.patch +++ /dev/null @@ -1,19 +0,0 @@ -*** ../binutils-2.24.orig/opcodes/s390-mkopc.c 2013-12-05 13:06:00.082812690 +0000 ---- opcodes/s390-mkopc.c 2013-12-05 13:13:40.206798138 +0000 -*************** dumpTable (void) -*** 298,304 **** - int ix; - - /* Write hash table entries (slots). */ -! printf (file_header); - - for (ix = 0; ix < no_ops; ix++) - { ---- 298,304 ---- - int ix; - - /* Write hash table entries (slots). */ -! printf ("%s", file_header); - - for (ix = 0; ix < no_ops; ix++) - { diff --git a/binutils-2.24-set-section-macros.patch b/binutils-2.24-set-section-macros.patch deleted file mode 100644 index 6171c48..0000000 --- a/binutils-2.24-set-section-macros.patch +++ /dev/null @@ -1,103 +0,0 @@ -diff -rcp ../binutils-2.24.orig/bfd/bfd-in2.h bfd/bfd-in2.h -*** ../binutils-2.24.orig/bfd/bfd-in2.h 2014-04-22 12:03:35.226872578 +0100 ---- bfd/bfd-in2.h 2014-04-22 12:07:51.556393678 +0100 -*************** typedef struct bfd_section *sec_ptr; -*** 294,302 **** - - #define bfd_is_com_section(ptr) (((ptr)->flags & SEC_IS_COMMON) != 0) - -- #define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (ptr)->lma = (val)), ((ptr)->user_set_vma = TRUE), TRUE) -- #define bfd_set_section_alignment(bfd, ptr, val) (((ptr)->alignment_power = (val)),TRUE) -- #define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),TRUE) - /* Find the address one past the end of SEC. */ - #define bfd_get_section_limit(bfd, sec) \ - (((bfd)->direction != write_direction && (sec)->rawsize != 0 \ ---- 294,299 ---- -*************** struct relax_table { -*** 1592,1597 **** ---- 1589,1620 ---- - int size; - }; - -+ /* Note: the following are provided as inline functions rather than macros -+ because not all callers use the return value. A macro implementation -+ would use a comma expression, eg: "((ptr)->foo = val, TRUE)" and some -+ compilers will complain about comma expressions that have no effect. */ -+ static inline bfd_boolean -+ bfd_set_section_userdata (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, void * val) -+ { -+ ptr->userdata = val; -+ return TRUE; -+ } -+ -+ static inline bfd_boolean -+ bfd_set_section_vma (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, bfd_vma val) -+ { -+ ptr->vma = ptr->lma = val; -+ ptr->user_set_vma = TRUE; -+ return TRUE; -+ } -+ -+ static inline bfd_boolean -+ bfd_set_section_alignment (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, unsigned int val) -+ { -+ ptr->alignment_power = val; -+ return TRUE; -+ } -+ - /* These sections are global, and are managed by BFD. The application - and target back end are not permitted to change the values in - these sections. */ -diff -rcp ../binutils-2.24.orig/bfd/bfd-in.h bfd/bfd-in.h -*** ../binutils-2.24.orig/bfd/bfd-in.h 2014-04-22 12:03:35.272868967 +0100 ---- bfd/bfd-in.h 2014-04-22 12:06:12.850914084 +0100 -*************** typedef struct bfd_section *sec_ptr; -*** 287,295 **** - - #define bfd_is_com_section(ptr) (((ptr)->flags & SEC_IS_COMMON) != 0) - -- #define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (ptr)->lma = (val)), ((ptr)->user_set_vma = TRUE), TRUE) -- #define bfd_set_section_alignment(bfd, ptr, val) (((ptr)->alignment_power = (val)),TRUE) -- #define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),TRUE) - /* Find the address one past the end of SEC. */ - #define bfd_get_section_limit(bfd, sec) \ - (((bfd)->direction != write_direction && (sec)->rawsize != 0 \ ---- 287,292 ---- -diff -rcp ../binutils-2.24.orig/bfd/section.c bfd/section.c -*** ../binutils-2.24.orig/bfd/section.c 2014-04-22 12:03:35.215873442 +0100 ---- bfd/section.c 2014-04-22 12:06:55.795118059 +0100 -*************** CODE_FRAGMENT -*** 542,547 **** ---- 542,573 ---- - . int size; - .}; - . -+ .{* Note: the following are provided as inline functions rather than macros -+ . because not all callers use the return value. A macro implementation -+ . would use a comma expression, eg: "((ptr)->foo = val, TRUE)" and some -+ . compilers will complain about comma expressions that have no effect. *} -+ .static inline bfd_boolean -+ .bfd_set_section_userdata (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, void * val) -+ .{ -+ . ptr->userdata = val; -+ . return TRUE; -+ .} -+ . -+ .static inline bfd_boolean -+ .bfd_set_section_vma (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, bfd_vma val) -+ .{ -+ . ptr->vma = ptr->lma = val; -+ . ptr->user_set_vma = TRUE; -+ . return TRUE; -+ .} -+ . -+ .static inline bfd_boolean -+ .bfd_set_section_alignment (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, unsigned int val) -+ .{ -+ . ptr->alignment_power = val; -+ . return TRUE; -+ .} -+ . - .{* These sections are global, and are managed by BFD. The application - . and target back end are not permitted to change the values in - . these sections. *} diff --git a/binutils-2.24-strings-default-all.patch b/binutils-2.24-strings-default-all.patch deleted file mode 100644 index 97b9f8e..0000000 --- a/binutils-2.24-strings-default-all.patch +++ /dev/null @@ -1,310 +0,0 @@ -diff -cpr ../binutils-2.24.orig/binutils/config.in binutils/config.in -*** ../binutils-2.24.orig/binutils/config.in 2014-10-31 11:50:20.455222877 +0000 ---- binutils/config.in 2014-10-31 11:59:05.021241036 +0000 -*************** -*** 18,23 **** ---- 18,26 ---- - /* Should ar and ranlib use -D behavior by default? */ - #undef DEFAULT_AR_DETERMINISTIC - -+ /* Should strings use -a behavior by default? */ -+ #undef DEFAULT_STRINGS_ALL -+ - /* Define to 1 if translation of program messages to the user's native - language is requested. */ - #undef ENABLE_NLS -diff -cpr ../binutils-2.24.orig/binutils/configure binutils/configure -*** ../binutils-2.24.orig/binutils/configure 2014-10-31 11:50:20.590223736 +0000 ---- binutils/configure 2014-10-31 12:01:46.570102643 +0000 -*************** with_gnu_ld -*** 772,777 **** ---- 772,778 ---- - enable_libtool_lock - enable_targets - enable_deterministic_archives -+ enable_default_strings_all - enable_werror - enable_build_warnings - enable_nls -*************** Optional Features: -*** 1421,1426 **** ---- 1422,1429 ---- - --enable-targets alternative target configurations - --enable-deterministic-archives - ar and ranlib default to -D behavior -+ --disable-default-strings-all -+ strings defaults to --data behavior - --enable-werror treat compile warnings as errors - --enable-build-warnings enable build-time compiler warnings - --disable-nls do not use Native Language Support -*************** cat >>confdefs.h <<_ACEOF -*** 11615,11620 **** ---- 11594,11618 ---- - _ACEOF - - -+ # Check whether --enable-default-strings-all was given. -+ if test "${enable_default_strings_all+set}" = set; then : -+ enableval=$enable_default_strings_all; -+ if test "${enableval}" = no; then -+ default_strings_all=0 -+ else -+ default_strings_all=1 -+ fi -+ else -+ default_strings_all=1 -+ fi -+ -+ -+ -+ cat >>confdefs.h <<_ACEOF -+ #define DEFAULT_STRINGS_ALL $default_strings_all -+ _ACEOF -+ -+ - - GCC_WARN_CFLAGS="-W -Wall -Wstrict-prototypes -Wmissing-prototypes" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -diff -cpr ../binutils-2.24.orig/binutils/configure.in binutils/configure.in -*** ../binutils-2.24.orig/binutils/configure.in 2014-10-31 11:50:20.430222717 +0000 ---- binutils/configure.in 2014-10-31 12:00:48.092790946 +0000 -*************** fi], [default_ar_deterministic=0]) -*** 57,62 **** ---- 57,74 ---- - AC_DEFINE_UNQUOTED(DEFAULT_AR_DETERMINISTIC, $default_ar_deterministic, - [Should ar and ranlib use -D behavior by default?]) - -+ AC_ARG_ENABLE(default-strings-all, -+ [AS_HELP_STRING([--disable-default-strings-all], -+ [strings defaults to --data behavior])], [ -+ if test "${enableval}" = no; then -+ default_strings_all=0 -+ else -+ default_strings_all=1 -+ fi], [default_strings_all=1]) -+ -+ AC_DEFINE_UNQUOTED(DEFAULT_STRINGS_ALL, $default_strings_all, -+ [Should strings use -a behavior by default?]) -+ - AM_BINUTILS_WARNINGS - - AC_CONFIG_HEADERS(config.h:config.in) -diff -cpr ../binutils-2.24.orig/binutils/doc/binutils.texi binutils/doc/binutils.texi -*** ../binutils-2.24.orig/binutils/doc/binutils.texi 2014-10-31 11:50:20.579223666 +0000 ---- binutils/doc/binutils.texi 2014-10-31 11:59:23.052339164 +0000 -*************** strings [@option{-afovV}] [@option{-}@va -*** 2653,2667 **** - - @c man begin DESCRIPTION strings - -! For each @var{file} given, @sc{gnu} @command{strings} prints the printable -! character sequences that are at least 4 characters long (or the number -! given with the options below) and are followed by an unprintable -! character. By default, it only prints the strings from the initialized -! and loaded sections of object files; for other types of files, it prints -! the strings from the whole file. - -! @command{strings} is mainly useful for determining the contents of non-text -! files. - - @c man end - ---- 2653,2676 ---- - - @c man begin DESCRIPTION strings - -! For each @var{file} given, @sc{gnu} @command{strings} prints the -! printable character sequences that are at least 4 characters long (or -! the number given with the options below) and are followed by an -! unprintable character. -! -! Depending upon how the strings program was configured it will default -! to either displaying all the printable sequences that it can find in -! each file, or only those sequences that are in loadable, initialized -! data sections. If the file type in unrecognizable, or if strings is -! reading from stdin then it will always display all of the printable -! sequences that it can find. -! -! For backwards compatibility any file that occurs after a command line -! option of just @option{-} will also be scanned in full, regardless of -! the presence of any @option{-d} option. - -! @command{strings} is mainly useful for determining the contents of -! non-text files. - - @c man end - -*************** files. -*** 2671,2678 **** - @item -a - @itemx --all - @itemx - -! Do not scan only the initialized and loaded sections of object files; -! scan the whole files. - - @item -f - @itemx --print-file-name ---- 2680,2704 ---- - @item -a - @itemx --all - @itemx - -! Scan the whole file, regardless of what sections it contains or -! whether those sections are loaded or initialized. Normally this is -! the default behaviour, but strings can be configured so that the -! @option{-d} is the default instead. -! -! The @option{-} option is position dependent and forces strings to -! perform full scans of any file that is mentioned after the @option{-} -! on the command line, even if the @option{-d} option has been -! specified. -! -! @item -d -! @itemx --data -! Only print strings from initialized, loaded data sections in the -! file. This may reduce the amount of garbage in the output, but it -! also exposes the strings program to any security flaws that may be -! present in the BFD library used to scan and load sections. Strings -! can be configured so that this option is the default behaviour. In -! such cases the @option{-a} option can be used to avoid using the BFD -! library and instead just print all of the strings found in the file. - - @item -f - @itemx --print-file-name -diff -cpr ../binutils-2.24.orig/binutils/NEWS binutils/NEWS -*** ../binutils-2.24.orig/binutils/NEWS 2014-10-31 11:50:20.338222131 +0000 ---- binutils/NEWS 2014-10-31 11:59:52.315493579 +0000 -*************** -*** 1,5 **** ---- 1,10 ---- - -*- text -*- - -+ * Add --data option to strings to only print strings in loadable, initialized -+ data sections. Change the default behaviour to be --all, but add a new -+ configure time option of --disable-default-strings-all to restore the old -+ default behaviour. -+ - Changes in 2.24: - - * Objcopy now supports wildcard characters in command line options that take -diff -cpr ../binutils-2.24.orig/binutils/strings.c binutils/strings.c -*** ../binutils-2.24.orig/binutils/strings.c 2014-10-31 11:50:20.464222934 +0000 ---- binutils/strings.c 2014-10-31 12:01:33.901035485 +0000 -*************** -*** 23,29 **** - Options: - --all - -a -! - Do not scan only the initialized data section of object files. - - --print-file-name - -f Print the name of the file before each string. ---- 23,32 ---- - Options: - --all - -a -! - Scan each file in its entirety. -! -! --data -! -d Scan only the initialized data section(s) of object files. - - --print-file-name - -f Print the name of the file before each string. -*************** static int encoding_bytes; -*** 107,112 **** ---- 110,116 ---- - static struct option long_options[] = - { - {"all", no_argument, NULL, 'a'}, -+ {"data", no_argument, NULL, 'd'}, - {"print-file-name", no_argument, NULL, 'f'}, - {"bytes", required_argument, NULL, 'n'}, - {"radix", required_argument, NULL, 't'}, -*************** typedef struct -*** 128,134 **** - - static void strings_a_section (bfd *, asection *, void *); - static bfd_boolean strings_object_file (const char *); -! static bfd_boolean strings_file (char *file); - static void print_strings (const char *, FILE *, file_ptr, int, int, char *); - static void usage (FILE *, int); - static long get_char (FILE *, file_ptr *, int *, char **); ---- 132,138 ---- - - static void strings_a_section (bfd *, asection *, void *); - static bfd_boolean strings_object_file (const char *); -! static bfd_boolean strings_file (char *); - static void print_strings (const char *, FILE *, file_ptr, int, int, char *); - static void usage (FILE *, int); - static long get_char (FILE *, file_ptr *, int *, char **); -*************** main (int argc, char **argv) -*** 158,168 **** - string_min = 4; - print_addresses = FALSE; - print_filenames = FALSE; -! datasection_only = TRUE; - target = NULL; - encoding = 's'; - -! while ((optc = getopt_long (argc, argv, "afhHn:ot:e:T:Vv0123456789", - long_options, (int *) 0)) != EOF) - { - switch (optc) ---- 162,175 ---- - string_min = 4; - print_addresses = FALSE; - print_filenames = FALSE; -! if (DEFAULT_STRINGS_ALL) -! datasection_only = FALSE; -! else -! datasection_only = TRUE; - target = NULL; - encoding = 's'; - -! while ((optc = getopt_long (argc, argv, "adfhHn:ot:e:T:Vv0123456789", - long_options, (int *) 0)) != EOF) - { - switch (optc) -*************** main (int argc, char **argv) -*** 171,176 **** ---- 178,187 ---- - datasection_only = FALSE; - break; - -+ case 'd': -+ datasection_only = TRUE; -+ break; -+ - case 'f': - print_filenames = TRUE; - break; -*************** usage (FILE *stream, int status) -*** 635,642 **** - { - fprintf (stream, _("Usage: %s [option(s)] [file(s)]\n"), program_name); - fprintf (stream, _(" Display printable strings in [file(s)] (stdin by default)\n")); -! fprintf (stream, _(" The options are:\n\ - -a - --all Scan the entire file, not just the data section\n\ - -f --print-file-name Print the name of the file before each string\n\ - -n --bytes=[number] Locate & print any NUL-terminated sequence of at\n\ - - least [number] characters (default 4).\n\ ---- 646,663 ---- - { - fprintf (stream, _("Usage: %s [option(s)] [file(s)]\n"), program_name); - fprintf (stream, _(" Display printable strings in [file(s)] (stdin by default)\n")); -! fprintf (stream, _(" The options are:\n")); -! -! if (DEFAULT_STRINGS_ALL) -! fprintf (stream, _("\ -! -a - --all Scan the entire file, not just the data section [default]\n\ -! -d --data Only scan the data sections in the file\n")); -! else -! fprintf (stream, _("\ - -a - --all Scan the entire file, not just the data section\n\ -+ -d --data Only scan the data sections in the file [default]\n")); -+ -+ fprintf (stream, _("\ - -f --print-file-name Print the name of the file before each string\n\ - -n --bytes=[number] Locate & print any NUL-terminated sequence of at\n\ - - least [number] characters (default 4).\n\ - -Only in binutils: strings.c.rej diff --git a/binutils-2.24-symbol-warning.patch b/binutils-2.24-symbol-warning.patch deleted file mode 100644 index aff6c48..0000000 --- a/binutils-2.24-symbol-warning.patch +++ /dev/null @@ -1,114 +0,0 @@ -From 4c6d802e592b3762a149c343bc5722e065e57841 Mon Sep 17 00:00:00 2001 -From: H.J. Lu -Date: Wed, 26 Mar 2014 12:18:59 -0700 -Subject: [PATCH] Scan all input files for symbol reference warning - -This patch scans all input files for symbol reference warning if the -symbol reference doesn't exist in the current input file. - -ld/ - - PR ld/16756 - * ldmain.c (symbol_warning): New function. - (warning_callback): Use it. Scan all input files for a reference - to SYMBOL. - -ld/testsuite/ - - PR ld/16756 - * ld-plugin/lto.exp: Expect filename and line number for PR - ld/12760 test. ---- - ld/ChangeLog | 7 ++++ - ld/ldmain.c | 43 ++++++++++++++++---------- - ld/testsuite/ChangeLog | 64 ++++++++++++++++++++++------------------ - ld/testsuite/ld-plugin/lto.exp | 4 +- - 4 files changed, 70 insertions(+), 48 deletions(-) - -diff --git a/ld/ldmain.c b/ld/ldmain.c -index ffc9f84..14253a6 100644 ---- a/ld/ldmain.c -+++ b/ld/ldmain.c -@@ -1150,6 +1150,25 @@ struct warning_callback_info - asymbol **asymbols; - }; - -+/* Look through the relocs to see if we can find a plausible address -+ for SYMBOL in ABFD. Return TRUE if found. Otherwise return FALSE. */ -+ -+static bfd_boolean -+symbol_warning (const char *warning, const char *symbol, bfd *abfd) -+{ -+ struct warning_callback_info cinfo; -+ -+ if (!bfd_generic_link_read_symbols (abfd)) -+ einfo (_("%B%F: could not read symbols: %E\n"), abfd); -+ -+ cinfo.found = FALSE; -+ cinfo.warning = warning; -+ cinfo.symbol = symbol; -+ cinfo.asymbols = bfd_get_outsymbols (abfd); -+ bfd_map_over_sections (abfd, warning_find_reloc, &cinfo); -+ return cinfo.found; -+} -+ - /* This is called when there is a reference to a warning symbol. */ - - static bfd_boolean ---- a/ld/ldmain.c 2014-06-24 14:04:00.700594584 -0400 -+++ b/ld/ldmain.c 2014-06-24 14:07:19.452270808 -0400 -@@ -1172,24 +1172,14 @@ - einfo ("%P: %s%s\n", _("warning: "), warning); - else if (symbol == NULL) - einfo ("%B: %s%s\n", abfd, _("warning: "), warning); -- else if ((abfd->flags & BFD_PLUGIN) == 0) -+ else if (! symbol_warning (warning, symbol, abfd)) - { -- struct warning_callback_info cinfo; -- -- /* Look through the relocs to see if we can find a plausible -- address. */ -- -- if (!bfd_generic_link_read_symbols (abfd)) -- einfo (_("%B%F: could not read symbols: %E\n"), abfd); -- -- cinfo.found = FALSE; -- cinfo.warning = warning; -- cinfo.symbol = symbol; -- cinfo.asymbols = bfd_get_outsymbols (abfd); -- bfd_map_over_sections (abfd, warning_find_reloc, &cinfo); -- -- if (! cinfo.found) -- einfo ("%B: %s%s\n", abfd, _("warning: "), warning); -+ bfd *b; -+ /* Search all input files for a reference to SYMBOL. */ -+ for (b = info->input_bfds; b; b = b->link_next) -+ if (b != abfd && symbol_warning (warning, symbol, b)) -+ return TRUE; -+ einfo ("%B: %s%s\n", abfd, _("warning: "), warning); - } - - return TRUE; -diff --git a/ld/testsuite/ld-plugin/lto.exp b/ld/testsuite/ld-plugin/lto.exp -index af7307f..53543a6 100644 ---- a/ld/testsuite/ld-plugin/lto.exp -+++ b/ld/testsuite/ld-plugin/lto.exp -@@ -116,14 +116,14 @@ set lto_link_tests { - "-O2 -Wl,-e,foo -nostdlib -flto -fuse-linker-plugin tmpdir/pr12758a.o -Wl,--start-group tmpdir/libpr12758.a -Wl,--end-group" "" - {dummy.c} {} "pr12758.exe"} - {"Build libdummy.a PR ld/12760" -- "" "" -+ "" "-g -O0" - {pr12760a.c} {} "libdummy.a"} - {"Build libpr12760.a" - "" "-flto -O2 -ffat-lto-objects" - {pr12760b.c} {} "libpr12760.a"} - {"PR ld/12760" - "-O2 -Wl,-e,foo -nostdlib -flto -fuse-linker-plugin tmpdir/pr12760a.o -Wl,--start-group tmpdir/libpr12760.a -Wl,--end-group" "" -- {dummy.c} {} "pr12760.exe" "c" "warning: Bad bar"} -+ {dummy.c} {} "pr12760.exe" "c" "pr12760a.c:6: warning: Bad bar"} - {"Build libpr13183.a" - "-T" "-flto -O2 -ffat-lto-objects" - {pr13183a.c} {} "libpr13183.a"} --- -1.7.1 diff --git a/binutils-2.24-weak-sym-merge.patch b/binutils-2.24-weak-sym-merge.patch deleted file mode 100644 index 0625f0d..0000000 --- a/binutils-2.24-weak-sym-merge.patch +++ /dev/null @@ -1,22 +0,0 @@ -*** ../binutils-2.24.orig/bfd/elflink.c 2014-08-15 14:12:59.933394436 +0100 ---- bfd/elflink.c 2014-08-15 14:40:54.787075416 +0100 -*************** _bfd_elf_merge_symbol (bfd *abfd, -*** 1437,1443 **** - if (!(oldbfd != NULL - && (oldbfd->flags & BFD_PLUGIN) != 0 - && (abfd->flags & BFD_PLUGIN) == 0)) -! *skip = TRUE; - - /* Merge st_other. If the symbol already has a dynamic index, - but visibility says it should not be visible, turn it into a ---- 1437,1446 ---- - if (!(oldbfd != NULL - && (oldbfd->flags & BFD_PLUGIN) != 0 - && (abfd->flags & BFD_PLUGIN) == 0)) -! { -! newdef = FALSE; -! *skip = TRUE; -! } - - /* Merge st_other. If the symbol already has a dynamic index, - but visibility says it should not be visible, turn it into a diff --git a/binutils-2.25-kernel-ld-r.patch b/binutils-2.25-kernel-ld-r.patch new file mode 100644 index 0000000..8fc6c27 --- /dev/null +++ b/binutils-2.25-kernel-ld-r.patch @@ -0,0 +1,2362 @@ +diff -rup binutils-2.25.orig/bfd/bfd.c binutils-2.25/bfd/bfd.c +--- binutils-2.25.orig/bfd/bfd.c 2014-12-24 10:46:27.893435026 +0000 ++++ binutils-2.25/bfd/bfd.c 2014-12-24 10:48:25.666096395 +0000 +@@ -44,6 +44,14 @@ CODE_FRAGMENT + . both_direction = 3 + . }; + . ++.enum bfd_lto_object_type ++. { ++. lto_non_object, ++. lto_non_ir_object, ++. lto_ir_object, ++. lto_mixed_object ++. }; ++. + .struct bfd + .{ + . {* The filename the application opened the BFD with. *} +@@ -221,6 +229,9 @@ CODE_FRAGMENT + . {* The last section on the section list. *} + . struct bfd_section *section_last; + . ++. {* The object-only section on the section list. *} ++. struct bfd_section *object_only_section; ++. + . {* The number of sections. *} + . unsigned int section_count; + . +@@ -310,6 +321,9 @@ CODE_FRAGMENT + . struct objalloc *, but we use void * to avoid requiring the inclusion + . of objalloc.h. *} + . void *memory; ++. ++. {* LTO object type. *} ++. unsigned int lto_type : 2; + .}; + . + .{* See note beside bfd_set_section_userdata. *} +@@ -1923,3 +1937,36 @@ bfd_demangle (bfd *abfd, const char *nam + + return res; + } ++ ++/* ++FUNCTION ++ bfd_group_signature ++ ++SYNOPSIS ++ asymbol *bfd_group_signature (asection *group, asymbol **isympp); ++ ++DESCRIPTION ++ Return a pointer to the symbol used as a signature for GROUP. ++*/ ++ ++asymbol * ++bfd_group_signature (asection *group, asymbol **isympp) ++{ ++ bfd *abfd = group->owner; ++ Elf_Internal_Shdr *ghdr; ++ ++ if (bfd_get_flavour (abfd) != bfd_target_elf_flavour) ++ return NULL; ++ ++ ghdr = &elf_section_data (group)->this_hdr; ++ if (ghdr->sh_link < elf_numsections (abfd)) ++ { ++ const struct elf_backend_data *bed = get_elf_backend_data (abfd); ++ Elf_Internal_Shdr *symhdr = elf_elfsections (abfd) [ghdr->sh_link]; ++ ++ if (symhdr->sh_type == SHT_SYMTAB ++ && ghdr->sh_info < symhdr->sh_size / bed->s->sizeof_sym) ++ return isympp[ghdr->sh_info - 1]; ++ } ++ return NULL; ++} +Only in binutils-2.25/bfd: bfd.c.orig +Only in binutils-2.25/bfd: bfd.c.rej +diff -rup binutils-2.25.orig/bfd/bfd-in2.h binutils-2.25/bfd/bfd-in2.h +--- binutils-2.25.orig/bfd/bfd-in2.h 2014-12-24 10:46:27.890435009 +0000 ++++ binutils-2.25/bfd/bfd-in2.h 2014-12-24 10:54:21.498104097 +0000 +@@ -1078,6 +1078,9 @@ struct bfd_section *bfd_create_gnu_debug + bfd_boolean bfd_fill_in_gnu_debuglink_section + (bfd *abfd, struct bfd_section *sect, const char *filename); + ++const char *bfd_extract_object_only_section ++ (bfd *abfd); ++ + /* Extracted from libbfd.c. */ + + /* Byte swapping macros for user section data. */ +@@ -1650,6 +1653,9 @@ extern asection _bfd_std_section[4]; + || ((SEC) == bfd_com_section_ptr) \ + || ((SEC) == bfd_ind_section_ptr)) + ++/* GNU object-only section name. */ ++#define GNU_OBJECT_ONLY_SECTION_NAME ".gnu_object_only" ++ + /* Macros to handle insertion and deletion of a bfd's sections. These + only handle the list pointers, ie. do not adjust section_count, + target_index etc. */ +@@ -6269,6 +6275,14 @@ enum bfd_direction + both_direction = 3 + }; + ++enum bfd_lto_object_type ++ { ++ lto_non_object, ++ lto_non_ir_object, ++ lto_ir_object, ++ lto_mixed_object ++ }; ++ + struct bfd + { + /* The filename the application opened the BFD with. */ +@@ -6446,6 +6460,9 @@ struct bfd + /* The last section on the section list. */ + struct bfd_section *section_last; + ++ /* The object-only section on the section list. */ ++ struct bfd_section *object_only_section; ++ + /* The number of sections. */ + unsigned int section_count; + +@@ -6535,6 +6552,9 @@ struct bfd + struct objalloc *, but we use void * to avoid requiring the inclusion + of objalloc.h. */ + void *memory; ++ ++ /* LTO object type. */ ++ unsigned int lto_type : 2; + }; + + /* See note beside bfd_set_section_userdata. */ +@@ -6747,6 +6767,8 @@ void bfd_emul_set_commonpagesize (const + + char *bfd_demangle (bfd *, const char *, int); + ++asymbol *bfd_group_signature (asection *group, asymbol **isympp); ++ + /* Extracted from archive.c. */ + symindex bfd_get_next_mapent + (bfd *abfd, symindex previous, carsym **sym); +Only in binutils-2.25/bfd: bfd-in2.h.orig +Only in binutils-2.25/bfd: bfd-in2.h.rej +diff -rup binutils-2.25.orig/bfd/elf.c binutils-2.25/bfd/elf.c +--- binutils-2.25.orig/bfd/elf.c 2014-12-24 10:46:27.884434975 +0000 ++++ binutils-2.25/bfd/elf.c 2014-12-24 10:47:06.954654379 +0000 +@@ -2208,6 +2208,7 @@ static const struct bfd_elf_special_sect + { STRING_COMMA_LEN (".gnu.linkonce.b"), -2, SHT_NOBITS, SHF_ALLOC + SHF_WRITE }, + { STRING_COMMA_LEN (".gnu.lto_"), -1, SHT_PROGBITS, SHF_EXCLUDE }, + { STRING_COMMA_LEN (".got"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, ++ { STRING_COMMA_LEN (".gnu_object_only"), 0, SHT_GNU_OBJECT_ONLY, SHF_EXCLUDE }, + { STRING_COMMA_LEN (".gnu.version"), 0, SHT_GNU_versym, 0 }, + { STRING_COMMA_LEN (".gnu.version_d"), 0, SHT_GNU_verdef, 0 }, + { STRING_COMMA_LEN (".gnu.version_r"), 0, SHT_GNU_verneed, 0 }, +diff -rup binutils-2.25.orig/bfd/format.c binutils-2.25/bfd/format.c +--- binutils-2.25.orig/bfd/format.c 2014-12-24 10:46:27.897435048 +0000 ++++ binutils-2.25/bfd/format.c 2014-12-24 10:47:06.961654419 +0000 +@@ -94,6 +94,33 @@ bfd_check_format (bfd *abfd, bfd_format + return bfd_check_format_matches (abfd, format, NULL); + } + ++/* Set lto_type in ABFD. */ ++ ++static void ++bfd_set_lto_type (bfd *abfd) ++{ ++ if (abfd->format == bfd_object ++ && abfd->lto_type == lto_non_object ++ && (abfd->flags & (DYNAMIC | EXEC_P)) == 0) ++ { ++ asection *sec; ++ enum bfd_lto_object_type type = lto_non_ir_object; ++ for (sec = abfd->sections; sec != NULL; sec = sec->next) ++ { ++ if (strcmp (sec->name, GNU_OBJECT_ONLY_SECTION_NAME) == 0) ++ { ++ type = lto_mixed_object; ++ abfd->object_only_section = sec; ++ break; ++ } ++ else if (type != lto_ir_object ++ && strncmp (sec->name, ".gnu.lto_", 9) == 0) ++ type = lto_ir_object; ++ } ++ abfd->lto_type = type; ++ } ++} ++ + struct bfd_preserve + { + void *marker; +@@ -221,7 +248,10 @@ bfd_check_format_matches (bfd *abfd, bfd + } + + if (abfd->format != bfd_unknown) +- return abfd->format == format; ++ { ++ bfd_set_lto_type (abfd); ++ return abfd->format == format; ++ } + + if (matching != NULL || *bfd_associated_vector != NULL) + { +@@ -449,6 +479,9 @@ bfd_check_format_matches (bfd *abfd, bfd + if (matching_vector) + free (matching_vector); + ++ bfd_set_lto_type (abfd); ++ ++ + /* File position has moved, BTW. */ + return TRUE; + } +Only in binutils-2.25/bfd: format.c.orig +diff -rup binutils-2.25.orig/bfd/opncls.c binutils-2.25/bfd/opncls.c +--- binutils-2.25.orig/bfd/opncls.c 2014-12-24 10:46:27.903435082 +0000 ++++ binutils-2.25/bfd/opncls.c 2014-12-24 10:47:06.962654424 +0000 +@@ -1711,3 +1711,69 @@ bfd_fill_in_gnu_debuglink_section (bfd * + + return TRUE; + } ++ ++/* ++FUNCTION ++ bfd_extract_object_only_section ++ ++SYNOPSIS ++ const char *bfd_extract_object_only_section ++ (bfd *abfd); ++ ++DESCRIPTION ++ ++ Takes a @var{ABFD} and extract the .gnu_object_only section into ++ a temporary file. ++ ++RETURNS ++ The name of the temporary file is returned if all is ok. ++ Otherwise <> is returned and bfd_error is set. ++*/ ++ ++const char * ++bfd_extract_object_only_section (bfd *abfd) ++{ ++ asection *sec = abfd->object_only_section; ++ const char *name; ++ FILE *file; ++ bfd_byte *memhunk = NULL; ++ size_t off, size; ++ bfd_error_type err; ++ ++ /* Get a temporary object-only file. */ ++ name = make_temp_file (".obj-only.o"); ++ ++ /* Open the object-only file. */ ++ file = real_fopen (name, FOPEN_WB); ++ if (!bfd_get_full_section_contents (abfd, sec, &memhunk)) ++ { ++ err = bfd_get_error (); ++ ++loser: ++ free (memhunk); ++ fclose (file); ++ unlink (name); ++ bfd_set_error (err); ++ return NULL; ++ } ++ ++ off = 0; ++ size = sec->size; ++ while (off != size) ++ { ++ size_t written, nwrite = size - off; ++ ++ written = fwrite (memhunk + off, 1, nwrite, file); ++ if (written < nwrite && ferror (file)) ++ { ++ err = bfd_error_system_call; ++ goto loser; ++ } ++ ++ off += written; ++ } ++ ++ free (memhunk); ++ fclose (file); ++ return name; ++} +Only in binutils-2.25/bfd: opncls.c.orig +diff -rup binutils-2.25.orig/bfd/plugin.c binutils-2.25/bfd/plugin.c +--- binutils-2.25.orig/bfd/plugin.c 2014-12-24 10:46:27.898435054 +0000 ++++ binutils-2.25/bfd/plugin.c 2014-12-24 10:47:06.963654430 +0000 +@@ -129,6 +129,139 @@ register_claim_file (ld_plugin_claim_fil + return LDPS_OK; + } + ++static asection bfd_plugin_fake_text_section ++ = BFD_FAKE_SECTION (bfd_plugin_fake_text_section, 0, 0, ".text", 0); ++static asection bfd_plugin_fake_common_section ++ = BFD_FAKE_SECTION (bfd_plugin_fake_common_section, SEC_IS_COMMON, 0, ++ NULL, 0); ++ ++/* Get symbols from object only section. */ ++ ++static void ++bfd_plugin_get_symbols_in_object_only (bfd *abfd) ++{ ++ struct plugin_data_struct *plugin_data = abfd->tdata.plugin_data; ++ const char *object_only_file; ++ bfd *nbfd; ++ long storage; ++ long object_only_nsyms, added_nsyms, i; ++ asymbol **object_only_syms, **added_syms; ++ ++ plugin_data->object_only_syms = NULL; ++ plugin_data->object_only_nsyms = 0; ++ ++ if (abfd->sections == NULL && abfd->my_archive == NULL) ++ { ++ nbfd = bfd_openr (abfd->filename, NULL); ++ if (nbfd == NULL || !bfd_check_format (nbfd, bfd_object)) ++ { ++ (*_bfd_error_handler) ++ (_("%s: failed to open to extract object only section: %s"), ++ abfd->filename, bfd_errmsg (bfd_get_error ())); ++ bfd_close (nbfd); ++ return; ++ } ++ } ++ else ++ { ++ if (!bfd_check_format (abfd, bfd_object)) ++ { ++ (*_bfd_error_handler) ++ (_("%B: invalid file to extract object only section: %s"), ++ abfd, bfd_errmsg (bfd_get_error ())); ++ return; ++ } ++ nbfd = abfd; ++ } ++ ++ if (nbfd->lto_type == lto_mixed_object ++ && (nbfd->flags & HAS_SYMS) != 0) ++ { ++ object_only_file = bfd_extract_object_only_section (nbfd); ++ if (object_only_file == NULL) ++ (*_bfd_error_handler) ++ (_("%B: failed to extract object only section: %s"), ++ abfd, bfd_errmsg (bfd_get_error ())); ++ } ++ else ++ object_only_file = NULL; ++ ++ /* Close the new bfd we just opened. */ ++ if (nbfd != abfd) ++ bfd_close (nbfd); ++ ++ /* Return if there is no object only section or there is no ++ symbol in object only section. */ ++ if (!object_only_file) ++ return; ++ ++ /* Open the file containing object only section. */ ++ nbfd = bfd_openr (object_only_file, NULL); ++ if (!bfd_check_format (nbfd, bfd_object)) ++ { ++ (*_bfd_error_handler) ++ (_("%B: failed to open object only section: %s"), ++ abfd, bfd_errmsg (bfd_get_error ())); ++ goto quit; ++ } ++ ++ storage = bfd_get_symtab_upper_bound (nbfd); ++ if (storage <= 0) ++ { ++ if (storage < 0) ++ (*_bfd_error_handler) ++ (_("%B: failed to get symbol table in object only section: %s"), ++ abfd, bfd_errmsg (bfd_get_error ())); ++ ++ goto quit; ++ } ++ ++ object_only_syms = (asymbol **) bfd_malloc (storage); ++ object_only_nsyms = bfd_canonicalize_symtab (nbfd, object_only_syms); ++ ++ /* FIXME: We waste some spaces if not all symbols are copied. */ ++ added_syms = (asymbol **) bfd_alloc (abfd, storage); ++ added_nsyms = 0; ++ ++ /* Copy only global symbols from object only section. */ ++ for (i = 0; i < object_only_nsyms; i++) ++ { ++ asection *sec = object_only_syms[i]->section; ++ flagword flags = object_only_syms[i]->flags; ++ asymbol *s; ++ ++ if (bfd_is_com_section (sec)) ++ sec = &bfd_plugin_fake_common_section; ++ else if (bfd_is_und_section (sec)) ++ ; ++ else if ((flags & (BSF_GLOBAL | BSF_WEAK | BSF_GNU_UNIQUE)) != 0) ++ sec = &bfd_plugin_fake_text_section; ++ else ++ continue; ++ ++ s = bfd_alloc (abfd, sizeof (asymbol)); ++ BFD_ASSERT (s); ++ added_syms[added_nsyms++] = s; ++ ++ s->section = sec; ++ s->the_bfd = abfd; ++ s->name = xstrdup (object_only_syms[i]->name); ++ s->value = 0; ++ s->flags = flags; ++ s->udata.p = NULL; ++ } ++ ++ plugin_data->object_only_syms = added_syms; ++ plugin_data->object_only_nsyms = added_nsyms; ++ ++ free (object_only_syms); ++ ++quit: ++ /* Close and remove the object only section file. */ ++ bfd_close (nbfd); ++ unlink (object_only_file); ++} ++ + static enum ld_plugin_status + add_symbols (void * handle, + int nsyms, +@@ -141,7 +274,9 @@ add_symbols (void * handle, + plugin_data->nsyms = nsyms; + plugin_data->syms = syms; + +- if (nsyms != 0) ++ bfd_plugin_get_symbols_in_object_only (abfd); ++ ++ if ((nsyms + plugin_data->object_only_nsyms) != 0) + abfd->flags |= HAS_SYMS; + + abfd->tdata.plugin_data = plugin_data; +@@ -390,7 +525,8 @@ static long + bfd_plugin_get_symtab_upper_bound (bfd *abfd) + { + struct plugin_data_struct *plugin_data = abfd->tdata.plugin_data; +- long nsyms = plugin_data->nsyms; ++ /* Add symbols from object only section. */ ++ long nsyms = plugin_data->nsyms + plugin_data->object_only_nsyms; + + BFD_ASSERT (nsyms >= 0); + +@@ -424,12 +560,7 @@ bfd_plugin_canonicalize_symtab (bfd *abf + struct plugin_data_struct *plugin_data = abfd->tdata.plugin_data; + long nsyms = plugin_data->nsyms; + const struct ld_plugin_symbol *syms = plugin_data->syms; +- static asection fake_section; +- static asection fake_common_section; +- int i; +- +- fake_section.name = ".text"; +- fake_common_section.flags = SEC_IS_COMMON; ++ int i, j; + + for (i = 0; i < nsyms; i++) + { +@@ -442,10 +573,11 @@ bfd_plugin_canonicalize_symtab (bfd *abf + s->name = syms[i].name; + s->value = 0; + s->flags = convert_flags (&syms[i]); ++ s->udata.p = NULL; + switch (syms[i].def) + { + case LDPK_COMMON: +- s->section = &fake_common_section; ++ s->section = &bfd_plugin_fake_common_section; + break; + case LDPK_UNDEF: + case LDPK_WEAKUNDEF: +@@ -453,15 +585,18 @@ bfd_plugin_canonicalize_symtab (bfd *abf + break; + case LDPK_DEF: + case LDPK_WEAKDEF: +- s->section = &fake_section; ++ s->section = &bfd_plugin_fake_text_section; + break; + default: + BFD_ASSERT (0); + } +- +- s->udata.p = (void *) &syms[i]; + } + ++ /* Copy symbols from object only section. */ ++ nsyms += plugin_data->object_only_nsyms; ++ for (j = 0; j < plugin_data->object_only_nsyms; j++, i++) ++ alocation[i] = plugin_data->object_only_syms[j]; ++ + return nsyms; + } + +Only in binutils-2.25/bfd: plugin.c.orig +diff -rup binutils-2.25.orig/bfd/plugin.h binutils-2.25/bfd/plugin.h +--- binutils-2.25.orig/bfd/plugin.h 2014-12-24 10:46:27.894435031 +0000 ++++ binutils-2.25/bfd/plugin.h 2014-12-24 10:47:06.964654436 +0000 +@@ -30,6 +30,8 @@ typedef struct plugin_data_struct + { + int nsyms; + const struct ld_plugin_symbol *syms; ++ int object_only_nsyms; ++ asymbol **object_only_syms; + } + plugin_data_struct; + +diff -rup binutils-2.25.orig/bfd/section.c binutils-2.25/bfd/section.c +--- binutils-2.25.orig/bfd/section.c 2014-12-24 10:46:27.882434964 +0000 ++++ binutils-2.25/bfd/section.c 2014-12-24 10:47:07.163655553 +0000 +@@ -595,6 +595,9 @@ CODE_FRAGMENT + . || ((SEC) == bfd_com_section_ptr) \ + . || ((SEC) == bfd_ind_section_ptr)) + . ++.{* GNU object-only section name. *} ++.#define GNU_OBJECT_ONLY_SECTION_NAME ".gnu_object_only" ++. + .{* Macros to handle insertion and deletion of a bfd's sections. These + . only handle the list pointers, ie. do not adjust section_count, + . target_index etc. *} +Only in binutils-2.25/bfd: section.c.orig +diff -rup binutils-2.25.orig/binutils/objcopy.c binutils-2.25/binutils/objcopy.c +--- binutils-2.25.orig/binutils/objcopy.c 2014-12-24 10:46:27.917435160 +0000 ++++ binutils-2.25/binutils/objcopy.c 2014-12-24 10:47:07.165655564 +0000 +@@ -1009,30 +1009,6 @@ is_specified_symbol (const char *name, h + return htab_find (htab, name) != NULL; + } + +-/* Return a pointer to the symbol used as a signature for GROUP. */ +- +-static asymbol * +-group_signature (asection *group) +-{ +- bfd *abfd = group->owner; +- Elf_Internal_Shdr *ghdr; +- +- if (bfd_get_flavour (abfd) != bfd_target_elf_flavour) +- return NULL; +- +- ghdr = &elf_section_data (group)->this_hdr; +- if (ghdr->sh_link < elf_numsections (abfd)) +- { +- const struct elf_backend_data *bed = get_elf_backend_data (abfd); +- Elf_Internal_Shdr *symhdr = elf_elfsections (abfd) [ghdr->sh_link]; +- +- if (symhdr->sh_type == SHT_SYMTAB +- && ghdr->sh_info < symhdr->sh_size / bed->s->sizeof_sym) +- return isympp[ghdr->sh_info - 1]; +- } +- return NULL; +-} +- + /* Return TRUE if the section is a DWO section. */ + + static bfd_boolean +@@ -1114,7 +1090,7 @@ is_strip_section (bfd *abfd ATTRIBUTE_UN + /* PR binutils/3181 + If we are going to strip the group signature symbol, then + strip the group section too. */ +- gsym = group_signature (sec); ++ gsym = bfd_group_signature (sec, isympp); + if (gsym != NULL) + gname = gsym->name; + else +@@ -2823,7 +2799,7 @@ setup_section (bfd *ibfd, sec_ptr isecti + + if ((isection->flags & SEC_GROUP) != 0) + { +- asymbol *gsym = group_signature (isection); ++ asymbol *gsym = bfd_group_signature (isection, isympp); + + if (gsym != NULL) + { +Only in binutils-2.25/binutils: objcopy.c.orig +diff -rup binutils-2.25.orig/binutils/readelf.c binutils-2.25/binutils/readelf.c +--- binutils-2.25.orig/binutils/readelf.c 2014-12-24 10:46:27.916435155 +0000 ++++ binutils-2.25/binutils/readelf.c 2014-12-24 10:47:07.170655592 +0000 +@@ -3624,6 +3624,7 @@ get_section_type_name (unsigned int sh_t + case 0x7ffffffd: return "AUXILIARY"; + case 0x7fffffff: return "FILTER"; + case SHT_GNU_LIBLIST: return "GNU_LIBLIST"; ++ case SHT_GNU_OBJECT_ONLY: return "GNU_OBJECT_ONLY"; + + default: + if ((sh_type >= SHT_LOPROC) && (sh_type <= SHT_HIPROC)) +Only in binutils-2.25/binutils: readelf.c.orig +diff -rup binutils-2.25.orig/include/bfdlink.h binutils-2.25/include/bfdlink.h +--- binutils-2.25.orig/include/bfdlink.h 2014-12-24 10:46:27.704433964 +0000 ++++ binutils-2.25/include/bfdlink.h 2014-12-24 10:47:07.170655592 +0000 +@@ -389,6 +389,12 @@ struct bfd_link_info + /* TRUE if ok to have multiple definition. */ + unsigned int allow_multiple_definition: 1; + ++ /* TRUE if .gnu_object_only section should be created. */ ++ unsigned int emit_gnu_object_only: 1; ++ ++ /* TRUE if .gnu_object_only section is being created. */ ++ unsigned int emitting_gnu_object_only: 1; ++ + /* TRUE if ok to have version with no definition. */ + unsigned int allow_undefined_version: 1; + +Only in binutils-2.25/include: bfdlink.h.orig +diff -rup binutils-2.25.orig/include/elf/common.h binutils-2.25/include/elf/common.h +--- binutils-2.25.orig/include/elf/common.h 2014-12-24 10:46:27.698433930 +0000 ++++ binutils-2.25/include/elf/common.h 2014-12-24 10:47:07.171655598 +0000 +@@ -472,6 +472,7 @@ + #define SHT_GNU_ATTRIBUTES 0x6ffffff5 /* Object attributes */ + #define SHT_GNU_HASH 0x6ffffff6 /* GNU style symbol hash table */ + #define SHT_GNU_LIBLIST 0x6ffffff7 /* List of prelink dependencies */ ++#define SHT_GNU_OBJECT_ONLY 0x6ffffff8 /* Object only */ + + /* The next three section types are defined by Solaris, and are named + SHT_SUNW*. We use them in GNU code, so we also define SHT_GNU* +diff -rup binutils-2.25.orig/ld/emultempl/alphaelf.em binutils-2.25/ld/emultempl/alphaelf.em +--- binutils-2.25.orig/ld/emultempl/alphaelf.em 2014-12-24 10:46:27.717434037 +0000 ++++ binutils-2.25/ld/emultempl/alphaelf.em 2014-12-24 10:47:07.172655604 +0000 +@@ -100,7 +100,7 @@ alpha_finish (void) + if (limit_32bit) + elf_elfheader (link_info.output_bfd)->e_flags |= EF_ALPHA_32BIT; + +- finish_default (); ++ gld${EMULATION_NAME}_finish (); + } + EOF + +diff -rup binutils-2.25.orig/ld/emultempl/armelf.em binutils-2.25/ld/emultempl/armelf.em +--- binutils-2.25.orig/ld/emultempl/armelf.em 2014-12-24 10:46:27.718434043 +0000 ++++ binutils-2.25/ld/emultempl/armelf.em 2014-12-24 10:47:07.172655604 +0000 +@@ -370,7 +370,7 @@ gld${EMULATION_NAME}_after_allocation (v + } + + static void +-gld${EMULATION_NAME}_finish (void) ++arm_finish (void) + { + struct bfd_link_hash_entry * h; + +@@ -393,7 +393,7 @@ gld${EMULATION_NAME}_finish (void) + } + } + +- finish_default (); ++ gld${EMULATION_NAME}_finish (); + + if (thumb_entry_symbol) + { +@@ -702,4 +702,4 @@ LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS= + LDEMUL_BEFORE_PARSE=gld"${EMULATION_NAME}"_before_parse + + # Call the extra arm-elf function +-LDEMUL_FINISH=gld${EMULATION_NAME}_finish ++LDEMUL_FINISH=arm_finish +Only in binutils-2.25/ld/emultempl: armelf.em.orig +diff -rup binutils-2.25.orig/ld/emultempl/elf32.em binutils-2.25/ld/emultempl/elf32.em +--- binutils-2.25.orig/ld/emultempl/elf32.em 2014-12-24 10:46:27.717434037 +0000 ++++ binutils-2.25/ld/emultempl/elf32.em 2014-12-24 10:47:07.174655615 +0000 +@@ -65,6 +65,7 @@ static void gld${EMULATION_NAME}_before_ + static void gld${EMULATION_NAME}_after_allocation (void); + static lang_output_section_statement_type *gld${EMULATION_NAME}_place_orphan + (asection *, const char *, int); ++static void gld${EMULATION_NAME}_finish (void); + EOF + + if [ "x${USE_LIBPATH}" = xyes ] ; then +@@ -1730,6 +1731,8 @@ output_rel_find (asection *sec, int isdy + return last; + } + ++static int orphan_init_done = 0; ++ + /* Place an orphan section. We use this to put random SHF_ALLOC + sections in the right segment. */ + +@@ -1738,7 +1741,7 @@ gld${EMULATION_NAME}_place_orphan (asect + const char *secname, + int constraint) + { +- static struct orphan_save hold[] = ++ static struct orphan_save orig_hold[] = + { + { ".text", + SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE, +@@ -1768,6 +1771,7 @@ gld${EMULATION_NAME}_place_orphan (asect + SEC_HAS_CONTENTS, + 0, 0, 0, 0 }, + }; ++ static struct orphan_save hold[ARRAY_SIZE (orig_hold)]; + enum orphan_save_index + { + orphan_text = 0, +@@ -1780,7 +1784,6 @@ gld${EMULATION_NAME}_place_orphan (asect + orphan_sdata, + orphan_nonalloc + }; +- static int orphan_init_done = 0; + struct orphan_save *place; + lang_output_section_statement_type *after; + lang_output_section_statement_type *os; +@@ -1857,15 +1860,22 @@ gld${EMULATION_NAME}_place_orphan (asect + + if (!orphan_init_done) + { +- struct orphan_save *ho; ++ struct orphan_save *ho, *horig; + + for (ho = hold; ho < hold + sizeof (hold) / sizeof (hold[0]); ++ho) ++ for (ho = hold, horig = orig_hold; ++ ho < hold + ARRAY_SIZE (hold); ++ ++ho, ++horig) ++ { ++ *ho = *horig; ++ if (ho->name != NULL) + if (ho->name != NULL) + { + ho->os = lang_output_section_find (ho->name); + if (ho->os != NULL && ho->os->flags == 0) + ho->os->flags = ho->flags; + } ++ } + orphan_init_done = 1; + } + +@@ -1937,6 +1947,27 @@ gld${EMULATION_NAME}_place_orphan (asect + EOF + fi + ++fragment <header.type = cmdline_is_bfd_enum; ++ new_opt->header.next = NULL; ++ new_opt->abfd.abfd = (bfd *) data; ++ ++ c = cmdline_object_only_archive_list.head; ++ if (c == NULL) ++ { ++ cmdline_object_only_archive_list.head = new_opt; ++ cmdline_object_only_archive_list.tail = &new_opt->header.next; ++ return; ++ } ++ ++ prev = NULL; ++ origin = abfd->origin; ++ for (; c != NULL; c = next) ++ { ++ if (c->header.type != cmdline_is_bfd_enum) ++ abort (); ++ ++ next = c->header.next; ++ ++ obfd = c->abfd.abfd; ++ oarchive = bfd_my_archive (obfd); ++ ++ if (strcmp (archive->filename, oarchive->filename) == 0) ++ { ++ bfd_boolean after; ++ ++ if (origin < obfd->origin) ++ { ++ /* Insert it before the current. */ ++ new_opt->header.next = c; ++ if (prev) ++ *prev = new_opt; ++ else ++ cmdline_object_only_archive_list.head = new_opt; ++ return; ++ } ++ ++ after = TRUE; ++ ++ /* Check origin. */ ++ while (next) ++ { ++ if (next->header.type != cmdline_is_bfd_enum) ++ abort (); ++ ++ nbfd = next->abfd.abfd; ++ norigin = nbfd->origin; ++ if (origin > norigin) ++ { ++ /* Insert it after NEXT. */ ++ break; ++ } ++ ++ narchive = bfd_my_archive (nbfd); ++ if (strcmp (archive->filename, narchive->filename) != 0) ++ { ++ /* Insert it befor NEXT. */ ++ after = FALSE; ++ break; ++ } ++ ++ c = next; ++ next = next->header.next; ++ } ++ ++ if (after && next) ++ { ++ c = next; ++ next = next->header.next; ++ } ++ ++ if (*cmdline_object_only_archive_list.tail == c->header.next) ++ cmdline_object_only_archive_list.tail ++ = &new_opt->header.next; ++ ++ prev = &c->header.next; ++ new_opt->header.next = next; ++ *prev = new_opt; ++ return; ++ } ++ ++ prev = &c->header.next; ++ } ++ ++ *cmdline_object_only_archive_list.tail = new_opt; ++ cmdline_object_only_archive_list.tail = &new_opt->header.next; ++} ++ ++ ++static void ++cmdline_get_object_only_input_files (void) ++{ ++ cmdline_union_type *c, *next; ++ bfd *abfd, *archive; ++ bfd *nbfd, *narchive; ++ ++ /* Add files first. */ ++ for (c = cmdline_object_only_file_list.head; ++ c != NULL; c = c->header.next) ++ switch (c->header.type) ++ { ++ default: ++ abort (); ++ case cmdline_is_file_enum: ++ lang_add_input_file (c->file.filename, ++ lang_input_file_is_file_enum, NULL); ++ break; ++ case cmdline_is_bfd_enum: ++ abfd = c->abfd.abfd; ++ if (bfd_my_archive (abfd)) ++ abort (); ++ lang_add_input_file (abfd->filename, ++ lang_input_file_is_file_enum, NULL); ++ break; ++ } ++ ++ /* Add archive members next. */ ++ for (c = cmdline_object_only_archive_list.head; c != NULL; c = next) ++ { ++ if (c->header.type != cmdline_is_bfd_enum) ++ abort (); ++ ++ next = c->header.next; ++ ++ abfd = c->abfd.abfd; ++ archive = bfd_my_archive (abfd); ++ ++ /* Add the first archive of the archive member group. */ ++ lang_add_input_file (archive->filename, ++ lang_input_file_is_file_enum, NULL); ++ ++ /* Skip the rest members in the archive member group. */ ++ do ++ { ++ if (!next) ++ break; ++ ++ if (next->header.type != cmdline_is_bfd_enum) ++ abort (); ++ ++ next = next->header.next; ++ if (!next) ++ break; ++ nbfd = next->abfd.abfd; ++ narchive = bfd_my_archive (nbfd); ++ } ++ while (strcmp (archive->filename, narchive->filename) == 0); ++ } ++} ++ ++struct cmdline_arg ++{ ++ bfd *obfd; ++ asymbol **isympp; ++ int status; ++}; ++ ++/* Create a section in OBFD with the same ++ name and attributes as ISECTION in IBFD. */ ++ ++static void ++setup_section (bfd *ibfd, sec_ptr isection, void *p) ++{ ++ struct cmdline_arg *arg = (struct cmdline_arg *) p; ++ bfd *obfd = arg->obfd; ++ asymbol **isympp = arg->isympp; ++ const char *name = isection->name; ++ sec_ptr osection; ++ const char *err; ++ ++ /* Skip the object-only section. */ ++ if (ibfd->object_only_section == isection) ++ return; ++ ++ /* If we have already failed earlier on, do not keep on generating ++ complaints now. */ ++ if (arg->status) ++ return; ++ ++ osection = bfd_make_section_anyway_with_flags (obfd, name, ++ isection->flags); ++ ++ if (osection == NULL) ++ { ++ err = _("failed to create output section"); ++ goto loser; ++ } ++ ++ osection->size = isection->size; ++ osection->vma = isection->vma; ++ osection->lma = isection->lma; ++ osection->alignment_power = isection->alignment_power; ++ ++ /* Copy merge entity size. */ ++ osection->entsize = isection->entsize; ++ ++ /* This used to be mangle_section; we do here to avoid using ++ bfd_get_section_by_name since some formats allow multiple ++ sections with the same name. */ ++ isection->output_section = osection; ++ isection->output_offset = 0; ++ ++ if ((isection->flags & SEC_GROUP) != 0) ++ { ++ asymbol *gsym = bfd_group_signature (isection, isympp); ++ ++ if (gsym != NULL) ++ { ++ gsym->flags |= BSF_KEEP; ++ if (ibfd->xvec->flavour == bfd_target_elf_flavour) ++ elf_group_id (isection) = gsym; ++ } ++ } ++ ++ /* Allow the BFD backend to copy any private data it understands ++ from the input section to the output section. */ ++ if (!bfd_copy_private_section_data (ibfd, isection, obfd, osection)) ++ { ++ err = _("failed to copy private data"); ++ goto loser; ++ } ++ ++ /* All went well. */ ++ return; ++ ++loser: ++ arg->status = 1; ++ einfo (_("%P%F: setup_section: %s: %s\n"), err, name); ++} ++ ++/* Copy the data of input section ISECTION of IBFD ++ to an output section with the same name in OBFD. ++ If stripping then don't copy any relocation info. */ ++ ++static void ++copy_section (bfd *ibfd, sec_ptr isection, void *p) ++{ ++ struct cmdline_arg *arg = (struct cmdline_arg *) p; ++ bfd *obfd = arg->obfd; ++ asymbol **isympp = arg->isympp; ++ arelent **relpp; ++ long relcount; ++ sec_ptr osection; ++ bfd_size_type size; ++ long relsize; ++ flagword flags; ++ const char *err; ++ ++ /* Skip the object-only section. */ ++ if (ibfd->object_only_section == isection) ++ return; ++ ++ /* If we have already failed earlier on, do not keep on generating ++ complaints now. */ ++ if (arg->status) ++ return; ++ ++ flags = bfd_get_section_flags (ibfd, isection); ++ if ((flags & SEC_GROUP) != 0) ++ return; ++ ++ osection = isection->output_section; ++ size = bfd_get_section_size (isection); ++ ++ if (size == 0 || osection == 0) ++ return; ++ ++ relsize = bfd_get_reloc_upper_bound (ibfd, isection); ++ ++ if (relsize < 0) ++ { ++ /* Do not complain if the target does not support relocations. */ ++ if (relsize == -1 ++ && bfd_get_error () == bfd_error_invalid_operation) ++ relsize = 0; ++ else ++ { ++ err = bfd_errmsg (bfd_get_error ()); ++ goto loser; ++ } ++ } ++ ++ if (relsize == 0) ++ bfd_set_reloc (obfd, osection, NULL, 0); ++ else ++ { ++ relpp = (arelent **) xmalloc (relsize); ++ relcount = bfd_canonicalize_reloc (ibfd, isection, relpp, isympp); ++ if (relcount < 0) ++ { ++ err = _("relocation count is negative"); ++ goto loser; ++ } ++ ++ bfd_set_reloc (obfd, osection, ++ relcount == 0 ? NULL : relpp, relcount); ++ if (relcount == 0) ++ free (relpp); ++ } ++ ++ if (bfd_get_section_flags (ibfd, isection) & SEC_HAS_CONTENTS) ++ { ++ bfd_byte *memhunk = NULL; ++ ++ if (!bfd_get_full_section_contents (ibfd, isection, &memhunk)) ++ { ++ err = bfd_errmsg (bfd_get_error ()); ++ goto loser; ++ } ++ ++ if (!bfd_set_section_contents (obfd, osection, memhunk, 0, size)) ++ { ++ err = bfd_errmsg (bfd_get_error ()); ++ goto loser; ++ } ++ free (memhunk); ++ } ++ ++ /* All went well. */ ++ return; ++ ++loser: ++ einfo (_("%P%F: copy_section: %s: %s\n"), err, isection->name); ++} ++/* Open the temporary bfd created in the same directory as PATH. */ ++ ++static bfd * ++cmdline_fopen_temp (const char *path, const char *target, ++ const char *mode) ++{ ++#define template "ldXXXXXX" ++ const char *slash = strrchr (path, '/'); ++ char *tmpname; ++ size_t len; ++ int fd; ++ ++#ifdef HAVE_DOS_BASED_FILE_SYSTEM ++ { ++ /* We could have foo/bar\\baz, or foo\\bar, or d:bar. */ ++ char *bslash = strrchr (path, '\\'); ++ ++ if (slash == NULL || (bslash != NULL && bslash > slash)) ++ slash = bslash; ++ if (slash == NULL && path[0] != '\0' && path[1] == ':') ++ slash = path + 1; ++ } ++#endif ++ ++ if (slash != (char *) NULL) ++ { ++ len = slash - path; ++ tmpname = (char *) xmalloc (len + sizeof (template) + 2); ++ memcpy (tmpname, path, len); ++ ++#ifdef HAVE_DOS_BASED_FILE_SYSTEM ++ /* If tmpname is "X:", appending a slash will make it a root ++ directory on drive X, which is NOT the same as the current ++ directory on drive X. */ ++ if (len == 2 && tmpname[1] == ':') ++ tmpname[len++] = '.'; ++#endif ++ tmpname[len++] = '/'; ++ } ++ else ++ { ++ tmpname = (char *) xmalloc (sizeof (template)); ++ len = 0; ++ } ++ ++ memcpy (tmpname + len, template, sizeof (template)); ++#undef template ++ ++#ifdef HAVE_MKSTEMP ++ fd = mkstemp (tmpname); ++#else ++ tmpname = mktemp (tmpname); ++ if (tmpname == NULL) ++ return NULL; ++ fd = open (tmpname, O_RDWR | O_CREAT | O_EXCL, 0600); ++#endif ++ if (fd == -1) ++ return NULL; ++ return bfd_fopen (tmpname, target, mode, fd); ++} ++ ++/* Add the object-only section. */ ++ ++static void ++cmdline_add_object_only_section (bfd_byte *contents, size_t size) ++{ ++ bfd_vma start; ++ flagword flags; ++ enum bfd_architecture iarch; ++ unsigned int imach; ++ long symcount; ++ long symsize; ++ asymbol **isympp = NULL; ++ asymbol **osympp = NULL; ++ bfd *obfd = NULL, *ibfd; ++ const char *err; ++ struct arg ++ { ++ bfd *obfd; ++ asymbol **isympp; ++ int status; ++ } arg; ++ char **matching; ++ const char *ofilename = NULL; ++ asection *sec; ++ ++ ibfd = bfd_openr (output_filename, output_target); ++ if (!ibfd) ++ { ++ err = bfd_errmsg (bfd_get_error ()); ++ goto loser; ++ } ++ ++ if (!bfd_check_format_matches (ibfd, bfd_object, &matching)) ++ { ++ err = bfd_errmsg (bfd_get_error ()); ++ goto loser; ++ } ++ ++ obfd = cmdline_fopen_temp (output_filename, output_target, "w"); ++ if (!obfd) ++ { ++ err = bfd_errmsg (bfd_get_error ()); ++ goto loser; ++ } ++ ofilename = bfd_get_filename (obfd); ++ ++ if (!bfd_set_format (obfd, bfd_object)) ++ { ++ err = bfd_errmsg (bfd_get_error ()); ++ goto loser; ++ } ++ ++ /* Copy the start address, flags and architecture of input file to ++ output file. */ ++ flags = bfd_get_file_flags (ibfd); ++ start = bfd_get_start_address (ibfd); ++ iarch = bfd_get_arch (ibfd); ++ imach = bfd_get_mach (ibfd); ++ if (!bfd_set_start_address (obfd, start) ++ || !bfd_set_file_flags (obfd, flags) ++ || !bfd_set_arch_mach (obfd, iarch, imach)) ++ { ++ err = bfd_errmsg (bfd_get_error ()); ++ goto loser; ++ } ++ ++ symsize = bfd_get_symtab_upper_bound (ibfd); ++ if (symsize < 0) ++ { ++ err = bfd_errmsg (bfd_get_error ()); ++ goto loser; ++ } ++ ++ isympp = (asymbol **) xmalloc (symsize); ++ symcount = bfd_canonicalize_symtab (ibfd, isympp); ++ if (symcount < 0) ++ { ++ err = bfd_errmsg (bfd_get_error ()); ++ goto loser; ++ } ++ ++ arg.obfd = obfd; ++ arg.isympp = isympp; ++ arg.status = 0; ++ ++ /* BFD mandates that all output sections be created and sizes set before ++ any output is done. Thus, we traverse all sections multiple times. */ ++ bfd_map_over_sections (ibfd, setup_section, &arg); ++ ++ if (arg.status) ++ { ++ err = _("error setting up sections"); ++ goto loser; ++ } ++ ++ /* Allow the BFD backend to copy any private data it understands ++ from the input section to the output section. */ ++ if (! bfd_copy_private_header_data (ibfd, obfd)) ++ { ++ err = _("error copying private header data"); ++ goto loser; ++ } ++ ++ /* Create the object-only section. */ ++ sec = bfd_make_section_with_flags (obfd, ++ GNU_OBJECT_ONLY_SECTION_NAME, ++ (SEC_HAS_CONTENTS ++ | SEC_READONLY ++ | SEC_DATA ++ | SEC_LINKER_CREATED)); ++ if (sec == NULL) ++ { ++ err = _("can't create object-only section"); ++ goto loser; ++ } ++ ++ if (! bfd_set_section_size (obfd, sec, size)) ++ { ++ err = _("can't set object-only section size"); ++ goto loser; ++ } ++ ++ if (ibfd->object_only_section) ++ { ++ /* Filter out the object-only section symbol. */ ++ long src_count = 0, dst_count = 0; ++ asymbol **from, **to; ++ ++ osympp = (asymbol **) xmalloc (symcount * sizeof (asymbol *)); ++ from = isympp; ++ to = osympp; ++ for (; src_count < symcount; src_count++) ++ { ++ asymbol *sym = from[src_count]; ++ if (bfd_get_section (sym) != ibfd->object_only_section) ++ to[dst_count++] = sym; ++ } ++ to[dst_count] = NULL; ++ symcount = dst_count; ++ bfd_set_symtab (obfd, osympp, symcount); ++ } ++ else ++ bfd_set_symtab (obfd, isympp, symcount); ++ ++ /* This has to happen after the symbol table has been set. */ ++ bfd_map_over_sections (ibfd, copy_section, &arg); ++ ++ if (arg.status) ++ { ++ err = _("error copying sections"); ++ goto loser; ++ } ++ ++ /* Copy the object-only section to the output. */ ++ if (! bfd_set_section_contents (obfd, sec, contents, 0, size)) ++ { ++ err = _("error adding object-only section"); ++ goto loser; ++ } ++ ++ /* Allow the BFD backend to copy any private data it understands ++ from the input BFD to the output BFD. This is done last to ++ permit the routine to look at the filtered symbol table, which is ++ important for the ECOFF code at least. */ ++ if (! bfd_copy_private_bfd_data (ibfd, obfd)) ++ { ++ err = _("error copying private BFD data"); ++ goto loser; ++ } ++ ++ if (!bfd_close (obfd)) ++ { ++ unlink (ofilename); ++ einfo (_("%P%F: failed to finish output with object-only section\n")); ++ } ++ ++ /* Must be freed after bfd_close (). */ ++ free (isympp); ++ if (osympp) ++ free (osympp); ++ ++ if (rename (ofilename, output_filename)) ++ { ++ unlink (ofilename); ++ einfo (_("%P%F: failed to rename output with object-only section\n")); ++ } ++ ++ return; ++ ++loser: ++ if (isympp) ++ free (isympp); ++ if (osympp) ++ free (osympp); ++ if (obfd) ++ bfd_close (obfd); ++ if (ofilename) ++ unlink (ofilename); ++ einfo (_("%P%F: failed to add object-only section: %s\n"), err); ++} ++ ++/* Emit the final output with object-only section. */ ++ ++void ++cmdline_emit_object_only_section (void) ++{ ++ const char *saved_output_filename = output_filename; ++ int fd; ++ size_t size, off; ++ bfd_byte *contents; ++ struct stat st; ++ ++ /* Get a temporary object-only file. */ ++ output_filename = make_temp_file (".obj-only.o"); ++ ++ had_output_filename = FALSE; ++ link_info.input_bfds = NULL; ++ link_info.input_bfds_tail = &link_info.input_bfds; ++ ++ lang_init (TRUE); ++ ++ ld_parse_linker_script (); ++ ++ /* Set up the object-only output. */ ++ lang_final (); ++ ++ /* Open the object-only file for output. */ ++ lang_for_each_statement (ldlang_open_output); ++ ++ ldemul_create_output_section_statements (); ++ ++ if (!bfd_section_already_linked_table_init ()) ++ einfo (_("%P%F: Failed to create hash table\n")); ++ ++ /* Call cmdline_on_object_only_archive_list_p to check which member ++ should be loaded. */ ++ input_flags.whole_archive = TRUE; ++ ++ /* Set it to avoid adding more to cmdline lists. */ ++ link_info.emitting_gnu_object_only = TRUE; ++ ++ cmdline_get_object_only_input_files (); ++ ++ open_input_bfds (statement_list.head, FALSE); ++ ++ ldemul_after_open (); ++ ++ bfd_section_already_linked_table_free (); ++ ++ /* Make sure that we're not mixing architectures. We call this ++ after all the input files have been opened, but before we do any ++ other processing, so that any operations merge_private_bfd_data ++ does on the output file will be known during the rest of the ++ link. */ ++ lang_check (); ++ ++ /* Size up the common data. */ ++ lang_common (); ++ ++ /* Update wild statements. */ ++ update_wild_statements (statement_list.head); ++ ++ /* Run through the contours of the script and attach input sections ++ to the correct output sections. */ ++ map_input_to_output_sections (statement_list.head, NULL, NULL); ++ ++ /* Find any sections not attached explicitly and handle them. */ ++ lang_place_orphans (); ++ ++ /* Do anything special before sizing sections. This is where ELF ++ and other back-ends size dynamic sections. */ ++ ldemul_before_allocation (); ++ ++ /* Size up the sections. */ ++ lang_size_sections (NULL, ! RELAXATION_ENABLED); ++ ++ /* See if anything special should be done now we know how big ++ everything is. This is where relaxation is done. */ ++ ldemul_after_allocation (); ++ ++ ldemul_finish (); ++ ++ /* Make sure that the section addresses make sense. */ ++ if (command_line.check_section_addresses) ++ lang_check_section_addresses (); ++ ++ lang_end (); ++ ++ ldwrite (); ++ ++ lang_finish (); ++ ++ if (! bfd_close (link_info.output_bfd)) ++ einfo (_("%P%F:%s: final close failed on object-only output: %E\n"), ++ output_filename); ++ ++ /* Read in the object-only file. */ ++ fd = open (output_filename, O_RDONLY | O_BINARY); ++ if (fd < 0) ++ { ++ bfd_set_error (bfd_error_system_call); ++ einfo (_("%P%F:%s: cannot open object-only output: %E"), ++ output_filename); ++ } ++ ++ /* Get the object-only file size. */ ++ if (fstat (fd, &st) != 0) ++ { ++ bfd_set_error (bfd_error_system_call); ++ einfo (_("%P%F:%s: cannot stat object-only output: %E"), ++ output_filename); ++ } ++ ++ size = st.st_size; ++ off = 0; ++ contents = (bfd_byte *) xmalloc (size); ++ while (off != size) ++ { ++ ssize_t got; ++ ++ got = read (fd, contents + off, size - off); ++ if (got < 0) ++ { ++ bfd_set_error (bfd_error_system_call); ++ einfo (_("%P%F:%s: read failed on object-only output: %E"), ++ output_filename); ++ } ++ ++ off += got; ++ } ++ ++ close (fd); ++ ++ /* Remove the temporary object-only file. */ ++ unlink (output_filename); ++ ++ output_filename = saved_output_filename; ++ ++ cmdline_add_object_only_section (contents, size); ++ ++ free (contents); ++} ++ ++/* Extract the object-only section. */ ++ ++static const char * ++cmdline_extract_object_only_section (bfd *abfd) ++{ ++ const char *name = bfd_extract_object_only_section (abfd); ++ ++ if (name == NULL) ++ einfo (_("%P%F: cannot extract object-only section from %B: %E"), ++ abfd); ++ ++ /* It should be removed after it is done. */ ++ cmdline_list_append (&cmdline_temp_object_only_list, ++ cmdline_is_file_enum, (void *) name); ++ ++ return name; ++} ++ ++/* Check and handle the object-only section. */ ++ ++void ++cmdline_check_object_only_section (bfd *abfd, bfd_boolean lto) ++{ ++ const char *filename; ++ ++ if (link_info.emitting_gnu_object_only ++ || abfd->format != bfd_object) ++ return; ++ ++ if (lto) ++ { ++ /* For LTO link, we only need to extract object-only section ++ from the mixed object, add it to input, and put it on LTO ++ claimed output. */ ++ switch (abfd->lto_type) ++ { ++ default: ++ abort (); ++ case lto_mixed_object: ++ filename = cmdline_extract_object_only_section (abfd); ++ lang_add_input_file (filename, ++ lang_input_file_is_file_enum, NULL); ++ break; ++ case lto_non_ir_object: ++ case lto_ir_object: ++ break; ++ } ++ } ++ else if (link_info.relocatable) ++ { ++ /* For non-LTO relocatable link, we need to append non-IR object ++ file and the object file in object-only section to the object ++ only list. */ ++ switch (abfd->lto_type) ++ { ++ default: ++ abort (); ++ case lto_mixed_object: ++ filename = cmdline_extract_object_only_section (abfd); ++ cmdline_object_only_list_append (cmdline_is_file_enum, ++ (void *) filename); ++ break; ++ case lto_non_ir_object: ++ cmdline_object_only_list_append (cmdline_is_bfd_enum, abfd); ++ break; ++ case lto_ir_object: ++ break; ++ } ++ } ++} ++ ++/* Remove temporary object-only files. */ ++ ++void ++cmdline_remove_object_only_files (void) ++{ ++ cmdline_union_type *c; ++ ++#ifdef ENABLE_PLUGINS ++ if (plugin_save_temps) ++ return; ++#endif ++ ++ c = cmdline_temp_object_only_list.head; ++ for (; c != NULL; c = c->header.next) ++ switch (c->header.type) ++ { ++ default: ++ abort (); ++ case cmdline_is_file_enum: ++ unlink (c->file.filename); ++ break; ++ } ++} ++ ++ ++ +Only in binutils-2.25/ld: ldlang.c.orig +Only in binutils-2.25/ld: ldlang.c.rej +diff -rup binutils-2.25.orig/ld/ldlang.h binutils-2.25/ld/ldlang.h +--- binutils-2.25.orig/ld/ldlang.h 2014-12-24 10:46:27.718434043 +0000 ++++ binutils-2.25/ld/ldlang.h 2014-12-24 10:47:07.181655654 +0000 +@@ -523,7 +523,7 @@ extern struct asneeded_minfo **asneeded_ + extern void (*output_bfd_hash_table_free_fn) (struct bfd_link_hash_table *); + + extern void lang_init +- (void); ++ (bfd_boolean); + extern void lang_finish + (void); + extern lang_memory_region_type * lang_memory_region_lookup +@@ -698,4 +698,45 @@ ldlang_override_segment_assignment + extern void + lang_ld_feature (char *); + ++typedef enum ++{ ++ cmdline_is_file_enum, ++ cmdline_is_bfd_enum ++} cmdline_enum_type; ++ ++typedef struct cmdline_header_struct ++{ ++ union cmdline_union *next; ++ cmdline_enum_type type; ++} cmdline_header_type; ++ ++typedef struct cmdline_file_struct ++{ ++ cmdline_header_type header; ++ const char *filename; ++} cmdline_file_type; ++ ++typedef struct cmdline_bfd_struct ++{ ++ cmdline_header_type header; ++ bfd *abfd; ++} cmdline_bfd_type; ++ ++typedef union cmdline_union ++{ ++ cmdline_header_type header; ++ cmdline_file_type file; ++ cmdline_bfd_type abfd; ++} cmdline_union_type; ++ ++typedef struct cmdline_list ++{ ++ cmdline_union_type *head; ++ cmdline_union_type **tail; ++} cmdline_list_type; ++ ++extern void cmdline_emit_object_only_section (void); ++extern void cmdline_check_object_only_section (bfd *, bfd_boolean); ++extern void cmdline_remove_object_only_files (void); ++ + #endif +Only in binutils-2.25/ld: ldlang.h.orig +diff -rup binutils-2.25.orig/ld/ldlex.h binutils-2.25/ld/ldlex.h +--- binutils-2.25.orig/ld/ldlex.h 2014-12-24 10:46:27.720434054 +0000 ++++ binutils-2.25/ld/ldlex.h 2014-12-24 10:47:07.181655654 +0000 +@@ -133,6 +133,7 @@ enum option_values + #ifdef ENABLE_PLUGINS + OPTION_PLUGIN, + OPTION_PLUGIN_OPT, ++ OPTION_PLUGIN_SAVE_TEMPS, + #endif /* ENABLE_PLUGINS */ + OPTION_DEFAULT_SCRIPT, + OPTION_PRINT_OUTPUT_FORMAT, +diff -rup binutils-2.25.orig/ld/ldmain.c binutils-2.25/ld/ldmain.c +--- binutils-2.25.orig/ld/ldmain.c 2014-12-24 10:46:27.715434026 +0000 ++++ binutils-2.25/ld/ldmain.c 2014-12-24 11:02:55.443006018 +0000 +@@ -220,6 +220,9 @@ main (int argc, char **argv) + + xatexit (ld_cleanup); + ++ /* Remove temporary object-only files. */ ++ xatexit (cmdline_remove_object_only_files); ++ + /* Set up the sysroot directory. */ + ld_sysroot = get_sysroot (argc, argv); + if (*ld_sysroot) +@@ -296,7 +299,7 @@ main (int argc, char **argv) + default_target = ldemul_choose_target (argc, argv); + config.maxpagesize = bfd_emul_get_maxpagesize (default_target); + config.commonpagesize = bfd_emul_get_commonpagesize (default_target); +- lang_init (); ++ lang_init (FALSE); + ldemul_before_parse (); + lang_has_input_file = FALSE; + parse_args (argc, argv); +@@ -311,34 +314,7 @@ main (int argc, char **argv) + + ldemul_set_symbols (); + +- /* If we have not already opened and parsed a linker script, +- try the default script from command line first. */ +- if (saved_script_handle == NULL +- && command_line.default_script != NULL) +- { +- ldfile_open_command_file (command_line.default_script); +- parser_input = input_script; +- yyparse (); +- } +- +- /* If we have not already opened and parsed a linker script +- read the emulation's appropriate default script. */ +- if (saved_script_handle == NULL) +- { +- int isfile; +- char *s = ldemul_get_script (&isfile); +- +- if (isfile) +- ldfile_open_default_command_file (s); +- else +- { +- lex_string = s; +- lex_redirect (s, _("built in linker script"), 1); +- } +- parser_input = input_script; +- yyparse (); +- lex_string = NULL; +- } ++ ld_parse_linker_script (); + + if (verbose) + { +@@ -459,6 +435,8 @@ main (int argc, char **argv) + if (! bfd_close (link_info.output_bfd)) + einfo (_("%F%B: final close failed: %E\n"), link_info.output_bfd); + ++ link_info.output_bfd = NULL; ++ + /* If the --force-exe-suffix is enabled, and we're making an + executable file and it doesn't end in .exe, copy it to one + which does. */ +@@ -505,6 +483,9 @@ main (int argc, char **argv) + } + } + ++ if (link_info.emit_gnu_object_only) ++ cmdline_emit_object_only_section (); ++ + END_PROGRESS (program_name); + + if (config.stats) +@@ -814,7 +795,9 @@ add_archive_element (struct bfd_link_inf + } + } + } ++ else + #endif /* ENABLE_PLUGINS */ ++ cmdline_check_object_only_section (input->the_bfd, FALSE); + + ldlang_add_file (input); + +@@ -1207,7 +1190,8 @@ warning_callback (struct bfd_link_info * + einfo ("%P: %s%s\n", _("warning: "), warning); + else if (symbol == NULL) + einfo ("%B: %s%s\n", abfd, _("warning: "), warning); +- else if (! symbol_warning (warning, symbol, abfd)) ++ else if (((abfd->flags & BFD_PLUGIN) == 0) ++ && ! symbol_warning (warning, symbol, abfd)) + { + bfd *b; + /* Search all input files for a reference to SYMBOL. */ +@@ -1493,3 +1477,38 @@ notice (struct bfd_link_info *info, + + return TRUE; + } ++ ++/* Parse the linker script. */ ++ ++void ++ld_parse_linker_script () ++{ ++ /* If we have not already opened and parsed a linker script, ++ try the default script from command line first. */ ++ if (saved_script_handle == NULL ++ && command_line.default_script != NULL) ++ { ++ ldfile_open_command_file (command_line.default_script); ++ parser_input = input_script; ++ yyparse (); ++ } ++ ++ /* If we have not already opened and parsed a linker script ++ read the emulation's appropriate default script. */ ++ if (saved_script_handle == NULL) ++ { ++ int isfile; ++ char *s = ldemul_get_script (&isfile); ++ ++ if (isfile) ++ ldfile_open_default_command_file (s); ++ else ++ { ++ lex_string = s; ++ lex_redirect (s, _("built in linker script"), 1); ++ } ++ parser_input = input_script; ++ yyparse (); ++ lex_string = NULL; ++ } ++} +Only in binutils-2.25/ld: ldmain.c.orig +Only in binutils-2.25/ld: ldmain.c.rej +diff -rup binutils-2.25.orig/ld/ldmain.h binutils-2.25/ld/ldmain.h +--- binutils-2.25.orig/ld/ldmain.h 2014-12-24 10:46:27.715434026 +0000 ++++ binutils-2.25/ld/ldmain.h 2014-12-24 10:47:07.183655665 +0000 +@@ -59,4 +59,6 @@ extern void add_wrap (const char *); + extern void add_ignoresym (struct bfd_link_info *, const char *); + extern void add_keepsyms_file (const char *); + ++extern void ld_parse_linker_script (void); ++ + #endif +Only in binutils-2.25/ld: ldmain.h.orig +diff -rup binutils-2.25.orig/ld/lexsup.c binutils-2.25/ld/lexsup.c +--- binutils-2.25.orig/ld/lexsup.c 2014-12-24 10:46:27.870434896 +0000 ++++ binutils-2.25/ld/lexsup.c 2014-12-24 10:47:07.184655671 +0000 +@@ -166,6 +166,9 @@ static const struct ld_option ld_options + '\0', N_("PLUGIN"), N_("Load named plugin"), ONE_DASH }, + { {"plugin-opt", required_argument, NULL, OPTION_PLUGIN_OPT}, + '\0', N_("ARG"), N_("Send arg to last-loaded plugin"), ONE_DASH }, ++ { {"plugin-save-temps", no_argument, NULL, OPTION_PLUGIN_SAVE_TEMPS}, ++ '\0', NULL, N_("Store plugin intermediate files permanently"), ++ ONE_DASH }, + { {"flto", optional_argument, NULL, OPTION_IGNORE}, + '\0', NULL, N_("Ignored for GCC LTO option compatibility"), + ONE_DASH }, +@@ -978,6 +981,9 @@ parse_args (unsigned argc, char **argv) + if (plugin_opt_plugin_arg (optarg)) + einfo(_("%P%F: bad -plugin-opt option\n")); + break; ++ case OPTION_PLUGIN_SAVE_TEMPS: ++ plugin_save_temps = TRUE; ++ break; + #endif /* ENABLE_PLUGINS */ + case 'q': + link_info.emitrelocations = TRUE; +Only in binutils-2.25/ld: lexsup.c.orig +diff -rup binutils-2.25.orig/ld/plugin.c binutils-2.25/ld/plugin.c +--- binutils-2.25.orig/ld/plugin.c 2014-12-24 10:46:27.719434048 +0000 ++++ binutils-2.25/ld/plugin.c 2014-12-24 10:47:07.185655677 +0000 +@@ -39,6 +39,9 @@ + /* Report plugin symbols. */ + bfd_boolean report_plugin_symbols; + ++/* Store plugin intermediate files permanently. */ ++bfd_boolean plugin_save_temps; ++ + /* The suffix to append to the name of the real (claimed) object file + when generating a dummy BFD to hold the IR symbols sent from the + plugin. For cosmetic use only; appears in maps, crefs etc. */ +@@ -229,6 +232,17 @@ plugin_opt_plugin_arg (const char *arg) + return 0; + } + ++ /* Ignore -pass-through= from GCC driver. */ ++ if (*arg == '-') ++ { ++ const char *p; ++ for (p = arg + 1; p; p++) ++ if (*p != '-') ++ break; ++ if (strncmp (p, "pass-through=", 13) == 0) ++ return 0; ++ } ++ + newarg = xmalloc (sizeof *newarg); + newarg->arg = arg; + newarg->next = NULL; +@@ -882,6 +896,9 @@ plugin_maybe_claim (struct ld_plugin_inp + close (file->fd); + if (claimed) + { ++ /* Check object only section. */ ++ cmdline_check_object_only_section (entry->the_bfd, TRUE); ++ + /* Discard the real file's BFD and substitute the dummy one. */ + + /* BFD archive handling caches elements so we can't call +@@ -935,14 +952,17 @@ plugin_call_cleanup (void) + { + if (curplug->cleanup_handler && !curplug->cleanup_done) + { +- enum ld_plugin_status rv; +- curplug->cleanup_done = TRUE; +- called_plugin = curplug; +- rv = (*curplug->cleanup_handler) (); +- called_plugin = NULL; +- if (rv != LDPS_OK) +- info_msg (_("%P: %s: error in plugin cleanup: %d (ignored)\n"), +- curplug->name, rv); ++ if (!plugin_save_temps) ++ { ++ enum ld_plugin_status rv; ++ curplug->cleanup_done = TRUE; ++ called_plugin = curplug; ++ rv = (*curplug->cleanup_handler) (); ++ called_plugin = NULL; ++ if (rv != LDPS_OK) ++ info_msg (_("%P: %s: error in plugin cleanup: %d (ignored)\n"), ++ curplug->name, rv); ++ } + dlclose (curplug->dlhandle); + } + curplug = curplug->next; +Only in binutils-2.25/ld: plugin.c.orig +diff -rup binutils-2.25.orig/ld/plugin.h binutils-2.25/ld/plugin.h +--- binutils-2.25.orig/ld/plugin.h 2014-12-24 10:46:27.718434043 +0000 ++++ binutils-2.25/ld/plugin.h 2014-12-24 10:47:07.185655677 +0000 +@@ -24,6 +24,9 @@ + /* Report plugin symbols. */ + extern bfd_boolean report_plugin_symbols; + ++/* Store plugin intermediate files permanently. */ ++extern bfd_boolean plugin_save_temps; ++ + /* Set at all symbols read time, to avoid recursively offering the plugin + its own newly-added input files and libs to claim. */ + extern bfd_boolean no_more_claiming; +diff -rup binutils-2.25.orig/ld/scripttempl/armbpabi.sc binutils-2.25/ld/scripttempl/armbpabi.sc +--- binutils-2.25.orig/ld/scripttempl/armbpabi.sc 2014-12-24 10:46:27.709433992 +0000 ++++ binutils-2.25/ld/scripttempl/armbpabi.sc 2014-12-24 10:47:07.400656884 +0000 +@@ -36,7 +36,7 @@ INTERP=".interp 0 : { *(.interp) } + PLT=".plt ${RELOCATING-0} : { *(.plt) }" + RODATA=".rodata ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }" + DATARELRO=".data.rel.ro : { *(.data.rel.ro.local) *(.data.rel.ro .data.rel.ro.*) }" +-DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }" ++DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) *(.gnu_object_only) }" + if test -z "${NO_SMALL_DATA}"; then + SBSS=".sbss ${RELOCATING-0} : + { +Only in binutils-2.25/ld/scripttempl: armbpabi.sc.orig +diff -rup binutils-2.25.orig/ld/scripttempl/elf32sh-symbian.sc binutils-2.25/ld/scripttempl/elf32sh-symbian.sc +--- binutils-2.25.orig/ld/scripttempl/elf32sh-symbian.sc 2014-12-24 10:46:27.709433992 +0000 ++++ binutils-2.25/ld/scripttempl/elf32sh-symbian.sc 2014-12-24 10:47:07.401656890 +0000 +@@ -88,7 +88,7 @@ fi + PLT=".plt : { *(.plt) } :dynamic :dyn" + DYNAMIC=".dynamic : { *(.dynamic) } :dynamic :dyn" + RODATA=".rodata ALIGN(4) : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }" +-DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.directive) *(.gnu.lto_*) }" ++DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.directive) *(.gnu.lto_*) *(.gnu_object_only) }" + test -z "$GOT" && GOT=".got ${RELOCATING-0} : { *(.got.plt) *(.got) } :dynamic :dyn" + INIT_ARRAY=".init_array ${RELOCATING-0} : + { +Only in binutils-2.25/ld/scripttempl: elf32sh-symbian.sc.orig +diff -rup binutils-2.25.orig/ld/scripttempl/elf64hppa.sc binutils-2.25/ld/scripttempl/elf64hppa.sc +--- binutils-2.25.orig/ld/scripttempl/elf64hppa.sc 2014-12-24 10:46:27.711434003 +0000 ++++ binutils-2.25/ld/scripttempl/elf64hppa.sc 2014-12-24 10:47:07.401656890 +0000 +@@ -132,7 +132,7 @@ fi + DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }" + RODATA=".rodata ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .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_*) *(.gnu_object_only) }" + if test -z "${NO_SMALL_DATA}"; then + SBSS=".sbss ${RELOCATING-0} : + { +Only in binutils-2.25/ld/scripttempl: elf64hppa.sc.orig +diff -rup binutils-2.25.orig/ld/scripttempl/elf.sc binutils-2.25/ld/scripttempl/elf.sc +--- binutils-2.25.orig/ld/scripttempl/elf.sc 2014-12-24 10:46:27.709433992 +0000 ++++ binutils-2.25/ld/scripttempl/elf.sc 2014-12-24 10:47:07.402656895 +0000 +@@ -165,7 +165,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_*) *(.gnu_object_only) }" + if test -z "${NO_SMALL_DATA}"; then + SBSS=".${SBSS_NAME} ${RELOCATING-0} : + { +Only in binutils-2.25/ld/scripttempl: elf.sc.orig +diff -rup binutils-2.25.orig/ld/scripttempl/elfxtensa.sc binutils-2.25/ld/scripttempl/elfxtensa.sc +--- binutils-2.25.orig/ld/scripttempl/elfxtensa.sc 2014-12-24 10:46:27.710433998 +0000 ++++ binutils-2.25/ld/scripttempl/elfxtensa.sc 2014-12-24 10:47:07.402656895 +0000 +@@ -145,7 +145,7 @@ fi + DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }" + RODATA=".rodata ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .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_*) *(.gnu_object_only) }" + INIT_LIT=".init.literal 0 : { *(.init.literal) }" + INIT=".init 0 : { *(.init) }" + FINI_LIT=".fini.literal 0 : { *(.fini.literal) }" +Only in binutils-2.25/ld/scripttempl: elfxtensa.sc.orig +diff -rup binutils-2.25.orig/ld/scripttempl/mep.sc binutils-2.25/ld/scripttempl/mep.sc +--- binutils-2.25.orig/ld/scripttempl/mep.sc 2014-12-24 10:46:27.711434003 +0000 ++++ binutils-2.25/ld/scripttempl/mep.sc 2014-12-24 10:47:07.403656901 +0000 +@@ -119,7 +119,7 @@ fi + DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }" + RODATA=".rodata ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }" + DATARELRO=".data.rel.ro : { *(.data.rel.ro.local) *(.data.rel.ro .data.rel.ro.*) }" +-DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }" ++DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) *(.gnu_object_only) }" + if test -z "${NO_SMALL_DATA}"; then + SBSS=".sbss ${RELOCATING-0} : + { +Only in binutils-2.25/ld/scripttempl: mep.sc.orig +diff -rup binutils-2.25.orig/ld/scripttempl/pep.sc binutils-2.25/ld/scripttempl/pep.sc +--- binutils-2.25.orig/ld/scripttempl/pep.sc 2014-12-24 10:46:27.709433992 +0000 ++++ binutils-2.25/ld/scripttempl/pep.sc 2014-12-24 10:47:07.403656901 +0000 +@@ -170,6 +170,7 @@ SECTIONS + *(.drectve) + ${RELOCATING+ *(.note.GNU-stack)} + ${RELOCATING+ *(.gnu.lto_*)} ++ ${RELOCATING+ *(.gnu_object_only)} + } + + .idata ${RELOCATING+BLOCK(__section_alignment__)} : +Only in binutils-2.25/ld/scripttempl: pep.sc.orig +diff -rup binutils-2.25.orig/ld/scripttempl/pe.sc binutils-2.25/ld/scripttempl/pe.sc +--- binutils-2.25.orig/ld/scripttempl/pe.sc 2014-12-24 10:46:27.711434003 +0000 ++++ binutils-2.25/ld/scripttempl/pe.sc 2014-12-24 10:47:07.404656906 +0000 +@@ -165,6 +165,7 @@ SECTIONS + *(.drectve) + ${RELOCATING+ *(.note.GNU-stack)} + ${RELOCATING+ *(.gnu.lto_*)} ++ ${RELOCATING+ *(.gnu_object_only)} + } + + .idata ${RELOCATING+BLOCK(__section_alignment__)} : +Only in binutils-2.25/ld/scripttempl: pe.sc.orig diff --git a/binutils-2.25-set-long-long.patch b/binutils-2.25-set-long-long.patch new file mode 100644 index 0000000..1ea7418 --- /dev/null +++ b/binutils-2.25-set-long-long.patch @@ -0,0 +1,38 @@ +diff -up binutils-2.25.orig/bfd/configure.ac binutils-2.25/bfd/configure.ac +--- binutils-2.25.orig/bfd/configure.ac 2014-12-24 10:34:45.590491143 +0000 ++++ binutils-2.25/bfd/configure.ac 2014-12-24 10:36:12.997981992 +0000 +@@ -183,11 +183,13 @@ if test "x${ac_cv_sizeof_long}" = "x8"; + BFD_HOST_64BIT_LONG=1 + test -n "${HOST_64BIT_TYPE}" || HOST_64BIT_TYPE="long" + test -n "${HOST_U_64BIT_TYPE}" || HOST_U_64BIT_TYPE="unsigned long" +-elif test "x${ac_cv_sizeof_long_long}" = "x8"; then ++fi ++if test "x${ac_cv_sizeof_long_long}" = "x8"; then + BFD_HOST_64BIT_LONG_LONG=1 + test -n "${HOST_64BIT_TYPE}" || HOST_64BIT_TYPE="long long" + test -n "${HOST_U_64BIT_TYPE}" || HOST_U_64BIT_TYPE="unsigned long long" +- if test "x${ac_cv_sizeof_void_p}" = "x8"; then ++ if test "x${ac_cv_sizeof_void_p}" = "x8" \ ++ -a "x${ac_cv_sizeof_long}" != "x8"; then + BFD_HOSTPTR_T="unsigned long long" + fi + fi +diff -up ../binutils-2.20.51.0.7.original/bfd/configure ./bfd/configure +--- a/bfd/configure 2010-04-08 15:23:58.000000000 +0100 ++++ b/bfd/configure 2010-04-08 15:24:06.000000000 +0100 +@@ -12819,11 +12819,13 @@ + BFD_HOST_64BIT_LONG=1 + test -n "${HOST_64BIT_TYPE}" || HOST_64BIT_TYPE="long" + test -n "${HOST_U_64BIT_TYPE}" || HOST_U_64BIT_TYPE="unsigned long" +-elif test "x${ac_cv_sizeof_long_long}" = "x8"; then ++fi ++if test "x${ac_cv_sizeof_long_long}" = "x8"; then + BFD_HOST_64BIT_LONG_LONG=1 + test -n "${HOST_64BIT_TYPE}" || HOST_64BIT_TYPE="long long" + test -n "${HOST_U_64BIT_TYPE}" || HOST_U_64BIT_TYPE="unsigned long long" +- if test "x${ac_cv_sizeof_void_p}" = "x8"; then ++ if test "x${ac_cv_sizeof_void_p}" = "x8" \ ++ -a "x${ac_cv_sizeof_long}" != "x8"; then + BFD_HOSTPTR_T="unsigned long long" + fi + fi diff --git a/binutils-2.25-version.patch b/binutils-2.25-version.patch new file mode 100644 index 0000000..7d088ed --- /dev/null +++ b/binutils-2.25-version.patch @@ -0,0 +1,47 @@ +diff -up binutils-2.25.orig/bfd/Makefile.am binutils-2.25/bfd/Makefile.am +--- binutils-2.25.orig/bfd/Makefile.am 2014-12-24 10:28:10.546273213 +0000 ++++ binutils-2.25/bfd/Makefile.am 2014-12-24 10:30:27.569042391 +0000 +@@ -1025,8 +1025,8 @@ DISTCLEANFILES = $(BUILD_CFILES) $(BUILD + bfdver.h: $(srcdir)/version.h $(srcdir)/development.sh $(srcdir)/Makefile.in + @echo "creating $@" + @bfd_version=`echo "$(VERSION)" | sed -e 's/\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\).*/\1.00\2.00\3.00\4.00\5/' -e 's/\([^\.]*\)\..*\(..\)\..*\(..\)\..*\(..\)\..*\(..\)$$/\1\2\3\4\5/'` ;\ +- bfd_version_string="\"$(VERSION)\"" ;\ +- bfd_soversion="$(VERSION)" ;\ ++ bfd_version_string="\"$(VERSION)-%{release}\"" ;\ ++ bfd_soversion="$(VERSION)-%{release}" ;\ + bfd_version_package="\"$(PKGVERSION)\"" ;\ + report_bugs_to="\"$(REPORT_BUGS_TO)\"" ;\ + . $(srcdir)/development.sh ;\ +@@ -1037,7 +1037,7 @@ bfdver.h: $(srcdir)/version.h $(srcdir)/ + fi ;\ + sed -e "s,@bfd_version@,$$bfd_version," \ + -e "s,@bfd_version_string@,$$bfd_version_string," \ +- -e "s,@bfd_version_package@,$$bfd_version_package," \ ++ -e "s,@bfd_version_package@,\"version \"," \ + -e "s,@report_bugs_to@,$$report_bugs_to," \ + < $(srcdir)/version.h > $@; \ + echo "$${bfd_soversion}" > libtool-soversion +diff -up binutils-2.25.orig/bfd/Makefile.in binutils-2.25/bfd/Makefile.in +--- binutils-2.25.orig/bfd/Makefile.in 2014-12-24 10:28:10.558273280 +0000 ++++ binutils-2.25/bfd/Makefile.in 2014-12-24 10:31:37.444434637 +0000 +@@ -2085,8 +2085,8 @@ stmp-lcoff-h: $(LIBCOFF_H_FILES) + bfdver.h: $(srcdir)/version.h $(srcdir)/development.sh $(srcdir)/Makefile.in + @echo "creating $@" + @bfd_version=`echo "$(VERSION)" | sed -e 's/\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\).*/\1.00\2.00\3.00\4.00\5/' -e 's/\([^\.]*\)\..*\(..\)\..*\(..\)\..*\(..\)\..*\(..\)$$/\1\2\3\4\5/'` ;\ +- bfd_version_string="\"$(VERSION)\"" ;\ +- bfd_soversion="$(VERSION)" ;\ ++ bfd_version_string="\"$(VERSION)-%{release}\"" ;\ ++ bfd_soversion="$(VERSION)-%{release}" ;\ + bfd_version_package="\"$(PKGVERSION)\"" ;\ + report_bugs_to="\"$(REPORT_BUGS_TO)\"" ;\ + . $(srcdir)/development.sh ;\ +@@ -2097,7 +2097,7 @@ bfdver.h: $(srcdir)/version.h $(srcdir)/ + fi ;\ + sed -e "s,@bfd_version@,$$bfd_version," \ + -e "s,@bfd_version_string@,$$bfd_version_string," \ +- -e "s,@bfd_version_package@,$$bfd_version_package," \ ++ -e "s,@bfd_version_package@,\"version \"," \ + -e "s,@report_bugs_to@,$$report_bugs_to," \ + < $(srcdir)/version.h > $@; \ + echo "$${bfd_soversion}" > libtool-soversion + diff --git a/binutils-HEAD-change-ld-notice-interface.patch b/binutils-HEAD-change-ld-notice-interface.patch deleted file mode 100644 index db2ea9b..0000000 --- a/binutils-HEAD-change-ld-notice-interface.patch +++ /dev/null @@ -1,398 +0,0 @@ -From 4613510308cea27713e8c7424b2afee9b99f6226 Mon Sep 17 00:00:00 2001 -From: Alan Modra -Date: Tue, 12 Aug 2014 10:43:33 +0930 -Subject: [PATCH] Change ld "notice" interface for better handling of - indirect symbols - -The main aim of this change was to have non_ir_ref set correctly on -new indirect symbols. I could have added a "copy" param to the "notice" -function, so that indirect symbols could be created in plugin_notice, -but it seemed cleaner to create indirect syms earlier and pass them -rather than "string" to "notice". - -include/ - * bfdlink.h (struct bfd_link_callbacks ): Remove "string" - param, add "inh". -bfd/ - * coff-aux.c (coff_m68k_aux_link_add_one_symbol): Only call "notice" - here when not calling the generic add_symbol function. Formatting. - Correct handling of indirect symbols. Update notice call. - * elflink.c (_bfd_elf_notice_as_needed): Update notice call. - * linker.c (_bfd_generic_link_add_one_symbol): Create indirect - symbols early. Update notice call. Add comments regarding weak - symbols vs. indirect. -ld/ - * ldmain.c (notice): Update args. - * plugin.c (plugin_notice): Likewise. Follow warning sym link. - Handle new indirect symbol. ---- - bfd/coff-aux.c | 62 ++++++++++++++++++++++------------------- - bfd/elflink.c | 2 +- - bfd/linker.c | 82 +++++++++++++++++++++++++++++-------------------------- - include/bfdlink.h | 13 ++++----- - ld/ldmain.c | 6 ++-- - ld/plugin.c | 33 ++++++++++++---------- - 9 files changed, 128 insertions(+), 91 deletions(-) - -diff --git a/bfd/coff-aux.c b/bfd/coff-aux.c -index e79c77a..d95b98b 100644 ---- a/bfd/coff-aux.c -+++ b/bfd/coff-aux.c -@@ -73,20 +73,17 @@ coff_m68k_aux_link_add_one_symbol (struct bfd_link_info *info, - bfd_boolean collect, - struct bfd_link_hash_entry **hashp) - { -- struct bfd_link_hash_entry *h; -+ struct bfd_link_hash_entry *h, *inh, *t; - -- if ((flags & (BSF_WARNING | BSF_CONSTRUCTOR | BSF_WEAK)) == 0 && -- !bfd_is_und_section (section) && -- !bfd_is_com_section (section)) -+ if ((flags & (BSF_WARNING | BSF_CONSTRUCTOR | BSF_WEAK)) == 0 -+ && !bfd_is_und_section (section) -+ && !bfd_is_com_section (section)) - { - /* The new symbol is a definition or an indirect definition */ - - /* This bit copied from linker.c */ - if (hashp != NULL && *hashp != NULL) -- { -- h = *hashp; -- BFD_ASSERT (strcmp (h->root.string, name) == 0); -- } -+ h = *hashp; - else - { - h = bfd_link_hash_lookup (info->hash, name, TRUE, copy, FALSE); -@@ -98,37 +95,46 @@ coff_m68k_aux_link_add_one_symbol (struct bfd_link_info *info, - } - } - -- if (info->notice_hash != (struct bfd_hash_table *) NULL -- && (bfd_hash_lookup (info->notice_hash, name, FALSE, FALSE) -- != (struct bfd_hash_entry *) NULL)) -- { -- if (! (*info->callbacks->notice) (info, h, abfd, section, value, -- flags, string)) -- return FALSE; -- } -- - if (hashp != (struct bfd_link_hash_entry **) NULL) - *hashp = h; - /* end duplication from linker.c */ - -- if (h->type == bfd_link_hash_defined -- || h->type == bfd_link_hash_indirect) -+ t = h; -+ inh = NULL; -+ if (h->type == bfd_link_hash_indirect) - { -- asection *msec; -+ inh = h->u.i.link; -+ t = inh; -+ } - -- if (h->type == bfd_link_hash_defined) -- msec = h->u.def.section; -- else -- msec = bfd_ind_section_ptr; -+ if (t->type == bfd_link_hash_defined) -+ { -+ asection *msec = t->u.def.section; -+ bfd_boolean special = FALSE; - - if (bfd_is_abs_section (msec) && !bfd_is_abs_section (section)) - { -- h->u.def.section = section; -- h->u.def.value = value; -- return TRUE; -+ t->u.def.section = section; -+ t->u.def.value = value; -+ special = TRUE; - } - else if (bfd_is_abs_section (section) && !bfd_is_abs_section (msec)) -- return TRUE; -+ special = TRUE; -+ -+ if (special) -+ { -+ if (info->notice_all -+ || (info->notice_hash != NULL -+ && bfd_hash_lookup (info->notice_hash, name, -+ FALSE, FALSE) != NULL)) -+ { -+ if (!(*info->callbacks->notice) (info, h, inh, -+ abfd, section, value, flags)) -+ return FALSE; -+ } -+ -+ return TRUE; -+ } - } - } - -diff --git a/bfd/elflink.c b/bfd/elflink.c -index 69a87a6..de0a734 100644 ---- a/bfd/elflink.c -+++ b/bfd/elflink.c -@@ -3299,7 +3299,7 @@ _bfd_elf_notice_as_needed (bfd *ibfd, - struct bfd_link_info *info, - enum notice_asneeded_action act) - { -- return (*info->callbacks->notice) (info, NULL, ibfd, NULL, act, 0, NULL); -+ return (*info->callbacks->notice) (info, NULL, NULL, ibfd, NULL, act, 0); - } - - /* Add symbols from an ELF object file to the linker hash table. */ -diff --git a/bfd/linker.c b/bfd/linker.c -index 1a5ecef..abdf5b0 100644 ---- a/bfd/linker.c -+++ b/bfd/linker.c -@@ -1442,13 +1442,23 @@ _bfd_generic_link_add_one_symbol (struct bfd_link_info *info, - { - enum link_row row; - struct bfd_link_hash_entry *h; -+ struct bfd_link_hash_entry *inh = NULL; - bfd_boolean cycle; - - BFD_ASSERT (section != NULL); - - if (bfd_is_ind_section (section) - || (flags & BSF_INDIRECT) != 0) -- row = INDR_ROW; -+ { -+ row = INDR_ROW; -+ /* Create the indirect symbol here. This is for the benefit of -+ the plugin "notice" function. -+ STRING is the name of the symbol we want to indirect to. */ -+ inh = bfd_wrapped_link_hash_lookup (abfd, info, string, TRUE, -+ copy, FALSE); -+ if (inh == NULL) -+ return FALSE; -+ } - else if ((flags & BSF_WARNING) != 0) - row = WARN_ROW; - else if ((flags & BSF_CONSTRUCTOR) != 0) -@@ -1493,8 +1503,8 @@ _bfd_generic_link_add_one_symbol (struct bfd_link_info *info, - || (info->notice_hash != NULL - && bfd_hash_lookup (info->notice_hash, name, FALSE, FALSE) != NULL)) - { -- if (! (*info->callbacks->notice) (info, h, -- abfd, section, value, flags, string)) -+ if (! (*info->callbacks->notice) (info, h, inh, -+ abfd, section, value, flags)) - return FALSE; - } - -@@ -1728,44 +1738,40 @@ _bfd_generic_link_add_one_symbol (struct bfd_link_info *info, - return FALSE; - /* Fall through. */ - case IND: -- /* Create an indirect symbol. */ -- { -- struct bfd_link_hash_entry *inh; -- -- /* STRING is the name of the symbol we want to indirect -- to. */ -- inh = bfd_wrapped_link_hash_lookup (abfd, info, string, TRUE, -- copy, FALSE); -- if (inh == NULL) -+ if (inh->type == bfd_link_hash_indirect -+ && inh->u.i.link == h) -+ { -+ (*_bfd_error_handler) -+ (_("%B: indirect symbol `%s' to `%s' is a loop"), -+ abfd, name, string); -+ bfd_set_error (bfd_error_invalid_operation); - return FALSE; -- if (inh->type == bfd_link_hash_indirect -- && inh->u.i.link == h) -- { -- (*_bfd_error_handler) -- (_("%B: indirect symbol `%s' to `%s' is a loop"), -- abfd, name, string); -- bfd_set_error (bfd_error_invalid_operation); -- return FALSE; -- } -- if (inh->type == bfd_link_hash_new) -- { -- inh->type = bfd_link_hash_undefined; -- inh->u.undef.abfd = abfd; -- bfd_link_add_undef (info->hash, inh); -- } -+ } -+ if (inh->type == bfd_link_hash_new) -+ { -+ inh->type = bfd_link_hash_undefined; -+ inh->u.undef.abfd = abfd; -+ bfd_link_add_undef (info->hash, inh); -+ } - -- /* If the indirect symbol has been referenced, we need to -- push the reference down to the symbol we are -- referencing. */ -- if (h->type != bfd_link_hash_new) -- { -- row = UNDEF_ROW; -- cycle = TRUE; -- } -+ /* If the indirect symbol has been referenced, we need to -+ push the reference down to the symbol we are referencing. */ -+ if (h->type != bfd_link_hash_new) -+ { -+ /* ??? If inh->type == bfd_link_hash_undefweak this -+ converts inh to bfd_link_hash_undefined. */ -+ row = UNDEF_ROW; -+ cycle = TRUE; -+ } - -- h->type = bfd_link_hash_indirect; -- h->u.i.link = inh; -- } -+ h->type = bfd_link_hash_indirect; -+ h->u.i.link = inh; -+ /* Not setting h = h->u.i.link here means that when cycle is -+ set above we'll always go to REFC, and then cycle again -+ to the indirected symbol. This means that any successful -+ change of an existing symbol to indirect counts as a -+ reference. ??? That may not be correct when the existing -+ symbol was defweak. */ - break; - - case SET: -diff --git a/include/bfdlink.h b/include/bfdlink.h -index 58dba2a..125683d 100644 ---- a/include/bfdlink.h -+++ b/include/bfdlink.h -@@ -640,15 +640,14 @@ struct bfd_link_callbacks - (struct bfd_link_info *, const char *name, - bfd *abfd, asection *section, bfd_vma address); - /* A function which is called when a symbol in notice_hash is -- defined or referenced. H is the symbol. ABFD, SECTION and -- ADDRESS are the (new) value of the symbol. If SECTION is -- bfd_und_section, this is a reference. FLAGS are the symbol -- BSF_* flags. STRING is the name of the symbol to indirect to if -- the sym is indirect, or the warning string if a warning sym. */ -+ defined or referenced. H is the symbol, INH the indirect symbol -+ if applicable. ABFD, SECTION and ADDRESS are the (new) value of -+ the symbol. If SECTION is bfd_und_section, this is a reference. -+ FLAGS are the symbol BSF_* flags. */ - bfd_boolean (*notice) - (struct bfd_link_info *, struct bfd_link_hash_entry *h, -- bfd *abfd, asection *section, bfd_vma address, flagword flags, -- const char *string); -+ struct bfd_link_hash_entry *inh, -+ bfd *abfd, asection *section, bfd_vma address, flagword flags); - /* Error or warning link info message. */ - void (*einfo) - (const char *fmt, ...); -diff --git a/ld/ldmain.c b/ld/ldmain.c -index ea25afe..77235d5 100644 ---- a/ld/ldmain.c -+++ b/ld/ldmain.c -@@ -137,7 +137,7 @@ static bfd_boolean unattached_reloc - (struct bfd_link_info *, const char *, bfd *, asection *, bfd_vma); - static bfd_boolean notice - (struct bfd_link_info *, struct bfd_link_hash_entry *, -- bfd *, asection *, bfd_vma, flagword, const char *); -+ struct bfd_link_hash_entry *, bfd *, asection *, bfd_vma, flagword); - - static struct bfd_link_callbacks link_callbacks = - { -@@ -1461,11 +1461,11 @@ unattached_reloc (struct bfd_link_info *info ATTRIBUTE_UNUSED, - static bfd_boolean - notice (struct bfd_link_info *info, - struct bfd_link_hash_entry *h, -+ struct bfd_link_hash_entry *inh ATTRIBUTE_UNUSED, - bfd *abfd, - asection *section, - bfd_vma value, -- flagword flags ATTRIBUTE_UNUSED, -- const char *string ATTRIBUTE_UNUSED) -+ flagword flags ATTRIBUTE_UNUSED) - { - const char *name; - -diff --git a/ld/plugin.c b/ld/plugin.c -index 8d6ae05..8cca7d0 100644 ---- a/ld/plugin.c -+++ b/ld/plugin.c -@@ -127,8 +127,9 @@ static const size_t tv_header_size = ARRAY_SIZE (tv_header_tags); - - /* Forward references. */ - static bfd_boolean plugin_notice (struct bfd_link_info *, -- struct bfd_link_hash_entry *, bfd *, -- asection *, bfd_vma, flagword, const char *); -+ struct bfd_link_hash_entry *, -+ struct bfd_link_hash_entry *, -+ bfd *, asection *, bfd_vma, flagword); - - #if !defined (HAVE_DLFCN_H) && defined (HAVE_WINDOWS_H) - -@@ -962,16 +963,21 @@ plugin_call_cleanup (void) - static bfd_boolean - plugin_notice (struct bfd_link_info *info, - struct bfd_link_hash_entry *h, -+ struct bfd_link_hash_entry *inh, - bfd *abfd, - asection *section, - bfd_vma value, -- flagword flags, -- const char *string) -+ flagword flags) - { -+ struct bfd_link_hash_entry *orig_h = h; -+ - if (h != NULL) - { - bfd *sym_bfd; - -+ if (h->type == bfd_link_hash_warning) -+ h = h->u.i.link; -+ - /* Nothing to do here if this def/ref is from an IR dummy BFD. */ - if (is_ir_dummy_bfd (abfd)) - ; -@@ -981,16 +987,15 @@ plugin_notice (struct bfd_link_info *info, - else if (bfd_is_ind_section (section) - || (flags & BSF_INDIRECT) != 0) - { -+ /* ??? Some of this is questionable. See comments in -+ _bfd_generic_link_add_one_symbol for case IND. */ - if (h->type != bfd_link_hash_new) - { -- struct bfd_link_hash_entry *inh; -- - h->non_ir_ref = TRUE; -- inh = bfd_wrapped_link_hash_lookup (abfd, info, string, FALSE, -- FALSE, FALSE); -- if (inh != NULL) -- inh->non_ir_ref = TRUE; -+ inh->non_ir_ref = TRUE; - } -+ else if (inh->type == bfd_link_hash_new) -+ inh->non_ir_ref = TRUE; - } - - /* Nothing to do here for warning symbols. */ -@@ -1031,13 +1036,13 @@ plugin_notice (struct bfd_link_info *info, - } - - /* Continue with cref/nocrossref/trace-sym processing. */ -- if (h == NULL -+ if (orig_h == NULL - || orig_notice_all - || (info->notice_hash != NULL -- && bfd_hash_lookup (info->notice_hash, h->root.string, -+ && bfd_hash_lookup (info->notice_hash, orig_h->root.string, - FALSE, FALSE) != NULL)) -- return (*orig_callbacks->notice) (info, h, -- abfd, section, value, flags, string); -+ return (*orig_callbacks->notice) (info, orig_h, inh, -+ abfd, section, value, flags); - return TRUE; - } - --- -1.9.3 - diff --git a/binutils.spec b/binutils.spec index fd82e82..d032493 100644 --- a/binutils.spec +++ b/binutils.spec @@ -18,8 +18,8 @@ Summary: A GNU collection of binary utilities Name: %{?cross}binutils%{?_with_debug:-debug} -Version: 2.24 -Release: 29%{?dist} +Version: 2.25 +Release: 1%{?dist} License: GPLv3+ Group: Development/Tools URL: http://sources.redhat.com/binutils @@ -34,8 +34,8 @@ Source2: binutils-2.19.50.0.1-output-format.sed Patch01: binutils-2.20.51.0.2-libtool-lib64.patch Patch02: binutils-2.20.51.0.10-ppc64-pie.patch Patch03: binutils-2.20.51.0.2-ia64-lib64.patch -Patch04: binutils-2.20.51.0.2-version.patch -Patch05: binutils-2.20.51.0.2-set-long-long.patch +Patch04: binutils-2.25-version.patch +Patch05: binutils-2.25-set-long-long.patch Patch06: binutils-2.20.51.0.10-copy-osabi.patch Patch07: binutils-2.20.51.0.10-sec-merge-emit.patch # Enable -zrelro by default: BZ #621983 @@ -46,35 +46,12 @@ Patch09: binutils-2.22.52.0.1-export-demangle.h.patch Patch10: binutils-2.22.52.0.4-no-config-h-check.patch # Fix addr2line to use the dynamic symbol table if it could not find any ordinary symbols. Patch11: binutils-2.23.52.0.1-addr2line-dynsymtab.patch -Patch12: binutils-2.23.2-kernel-ld-r.patch +# Patch12: binutils-2.23.2-kernel-ld-r.patch +Patch12: binutils-2.25-kernel-ld-r.patch # Correct bug introduced by patch 12 Patch13: binutils-2.23.2-aarch64-em.patch -# Fix building opcodes library with -Werror=format-security -Patch14: binutils-2.24-s390-mkopc.patch -# Import fixes for IFUNC and PLT handling for AArch64. -Patch15: binutils-2.24-elfnn-aarch64.patch -# Fix decoding of abstract instance names using DW_FORM_ref_addr. -Patch16: binutils-2.24-DW_FORM_ref_addr.patch -# Fix compiling using gcc 4.9 -Patch17: binutils-2.24-set-section-macros.patch -# Fix detections of uncompressed .debug_str sections that look like they have been compressed. -Patch18: binutils-2.24-fake-zlib-sections.patch # Fix detections little endian PPC shared libraries -Patch19: binutils-2.24-ldforcele.patch -Patch20: binutils-2.24-arm-static-tls.patch -Patch21: binutils-2.24-fat-lto-objects.patch -Patch22: binutils-2.24-symbol-warning.patch -Patch23: binutils-2.24-aarch64-ld-shared-non-PIC-xfail.patch -Patch24: binutils-2.24-weak-sym-merge.patch -Patch25: binutils-2.24-indirect-chain.patch -Patch26: binutils-2.24-aarch64-fix-final_link_relocate.patch -Patch27: binutils-2.24-aarch64-fix-gotplt-offset-ifunc.patch -Patch28: binutils-2.24-aarch64-fix-static-ifunc.patch -Patch29: binutils-2.24-aarch64-fix-ie-relax.patch -Patch30: binutils-HEAD-change-ld-notice-interface.patch -Patch31: binutils-2.24-corrupt-binaries.patch -Patch32: binutils-2.24-strings-default-all.patch -Patch33: binutils-2.24-corrupt-ar.patch +Patch14: binutils-2.24-ldforcele.patch Provides: bundled(libiberty) @@ -171,47 +148,28 @@ using libelf instead of BFD. %prep %setup -q -n binutils-%{version} -%patch01 -p0 -b .libtool-lib64~ -%patch02 -p0 -b .ppc64-pie~ +%patch01 -p1 -b .libtool-lib64~ +%patch02 -p1 -b .ppc64-pie~ %ifarch ia64 %if "%{_lib}" == "lib64" -%patch03 -p0 -b .ia64-lib64~ +%patch03 -p1 -b .ia64-lib64~ %endif %endif -%patch04 -p0 -b .version~ -%patch05 -p0 -b .set-long-long~ -%patch06 -p0 -b .copy-osabi~ -%patch07 -p0 -b .sec-merge-emit~ +%patch04 -p1 -b .version~ +%patch05 -p1 -b .set-long-long~ +%patch06 -p1 -b .copy-osabi~ +%patch07 -p1 -b .sec-merge-emit~ %if 0%{?fedora} >= 18 || 0%{?rhel} >= 7 -%patch08 -p0 -b .relro~ +%patch08 -p1 -b .relro~ %endif -%patch09 -p0 -b .export-demangle-h~ -%patch10 -p0 -b .no-config-h-check~ -%patch11 -p0 -b .addr2line~ -%patch12 -p0 -b .kernel-ld-r~ -%patch13 -p0 -b .aarch64~ -%patch14 -p0 -b .mkopc~ -%patch15 -p0 -b .elf-aarch64~ -%patch16 -p0 -b .ref-addr~ -%patch17 -p0 -b .sec-macros~ -%patch18 -p0 -b .fake-zlib~ +%patch09 -p1 -b .export-demangle-h~ +%patch10 -p1 -b .no-config-h-check~ +%patch11 -p1 -b .addr2line~ +%patch12 -p1 -b .kernel-ld-r~ +%patch13 -p1 -b .aarch64~ %ifarch ppc64le -%patch19 -p0 -b .ldforcele~ +%patch14 -p1 -b .ldforcele~ %endif -%patch20 -p1 -b .armstatictls~ -%patch21 -p1 -b .fatlto~ -%patch22 -p1 -b .symwarn~ -%patch23 -p1 -b .ld-aarch64-xfails~ -%patch24 -p0 -b .weak-sym-merge~ -%patch25 -p0 -b .indirect-chain~ -%patch26 -p1 -b .aa64-final-link~ -%patch27 -p1 -b .aa64-1~ -%patch28 -p1 -b .aa64-2~ -%patch29 -p1 -b .aa64-3~ -%patch30 -p1 -b .ldplugin~ -%patch31 -p0 -b .corrupt-binaries~ -%patch32 -p0 -b .strings-all~ -%patch33 -p0 -b .corrupt-ar~ # We cannot run autotools as there is an exact requirement of autoconf-2.59. @@ -526,6 +484,28 @@ exit 0 %endif # %{isnative} %changelog +* Wed Dec 24 2014 Nick Clifton - 2.25-1 +- Rebase on FSF binutils 2.25 release. +- Retire: binutils-2.24-s390-mkopc.patch +- Retire: binutils-2.24-elfnn-aarch64.patch +- Retire: binutils-2.24-DW_FORM_ref_addr.patch +- Retire: binutils-2.24-set-section-macros.patch +- Retire: binutils-2.24-fake-zlib-sections.patch +- Retire: binutils-2.24-arm-static-tls.patch +- Retire: binutils-2.24-fat-lto-objects.patch +- Retire: binutils-2.24-symbol-warning.patch +- Retire: binutils-2.24-aarch64-ld-shared-non-PIC-xfail.patch +- Retire: binutils-2.24-weak-sym-merge.patch +- Retire: binutils-2.24-indirect-chain.patch +- Retire: binutils-2.24-aarch64-fix-final_link_relocate.patch +- Retire: binutils-2.24-aarch64-fix-gotplt-offset-ifunc.patch +- Retire: binutils-2.24-aarch64-fix-static-ifunc.patch +- Retire: binutils-2.24-aarch64-fix-ie-relax.patch +- Retire: binutils-HEAD-change-ld-notice-interface.patch +- Retire: binutils-2.24-corrupt-binaries.patch +- Retire: binutils-2.24-strings-default-all.patch +- Retire: binutils-2.24-corrupt-ar.patch + * Thu Nov 13 2014 Nick Clifton - 2.24-29 - Fix problems with the ar program reported in FSF PR 17533. Resolves: BZ #1162666, #1162655 diff --git a/sources b/sources index 1280421..272f6fd 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -e0f71a7b2ddab0f8612336ac81d9636b binutils-2.24.tar.bz2 +d9f3303f802a5b6b0bb73a335ab89d66 binutils-2.25.tar.bz2