Update binutils-* to upstream (2.30-r0)

This commit is contained in:
Oliver Smith 2018-05-03 21:11:10 +02:00
parent 6e75a19cc1
commit eb709f2450
9 changed files with 9 additions and 1317 deletions

View file

@ -4,8 +4,8 @@
pkgname="binutils-aarch64"
pkgver=2.28
pkgrel=3
pkgver=2.30
pkgrel=0
pkgdesc="Tools necessary to build programs for aarch64 targets"
url="https://www.gnu.org/software/binutils/"
depends=""
@ -17,8 +17,6 @@ license="GPL-2.0 GPL-3.0-or-later LGPL-2.0 BSD"
subpackages=""
source="http://ftp.gnu.org/gnu/binutils/binutils-$pkgver.tar.bz2
binutils-ld-fix-static-linking.patch
hash-style-configure-flag.patch
CVE-2017-7614.patch
gold-mips.patch
"
builddir="$srcdir/binutils-$pkgver"
@ -62,8 +60,6 @@ package() {
sha512sums="ede2e4e59a800260eea8c14eafbaee94e30abadafd5c419a3370f9f62213cf027d6400a1d4970b6958bd4d220e675dcd483a708107016e7abd5c99d7392ba8fd binutils-2.28.tar.bz2
sha512sums="c3ce91aa20f058ec589bf18c722bf651331b394db6378900cc813cc0eea3a331a96584d5ae090630b627369510397dccc9edfcd43d4aeefc99579f277a05c72c binutils-2.30.tar.bz2
ecee33b0e435aa704af1c334e560f201638ff79e199aa11ed78a72f7c9b46f85fbb227af5748e735fd681d1965fcc42ac81b0c8824e540430ce0c706c81e8b49 binutils-ld-fix-static-linking.patch
404a483adc8bf8112d953c53a853d21588745752687ee3ca57def539201b9e87844b23ba3c666d7c9648911cdeb55144382c3726ae3845e12b232c3f001c1bfe hash-style-configure-flag.patch
03e2329a216eaaaebc00a2b487a8ffa57657845ea3428f24a1029eabaca2103cb00f39cb4824fe6b70ce9c124e0f850c893746fcf203a6a69288d19df624c60a CVE-2017-7614.patch
f55cf2e0bf82f97583a1abe10710e4013ecf7d64f1da2ef8659a44a06d0dd8beaf58dab98a183488ea137f03e32d62efc878d95f018f836f8cec870bc448556f gold-mips.patch"

View file

@ -1,84 +0,0 @@
From ad32986fdf9da1c8748e47b8b45100398223dba8 Mon Sep 17 00:00:00 2001
From: Nick Clifton <nickc@redhat.com>
Date: Tue, 4 Apr 2017 11:23:36 +0100
Subject: [PATCH] Fix null pointer dereferences when using a link built with
clang.
PR binutils/21342
* elflink.c (_bfd_elf_define_linkage_sym): Prevent null pointer
dereference.
(bfd_elf_final_link): Only initialize the extended symbol index
section if there are extended symbol tables to list.
---
bfd/elflink.c | 35 +++++++++++++++++++++--------------
2 files changed, 29 insertions(+), 14 deletions(-)
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 776357f..9bf75c8 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -119,15 +119,18 @@ _bfd_elf_define_linkage_sym (bfd *abfd,
defined in shared libraries can't be overridden, because we
lose the link to the bfd which is via the symbol section. */
h->root.type = bfd_link_hash_new;
+ bh = &h->root;
}
+ else
+ bh = NULL;
- bh = &h->root;
bed = get_elf_backend_data (abfd);
if (!_bfd_generic_link_add_one_symbol (info, abfd, name, BSF_GLOBAL,
sec, 0, NULL, FALSE, bed->collect,
&bh))
return NULL;
h = (struct elf_link_hash_entry *) bh;
+ BFD_ASSERT (h != NULL);
h->def_regular = 1;
h->non_elf = 0;
h->root.linker_def = 1;
@@ -12038,24 +12041,28 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info)
{
/* Finish up and write out the symbol string table (.strtab)
section. */
- Elf_Internal_Shdr *symstrtab_hdr;
+ Elf_Internal_Shdr *symstrtab_hdr = NULL;
file_ptr off = symtab_hdr->sh_offset + symtab_hdr->sh_size;
- symtab_shndx_hdr = & elf_symtab_shndx_list (abfd)->hdr;
- if (symtab_shndx_hdr != NULL && symtab_shndx_hdr->sh_name != 0)
+ if (elf_symtab_shndx_list (abfd))
{
- symtab_shndx_hdr->sh_type = SHT_SYMTAB_SHNDX;
- symtab_shndx_hdr->sh_entsize = sizeof (Elf_External_Sym_Shndx);
- symtab_shndx_hdr->sh_addralign = sizeof (Elf_External_Sym_Shndx);
- amt = bfd_get_symcount (abfd) * sizeof (Elf_External_Sym_Shndx);
- symtab_shndx_hdr->sh_size = amt;
+ symtab_shndx_hdr = & elf_symtab_shndx_list (abfd)->hdr;
- off = _bfd_elf_assign_file_position_for_section (symtab_shndx_hdr,
- off, TRUE);
+ if (symtab_shndx_hdr != NULL && symtab_shndx_hdr->sh_name != 0)
+ {
+ symtab_shndx_hdr->sh_type = SHT_SYMTAB_SHNDX;
+ symtab_shndx_hdr->sh_entsize = sizeof (Elf_External_Sym_Shndx);
+ symtab_shndx_hdr->sh_addralign = sizeof (Elf_External_Sym_Shndx);
+ amt = bfd_get_symcount (abfd) * sizeof (Elf_External_Sym_Shndx);
+ symtab_shndx_hdr->sh_size = amt;
- if (bfd_seek (abfd, symtab_shndx_hdr->sh_offset, SEEK_SET) != 0
- || (bfd_bwrite (flinfo.symshndxbuf, amt, abfd) != amt))
- return FALSE;
+ off = _bfd_elf_assign_file_position_for_section (symtab_shndx_hdr,
+ off, TRUE);
+
+ if (bfd_seek (abfd, symtab_shndx_hdr->sh_offset, SEEK_SET) != 0
+ || (bfd_bwrite (flinfo.symshndxbuf, amt, abfd) != amt))
+ return FALSE;
+ }
}
symstrtab_hdr = &elf_tdata (abfd)->strtab_hdr;
--
2.9.3

View file

@ -1,348 +0,0 @@
From 2760f24c4942853eac7b921e4b8843d57a602654 Mon Sep 17 00:00:00 2001
From: Romain Geissler <romain.geissler@gmail.com>
Date: Tue, 8 Aug 2017 07:25:39 +0930
Subject: [PATCH] Add configure flag to enable gnu hash style by default.
ld/
* configure.ac: Add --enable-default-hash-style option.
* ldmain.c (main): Set link_info.emit_hash to DEFAULT_EMIT_SYSV_HASH.
Set link_info.emit_gnu_hash to DEFAULT_EMIT_GNU_HASH.
* configure: Regenerate.
* config.in: Regenerate.
gold/
* configure.ac: Add --enable-default-hash-style option.
* options.h (hash_style): Use DEFAULT_HASH_STYLE as default value.
* configure: Regenerate.
* config.in: Regenerate.
---
gold/ChangeLog | 8 ++++++++
gold/config.in | 3 +++
gold/configure | 27 +++++++++++++++++++++++++++
gold/configure.ac | 20 ++++++++++++++++++++
gold/options.h | 2 +-
ld/ChangeLog | 9 +++++++++
ld/config.in | 6 ++++++
ld/configure | 42 ++++++++++++++++++++++++++++++++++++++----
ld/configure.ac | 34 ++++++++++++++++++++++++++++++++++
ld/ldmain.c | 3 ++-
10 files changed, 148 insertions(+), 6 deletions(-)
diff --git a/gold/ChangeLog b/gold/ChangeLog
index d598386..93836dd 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,3 +1,11 @@
+2017-08-08 Romain Geissler <romain.geissler@gmail.com>
+ Alan Modra <amodra@gmail.com>
+
+ * configure.ac: Add --enable-default-hash-style option.
+ * options.h (hash_style): Use DEFAULT_HASH_STYLE as default value.
+ * configure: Regenerate.
+ * config.in: Regenerate.
+
2017-02-22 Alan Modra <amodra@gmail.com>
* powerpc.cc (Target_powerpc::make_iplt_section): Check that
diff --git a/gold/config.in b/gold/config.in
index d9f7b76..5855fca 100644
--- a/gold/config.in
+++ b/gold/config.in
@@ -10,6 +10,9 @@
/* Define if building universal (internal helper macro) */
#undef AC_APPLE_UNIVERSAL_BUILD
+/* Set the default --hash-style value */
+#undef DEFAULT_HASH_STYLE
+
/* Define to 1 if you want to enable -z relro in ELF linker by default. */
#undef DEFAULT_LD_Z_RELRO
diff --git a/gold/configure b/gold/configure
index cb020be..90a706d 100755
--- a/gold/configure
+++ b/gold/configure
@@ -797,6 +797,7 @@ enable_threads
enable_plugins
enable_relro
enable_targets
+enable_default_hash_style
with_lib_path
enable_dependency_tracking
enable_nls
@@ -1447,6 +1448,8 @@ Optional Features:
--enable-plugins linker plugins
--enable-relro enable -z relro in ELF linker by default
--enable-targets alternative target configurations
+ --enable-default-hash-style={sysv,gnu,both}
+ use this default hash style
--disable-dependency-tracking speeds up one-time build
--enable-dependency-tracking do not reject slow dependency extractors
--disable-nls do not use Native Language Support
@@ -3410,6 +3413,30 @@ if test -n "$enable_targets"; then
done
fi
+# Decide which "--hash-style" to use by default
+# Provide a configure time option to override our default.
+# Check whether --enable-default-hash-style was given.
+if test "${enable_default_hash_style+set}" = set; then :
+ enableval=$enable_default_hash_style; case "${enable_default_hash_style}" in
+ sysv | gnu | both) ;;
+ *) as_fn_error "bad value ${enable_default_hash_style} for enable-default-hash-style option" "$LINENO" 5 ;;
+esac
+else
+ case "${target}" in
+ # Enable gnu hash only on GNU targets, but not mips
+ mips*-*-*) enable_default_hash_style=sysv ;;
+ *-*-gnu* | *-*-linux* | *-*-nacl*) enable_default_hash_style=both ;;
+ *) enable_default_hash_style=sysv ;;
+esac
+fi
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define DEFAULT_HASH_STYLE "${enable_default_hash_style}"
+_ACEOF
+
+
# See which specific instantiations we need.
targetobjs=
all_targets=
diff --git a/gold/configure.ac b/gold/configure.ac
index cbe3380..d7fa1f8 100644
--- a/gold/configure.ac
+++ b/gold/configure.ac
@@ -161,6 +161,26 @@ if test -n "$enable_targets"; then
done
fi
+# Decide which "--hash-style" to use by default
+# Provide a configure time option to override our default.
+AC_ARG_ENABLE([default-hash-style],
+AS_HELP_STRING([--enable-default-hash-style={sysv,gnu,both}],
+ [use this default hash style]),
+[case "${enable_default_hash_style}" in
+ sysv | gnu | both) ;;
+ *) AC_MSG_ERROR([bad value ${enable_default_hash_style} for enable-default-hash-style option]) ;;
+esac],
+[case "${target}" in
+ # Enable gnu hash only on GNU targets, but not mips
+ mips*-*-*) enable_default_hash_style=sysv ;;
+ *-*-gnu* | *-*-linux* | *-*-nacl*) enable_default_hash_style=both ;;
+ *) enable_default_hash_style=sysv ;;
+esac])
+
+AC_DEFINE_UNQUOTED([DEFAULT_HASH_STYLE],
+ ["${enable_default_hash_style}"],
+ [Set the default --hash-style value])
+
# See which specific instantiations we need.
targetobjs=
all_targets=
diff --git a/gold/options.h b/gold/options.h
index a8b1d46..ce21a42 100644
--- a/gold/options.h
+++ b/gold/options.h
@@ -921,7 +921,7 @@ class General_options
N_("Min fraction of empty buckets in dynamic hash"),
N_("FRACTION"));
- DEFINE_enum(hash_style, options::TWO_DASHES, '\0', "sysv",
+ DEFINE_enum(hash_style, options::TWO_DASHES, '\0', DEFAULT_HASH_STYLE,
N_("Dynamic hash style"), N_("[sysv,gnu,both]"),
{"sysv", "gnu", "both"});
diff --git a/ld/ChangeLog b/ld/ChangeLog
index ba7d1d4..cf91d55 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,12 @@
+2017-08-08 Romain Geissler <romain.geissler@gmail.com>
+ Alan Modra <amodra@gmail.com>
+
+ * configure.ac: Add --enable-default-hash-style option.
+ * ldmain.c (main): Set link_info.emit_hash to DEFAULT_EMIT_SYSV_HASH.
+ Set link_info.emit_gnu_hash to DEFAULT_EMIT_GNU_HASH.
+ * configure: Regenerate.
+ * config.in: Regenerate.
+
2017-03-02 Tristan Gingold <gingold@adacore.com>
* configure: Regenerate.
diff --git a/ld/config.in b/ld/config.in
index 2c6d698..b2318e1 100644
--- a/ld/config.in
+++ b/ld/config.in
@@ -7,6 +7,12 @@
#endif
#define __CONFIG_H__ 1
+/* Define to 1 if you want to emit gnu hash in the ELF linker by default. */
+#undef DEFAULT_EMIT_GNU_HASH
+
+/* Define to 1 if you want to emit sysv hash in the ELF linker by default. */
+#undef DEFAULT_EMIT_SYSV_HASH
+
/* Define if you want compressed debug sections by default. */
#undef DEFAULT_FLAG_COMPRESS_DEBUG
diff --git a/ld/configure b/ld/configure
index 36af969..40c67fd 100755
--- a/ld/configure
+++ b/ld/configure
@@ -793,6 +793,7 @@ enable_gold
enable_got
enable_compressed_debug_sections
enable_relro
+enable_default_hash_style
enable_werror
enable_build_warnings
enable_nls
@@ -1452,6 +1453,8 @@ Optional Features:
--enable-compressed-debug-sections={all,ld,none}
compress debug sections by default]
--enable-relro enable -z relro in ELF linker by default
+ --enable-default-hash-style={sysv,gnu,both}
+ use this default hash style
--enable-werror treat compile warnings as errors
--enable-build-warnings enable build-time compiler warnings
--disable-nls do not use Native Language Support
@@ -11724,7 +11727,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 11727 "configure"
+#line 11730 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -11830,7 +11833,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 11833 "configure"
+#line 11836 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -15555,6 +15558,33 @@ if test "${enable_relro+set}" = set; then :
esac
fi
+# Decide which "--hash-style" to use by default
+# Provide a configure time option to override our default.
+# Check whether --enable-default-hash-style was given.
+if test "${enable_default_hash_style+set}" = set; then :
+ enableval=$enable_default_hash_style; case "${enable_default_hash_style}" in
+ sysv | gnu | both) ;;
+ *) as_fn_error "bad value ${enable_default_hash_style} for enable-default-hash-style option" "$LINENO" 5 ;;
+esac
+else
+ case "${target}" in
+ # Enable gnu hash only on GNU targets, but not mips
+ mips*-*-*) enable_default_hash_style=sysv ;;
+ *-*-gnu* | *-*-linux* | *-*-nacl*) enable_default_hash_style=both ;;
+ *) enable_default_hash_style=sysv ;;
+esac
+fi
+
+
+case "${enable_default_hash_style}" in
+ sysv | both) ac_default_emit_sysv_hash=1 ;;
+ *) ac_default_emit_sysv_hash=0 ;;
+esac
+
+case "${enable_default_hash_style}" in
+ gnu | both) ac_default_emit_gnu_hash=1 ;;
+ *) ac_default_emit_gnu_hash=0 ;;
+esac
# Set the 'development' global.
. $srcdir/../bfd/development.sh
@@ -17212,9 +17242,13 @@ cat >>confdefs.h <<_ACEOF
#define DEFAULT_LD_Z_RELRO $ac_default_ld_z_relro
_ACEOF
+cat >>confdefs.h <<_ACEOF
+#define DEFAULT_EMIT_SYSV_HASH $ac_default_emit_sysv_hash
+_ACEOF
-
-
+cat >>confdefs.h <<_ACEOF
+#define DEFAULT_EMIT_GNU_HASH $ac_default_emit_gnu_hash
+_ACEOF
diff --git a/ld/configure.ac b/ld/configure.ac
index 36a9f50..1876ad7 100644
--- a/ld/configure.ac
+++ b/ld/configure.ac
@@ -166,6 +166,32 @@ AC_ARG_ENABLE(relro,
no) ac_default_ld_z_relro=0 ;;
esac])dnl
+# Decide which "--hash-style" to use by default
+# Provide a configure time option to override our default.
+AC_ARG_ENABLE([default-hash-style],
+AS_HELP_STRING([--enable-default-hash-style={sysv,gnu,both}],
+ [use this default hash style]),
+[case "${enable_default_hash_style}" in
+ sysv | gnu | both) ;;
+ *) AC_MSG_ERROR([bad value ${enable_default_hash_style} for enable-default-hash-style option]) ;;
+esac],
+[case "${target}" in
+ # Enable gnu hash only on GNU targets, but not mips
+ mips*-*-*) enable_default_hash_style=sysv ;;
+ *-*-gnu* | *-*-linux* | *-*-nacl*) enable_default_hash_style=both ;;
+ *) enable_default_hash_style=sysv ;;
+esac])
+
+case "${enable_default_hash_style}" in
+ sysv | both) ac_default_emit_sysv_hash=1 ;;
+ *) ac_default_emit_sysv_hash=0 ;;
+esac
+
+case "${enable_default_hash_style}" in
+ gnu | both) ac_default_emit_gnu_hash=1 ;;
+ *) ac_default_emit_gnu_hash=0 ;;
+esac
+
AM_BINUTILS_WARNINGS
AM_LC_MESSAGES
@@ -394,6 +420,14 @@ AC_DEFINE_UNQUOTED(DEFAULT_LD_Z_RELRO,
$ac_default_ld_z_relro,
[Define to 1 if you want to enable -z relro in ELF linker by default.])
+AC_DEFINE_UNQUOTED([DEFAULT_EMIT_SYSV_HASH],
+ [$ac_default_emit_sysv_hash],
+ [Define to 1 if you want to emit sysv hash in the ELF linker by default.])
+
+AC_DEFINE_UNQUOTED([DEFAULT_EMIT_GNU_HASH],
+ [$ac_default_emit_gnu_hash],
+ [Define to 1 if you want to emit gnu hash in the ELF linker by default.])
+
AC_SUBST(elf_list_options)
AC_SUBST(elf_shlib_list_options)
AC_SUBST(elf_plt_unwind_list_options)
diff --git a/ld/ldmain.c b/ld/ldmain.c
index 1e48b1a..579d961 100644
--- a/ld/ldmain.c
+++ b/ld/ldmain.c
@@ -282,7 +282,8 @@ main (int argc, char **argv)
link_info.keep_memory = TRUE;
link_info.combreloc = TRUE;
link_info.strip_discarded = TRUE;
- link_info.emit_hash = TRUE;
+ link_info.emit_hash = DEFAULT_EMIT_SYSV_HASH;
+ link_info.emit_gnu_hash = DEFAULT_EMIT_GNU_HASH;
link_info.callbacks = &link_callbacks;
link_info.input_bfds_tail = &link_info.input_bfds;
/* SVR4 linkers seem to set DT_INIT and DT_FINI based on magic _init
--
2.14.2

View file

@ -4,8 +4,8 @@
pkgname="binutils-armhf"
pkgver=2.28
pkgrel=3
pkgver=2.30
pkgrel=0
pkgdesc="Tools necessary to build programs for armhf targets"
url="https://www.gnu.org/software/binutils/"
depends=""
@ -17,8 +17,6 @@ license="GPL-2.0 GPL-3.0-or-later LGPL-2.0 BSD"
subpackages=""
source="http://ftp.gnu.org/gnu/binutils/binutils-$pkgver.tar.bz2
binutils-ld-fix-static-linking.patch
hash-style-configure-flag.patch
CVE-2017-7614.patch
gold-mips.patch
"
builddir="$srcdir/binutils-$pkgver"
@ -62,8 +60,6 @@ package() {
sha512sums="ede2e4e59a800260eea8c14eafbaee94e30abadafd5c419a3370f9f62213cf027d6400a1d4970b6958bd4d220e675dcd483a708107016e7abd5c99d7392ba8fd binutils-2.28.tar.bz2
sha512sums="c3ce91aa20f058ec589bf18c722bf651331b394db6378900cc813cc0eea3a331a96584d5ae090630b627369510397dccc9edfcd43d4aeefc99579f277a05c72c binutils-2.30.tar.bz2
ecee33b0e435aa704af1c334e560f201638ff79e199aa11ed78a72f7c9b46f85fbb227af5748e735fd681d1965fcc42ac81b0c8824e540430ce0c706c81e8b49 binutils-ld-fix-static-linking.patch
404a483adc8bf8112d953c53a853d21588745752687ee3ca57def539201b9e87844b23ba3c666d7c9648911cdeb55144382c3726ae3845e12b232c3f001c1bfe hash-style-configure-flag.patch
03e2329a216eaaaebc00a2b487a8ffa57657845ea3428f24a1029eabaca2103cb00f39cb4824fe6b70ce9c124e0f850c893746fcf203a6a69288d19df624c60a CVE-2017-7614.patch
f55cf2e0bf82f97583a1abe10710e4013ecf7d64f1da2ef8659a44a06d0dd8beaf58dab98a183488ea137f03e32d62efc878d95f018f836f8cec870bc448556f gold-mips.patch"

View file

@ -1,84 +0,0 @@
From ad32986fdf9da1c8748e47b8b45100398223dba8 Mon Sep 17 00:00:00 2001
From: Nick Clifton <nickc@redhat.com>
Date: Tue, 4 Apr 2017 11:23:36 +0100
Subject: [PATCH] Fix null pointer dereferences when using a link built with
clang.
PR binutils/21342
* elflink.c (_bfd_elf_define_linkage_sym): Prevent null pointer
dereference.
(bfd_elf_final_link): Only initialize the extended symbol index
section if there are extended symbol tables to list.
---
bfd/elflink.c | 35 +++++++++++++++++++++--------------
2 files changed, 29 insertions(+), 14 deletions(-)
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 776357f..9bf75c8 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -119,15 +119,18 @@ _bfd_elf_define_linkage_sym (bfd *abfd,
defined in shared libraries can't be overridden, because we
lose the link to the bfd which is via the symbol section. */
h->root.type = bfd_link_hash_new;
+ bh = &h->root;
}
+ else
+ bh = NULL;
- bh = &h->root;
bed = get_elf_backend_data (abfd);
if (!_bfd_generic_link_add_one_symbol (info, abfd, name, BSF_GLOBAL,
sec, 0, NULL, FALSE, bed->collect,
&bh))
return NULL;
h = (struct elf_link_hash_entry *) bh;
+ BFD_ASSERT (h != NULL);
h->def_regular = 1;
h->non_elf = 0;
h->root.linker_def = 1;
@@ -12038,24 +12041,28 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info)
{
/* Finish up and write out the symbol string table (.strtab)
section. */
- Elf_Internal_Shdr *symstrtab_hdr;
+ Elf_Internal_Shdr *symstrtab_hdr = NULL;
file_ptr off = symtab_hdr->sh_offset + symtab_hdr->sh_size;
- symtab_shndx_hdr = & elf_symtab_shndx_list (abfd)->hdr;
- if (symtab_shndx_hdr != NULL && symtab_shndx_hdr->sh_name != 0)
+ if (elf_symtab_shndx_list (abfd))
{
- symtab_shndx_hdr->sh_type = SHT_SYMTAB_SHNDX;
- symtab_shndx_hdr->sh_entsize = sizeof (Elf_External_Sym_Shndx);
- symtab_shndx_hdr->sh_addralign = sizeof (Elf_External_Sym_Shndx);
- amt = bfd_get_symcount (abfd) * sizeof (Elf_External_Sym_Shndx);
- symtab_shndx_hdr->sh_size = amt;
+ symtab_shndx_hdr = & elf_symtab_shndx_list (abfd)->hdr;
- off = _bfd_elf_assign_file_position_for_section (symtab_shndx_hdr,
- off, TRUE);
+ if (symtab_shndx_hdr != NULL && symtab_shndx_hdr->sh_name != 0)
+ {
+ symtab_shndx_hdr->sh_type = SHT_SYMTAB_SHNDX;
+ symtab_shndx_hdr->sh_entsize = sizeof (Elf_External_Sym_Shndx);
+ symtab_shndx_hdr->sh_addralign = sizeof (Elf_External_Sym_Shndx);
+ amt = bfd_get_symcount (abfd) * sizeof (Elf_External_Sym_Shndx);
+ symtab_shndx_hdr->sh_size = amt;
- if (bfd_seek (abfd, symtab_shndx_hdr->sh_offset, SEEK_SET) != 0
- || (bfd_bwrite (flinfo.symshndxbuf, amt, abfd) != amt))
- return FALSE;
+ off = _bfd_elf_assign_file_position_for_section (symtab_shndx_hdr,
+ off, TRUE);
+
+ if (bfd_seek (abfd, symtab_shndx_hdr->sh_offset, SEEK_SET) != 0
+ || (bfd_bwrite (flinfo.symshndxbuf, amt, abfd) != amt))
+ return FALSE;
+ }
}
symstrtab_hdr = &elf_tdata (abfd)->strtab_hdr;
--
2.9.3

View file

@ -1,348 +0,0 @@
From 2760f24c4942853eac7b921e4b8843d57a602654 Mon Sep 17 00:00:00 2001
From: Romain Geissler <romain.geissler@gmail.com>
Date: Tue, 8 Aug 2017 07:25:39 +0930
Subject: [PATCH] Add configure flag to enable gnu hash style by default.
ld/
* configure.ac: Add --enable-default-hash-style option.
* ldmain.c (main): Set link_info.emit_hash to DEFAULT_EMIT_SYSV_HASH.
Set link_info.emit_gnu_hash to DEFAULT_EMIT_GNU_HASH.
* configure: Regenerate.
* config.in: Regenerate.
gold/
* configure.ac: Add --enable-default-hash-style option.
* options.h (hash_style): Use DEFAULT_HASH_STYLE as default value.
* configure: Regenerate.
* config.in: Regenerate.
---
gold/ChangeLog | 8 ++++++++
gold/config.in | 3 +++
gold/configure | 27 +++++++++++++++++++++++++++
gold/configure.ac | 20 ++++++++++++++++++++
gold/options.h | 2 +-
ld/ChangeLog | 9 +++++++++
ld/config.in | 6 ++++++
ld/configure | 42 ++++++++++++++++++++++++++++++++++++++----
ld/configure.ac | 34 ++++++++++++++++++++++++++++++++++
ld/ldmain.c | 3 ++-
10 files changed, 148 insertions(+), 6 deletions(-)
diff --git a/gold/ChangeLog b/gold/ChangeLog
index d598386..93836dd 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,3 +1,11 @@
+2017-08-08 Romain Geissler <romain.geissler@gmail.com>
+ Alan Modra <amodra@gmail.com>
+
+ * configure.ac: Add --enable-default-hash-style option.
+ * options.h (hash_style): Use DEFAULT_HASH_STYLE as default value.
+ * configure: Regenerate.
+ * config.in: Regenerate.
+
2017-02-22 Alan Modra <amodra@gmail.com>
* powerpc.cc (Target_powerpc::make_iplt_section): Check that
diff --git a/gold/config.in b/gold/config.in
index d9f7b76..5855fca 100644
--- a/gold/config.in
+++ b/gold/config.in
@@ -10,6 +10,9 @@
/* Define if building universal (internal helper macro) */
#undef AC_APPLE_UNIVERSAL_BUILD
+/* Set the default --hash-style value */
+#undef DEFAULT_HASH_STYLE
+
/* Define to 1 if you want to enable -z relro in ELF linker by default. */
#undef DEFAULT_LD_Z_RELRO
diff --git a/gold/configure b/gold/configure
index cb020be..90a706d 100755
--- a/gold/configure
+++ b/gold/configure
@@ -797,6 +797,7 @@ enable_threads
enable_plugins
enable_relro
enable_targets
+enable_default_hash_style
with_lib_path
enable_dependency_tracking
enable_nls
@@ -1447,6 +1448,8 @@ Optional Features:
--enable-plugins linker plugins
--enable-relro enable -z relro in ELF linker by default
--enable-targets alternative target configurations
+ --enable-default-hash-style={sysv,gnu,both}
+ use this default hash style
--disable-dependency-tracking speeds up one-time build
--enable-dependency-tracking do not reject slow dependency extractors
--disable-nls do not use Native Language Support
@@ -3410,6 +3413,30 @@ if test -n "$enable_targets"; then
done
fi
+# Decide which "--hash-style" to use by default
+# Provide a configure time option to override our default.
+# Check whether --enable-default-hash-style was given.
+if test "${enable_default_hash_style+set}" = set; then :
+ enableval=$enable_default_hash_style; case "${enable_default_hash_style}" in
+ sysv | gnu | both) ;;
+ *) as_fn_error "bad value ${enable_default_hash_style} for enable-default-hash-style option" "$LINENO" 5 ;;
+esac
+else
+ case "${target}" in
+ # Enable gnu hash only on GNU targets, but not mips
+ mips*-*-*) enable_default_hash_style=sysv ;;
+ *-*-gnu* | *-*-linux* | *-*-nacl*) enable_default_hash_style=both ;;
+ *) enable_default_hash_style=sysv ;;
+esac
+fi
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define DEFAULT_HASH_STYLE "${enable_default_hash_style}"
+_ACEOF
+
+
# See which specific instantiations we need.
targetobjs=
all_targets=
diff --git a/gold/configure.ac b/gold/configure.ac
index cbe3380..d7fa1f8 100644
--- a/gold/configure.ac
+++ b/gold/configure.ac
@@ -161,6 +161,26 @@ if test -n "$enable_targets"; then
done
fi
+# Decide which "--hash-style" to use by default
+# Provide a configure time option to override our default.
+AC_ARG_ENABLE([default-hash-style],
+AS_HELP_STRING([--enable-default-hash-style={sysv,gnu,both}],
+ [use this default hash style]),
+[case "${enable_default_hash_style}" in
+ sysv | gnu | both) ;;
+ *) AC_MSG_ERROR([bad value ${enable_default_hash_style} for enable-default-hash-style option]) ;;
+esac],
+[case "${target}" in
+ # Enable gnu hash only on GNU targets, but not mips
+ mips*-*-*) enable_default_hash_style=sysv ;;
+ *-*-gnu* | *-*-linux* | *-*-nacl*) enable_default_hash_style=both ;;
+ *) enable_default_hash_style=sysv ;;
+esac])
+
+AC_DEFINE_UNQUOTED([DEFAULT_HASH_STYLE],
+ ["${enable_default_hash_style}"],
+ [Set the default --hash-style value])
+
# See which specific instantiations we need.
targetobjs=
all_targets=
diff --git a/gold/options.h b/gold/options.h
index a8b1d46..ce21a42 100644
--- a/gold/options.h
+++ b/gold/options.h
@@ -921,7 +921,7 @@ class General_options
N_("Min fraction of empty buckets in dynamic hash"),
N_("FRACTION"));
- DEFINE_enum(hash_style, options::TWO_DASHES, '\0', "sysv",
+ DEFINE_enum(hash_style, options::TWO_DASHES, '\0', DEFAULT_HASH_STYLE,
N_("Dynamic hash style"), N_("[sysv,gnu,both]"),
{"sysv", "gnu", "both"});
diff --git a/ld/ChangeLog b/ld/ChangeLog
index ba7d1d4..cf91d55 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,12 @@
+2017-08-08 Romain Geissler <romain.geissler@gmail.com>
+ Alan Modra <amodra@gmail.com>
+
+ * configure.ac: Add --enable-default-hash-style option.
+ * ldmain.c (main): Set link_info.emit_hash to DEFAULT_EMIT_SYSV_HASH.
+ Set link_info.emit_gnu_hash to DEFAULT_EMIT_GNU_HASH.
+ * configure: Regenerate.
+ * config.in: Regenerate.
+
2017-03-02 Tristan Gingold <gingold@adacore.com>
* configure: Regenerate.
diff --git a/ld/config.in b/ld/config.in
index 2c6d698..b2318e1 100644
--- a/ld/config.in
+++ b/ld/config.in
@@ -7,6 +7,12 @@
#endif
#define __CONFIG_H__ 1
+/* Define to 1 if you want to emit gnu hash in the ELF linker by default. */
+#undef DEFAULT_EMIT_GNU_HASH
+
+/* Define to 1 if you want to emit sysv hash in the ELF linker by default. */
+#undef DEFAULT_EMIT_SYSV_HASH
+
/* Define if you want compressed debug sections by default. */
#undef DEFAULT_FLAG_COMPRESS_DEBUG
diff --git a/ld/configure b/ld/configure
index 36af969..40c67fd 100755
--- a/ld/configure
+++ b/ld/configure
@@ -793,6 +793,7 @@ enable_gold
enable_got
enable_compressed_debug_sections
enable_relro
+enable_default_hash_style
enable_werror
enable_build_warnings
enable_nls
@@ -1452,6 +1453,8 @@ Optional Features:
--enable-compressed-debug-sections={all,ld,none}
compress debug sections by default]
--enable-relro enable -z relro in ELF linker by default
+ --enable-default-hash-style={sysv,gnu,both}
+ use this default hash style
--enable-werror treat compile warnings as errors
--enable-build-warnings enable build-time compiler warnings
--disable-nls do not use Native Language Support
@@ -11724,7 +11727,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 11727 "configure"
+#line 11730 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -11830,7 +11833,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 11833 "configure"
+#line 11836 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -15555,6 +15558,33 @@ if test "${enable_relro+set}" = set; then :
esac
fi
+# Decide which "--hash-style" to use by default
+# Provide a configure time option to override our default.
+# Check whether --enable-default-hash-style was given.
+if test "${enable_default_hash_style+set}" = set; then :
+ enableval=$enable_default_hash_style; case "${enable_default_hash_style}" in
+ sysv | gnu | both) ;;
+ *) as_fn_error "bad value ${enable_default_hash_style} for enable-default-hash-style option" "$LINENO" 5 ;;
+esac
+else
+ case "${target}" in
+ # Enable gnu hash only on GNU targets, but not mips
+ mips*-*-*) enable_default_hash_style=sysv ;;
+ *-*-gnu* | *-*-linux* | *-*-nacl*) enable_default_hash_style=both ;;
+ *) enable_default_hash_style=sysv ;;
+esac
+fi
+
+
+case "${enable_default_hash_style}" in
+ sysv | both) ac_default_emit_sysv_hash=1 ;;
+ *) ac_default_emit_sysv_hash=0 ;;
+esac
+
+case "${enable_default_hash_style}" in
+ gnu | both) ac_default_emit_gnu_hash=1 ;;
+ *) ac_default_emit_gnu_hash=0 ;;
+esac
# Set the 'development' global.
. $srcdir/../bfd/development.sh
@@ -17212,9 +17242,13 @@ cat >>confdefs.h <<_ACEOF
#define DEFAULT_LD_Z_RELRO $ac_default_ld_z_relro
_ACEOF
+cat >>confdefs.h <<_ACEOF
+#define DEFAULT_EMIT_SYSV_HASH $ac_default_emit_sysv_hash
+_ACEOF
-
-
+cat >>confdefs.h <<_ACEOF
+#define DEFAULT_EMIT_GNU_HASH $ac_default_emit_gnu_hash
+_ACEOF
diff --git a/ld/configure.ac b/ld/configure.ac
index 36a9f50..1876ad7 100644
--- a/ld/configure.ac
+++ b/ld/configure.ac
@@ -166,6 +166,32 @@ AC_ARG_ENABLE(relro,
no) ac_default_ld_z_relro=0 ;;
esac])dnl
+# Decide which "--hash-style" to use by default
+# Provide a configure time option to override our default.
+AC_ARG_ENABLE([default-hash-style],
+AS_HELP_STRING([--enable-default-hash-style={sysv,gnu,both}],
+ [use this default hash style]),
+[case "${enable_default_hash_style}" in
+ sysv | gnu | both) ;;
+ *) AC_MSG_ERROR([bad value ${enable_default_hash_style} for enable-default-hash-style option]) ;;
+esac],
+[case "${target}" in
+ # Enable gnu hash only on GNU targets, but not mips
+ mips*-*-*) enable_default_hash_style=sysv ;;
+ *-*-gnu* | *-*-linux* | *-*-nacl*) enable_default_hash_style=both ;;
+ *) enable_default_hash_style=sysv ;;
+esac])
+
+case "${enable_default_hash_style}" in
+ sysv | both) ac_default_emit_sysv_hash=1 ;;
+ *) ac_default_emit_sysv_hash=0 ;;
+esac
+
+case "${enable_default_hash_style}" in
+ gnu | both) ac_default_emit_gnu_hash=1 ;;
+ *) ac_default_emit_gnu_hash=0 ;;
+esac
+
AM_BINUTILS_WARNINGS
AM_LC_MESSAGES
@@ -394,6 +420,14 @@ AC_DEFINE_UNQUOTED(DEFAULT_LD_Z_RELRO,
$ac_default_ld_z_relro,
[Define to 1 if you want to enable -z relro in ELF linker by default.])
+AC_DEFINE_UNQUOTED([DEFAULT_EMIT_SYSV_HASH],
+ [$ac_default_emit_sysv_hash],
+ [Define to 1 if you want to emit sysv hash in the ELF linker by default.])
+
+AC_DEFINE_UNQUOTED([DEFAULT_EMIT_GNU_HASH],
+ [$ac_default_emit_gnu_hash],
+ [Define to 1 if you want to emit gnu hash in the ELF linker by default.])
+
AC_SUBST(elf_list_options)
AC_SUBST(elf_shlib_list_options)
AC_SUBST(elf_plt_unwind_list_options)
diff --git a/ld/ldmain.c b/ld/ldmain.c
index 1e48b1a..579d961 100644
--- a/ld/ldmain.c
+++ b/ld/ldmain.c
@@ -282,7 +282,8 @@ main (int argc, char **argv)
link_info.keep_memory = TRUE;
link_info.combreloc = TRUE;
link_info.strip_discarded = TRUE;
- link_info.emit_hash = TRUE;
+ link_info.emit_hash = DEFAULT_EMIT_SYSV_HASH;
+ link_info.emit_gnu_hash = DEFAULT_EMIT_GNU_HASH;
link_info.callbacks = &link_callbacks;
link_info.input_bfds_tail = &link_info.input_bfds;
/* SVR4 linkers seem to set DT_INIT and DT_FINI based on magic _init
--
2.14.2

View file

@ -4,8 +4,8 @@
pkgname="binutils-x86_64"
pkgver=2.28
pkgrel=3
pkgver=2.30
pkgrel=0
pkgdesc="Tools necessary to build programs for x86_64 targets"
url="https://www.gnu.org/software/binutils/"
depends=""
@ -17,8 +17,6 @@ license="GPL-2.0 GPL-3.0-or-later LGPL-2.0 BSD"
subpackages=""
source="http://ftp.gnu.org/gnu/binutils/binutils-$pkgver.tar.bz2
binutils-ld-fix-static-linking.patch
hash-style-configure-flag.patch
CVE-2017-7614.patch
gold-mips.patch
"
builddir="$srcdir/binutils-$pkgver"
@ -62,8 +60,6 @@ package() {
sha512sums="ede2e4e59a800260eea8c14eafbaee94e30abadafd5c419a3370f9f62213cf027d6400a1d4970b6958bd4d220e675dcd483a708107016e7abd5c99d7392ba8fd binutils-2.28.tar.bz2
sha512sums="c3ce91aa20f058ec589bf18c722bf651331b394db6378900cc813cc0eea3a331a96584d5ae090630b627369510397dccc9edfcd43d4aeefc99579f277a05c72c binutils-2.30.tar.bz2
ecee33b0e435aa704af1c334e560f201638ff79e199aa11ed78a72f7c9b46f85fbb227af5748e735fd681d1965fcc42ac81b0c8824e540430ce0c706c81e8b49 binutils-ld-fix-static-linking.patch
404a483adc8bf8112d953c53a853d21588745752687ee3ca57def539201b9e87844b23ba3c666d7c9648911cdeb55144382c3726ae3845e12b232c3f001c1bfe hash-style-configure-flag.patch
03e2329a216eaaaebc00a2b487a8ffa57657845ea3428f24a1029eabaca2103cb00f39cb4824fe6b70ce9c124e0f850c893746fcf203a6a69288d19df624c60a CVE-2017-7614.patch
f55cf2e0bf82f97583a1abe10710e4013ecf7d64f1da2ef8659a44a06d0dd8beaf58dab98a183488ea137f03e32d62efc878d95f018f836f8cec870bc448556f gold-mips.patch"

View file

@ -1,84 +0,0 @@
From ad32986fdf9da1c8748e47b8b45100398223dba8 Mon Sep 17 00:00:00 2001
From: Nick Clifton <nickc@redhat.com>
Date: Tue, 4 Apr 2017 11:23:36 +0100
Subject: [PATCH] Fix null pointer dereferences when using a link built with
clang.
PR binutils/21342
* elflink.c (_bfd_elf_define_linkage_sym): Prevent null pointer
dereference.
(bfd_elf_final_link): Only initialize the extended symbol index
section if there are extended symbol tables to list.
---
bfd/elflink.c | 35 +++++++++++++++++++++--------------
2 files changed, 29 insertions(+), 14 deletions(-)
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 776357f..9bf75c8 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -119,15 +119,18 @@ _bfd_elf_define_linkage_sym (bfd *abfd,
defined in shared libraries can't be overridden, because we
lose the link to the bfd which is via the symbol section. */
h->root.type = bfd_link_hash_new;
+ bh = &h->root;
}
+ else
+ bh = NULL;
- bh = &h->root;
bed = get_elf_backend_data (abfd);
if (!_bfd_generic_link_add_one_symbol (info, abfd, name, BSF_GLOBAL,
sec, 0, NULL, FALSE, bed->collect,
&bh))
return NULL;
h = (struct elf_link_hash_entry *) bh;
+ BFD_ASSERT (h != NULL);
h->def_regular = 1;
h->non_elf = 0;
h->root.linker_def = 1;
@@ -12038,24 +12041,28 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info)
{
/* Finish up and write out the symbol string table (.strtab)
section. */
- Elf_Internal_Shdr *symstrtab_hdr;
+ Elf_Internal_Shdr *symstrtab_hdr = NULL;
file_ptr off = symtab_hdr->sh_offset + symtab_hdr->sh_size;
- symtab_shndx_hdr = & elf_symtab_shndx_list (abfd)->hdr;
- if (symtab_shndx_hdr != NULL && symtab_shndx_hdr->sh_name != 0)
+ if (elf_symtab_shndx_list (abfd))
{
- symtab_shndx_hdr->sh_type = SHT_SYMTAB_SHNDX;
- symtab_shndx_hdr->sh_entsize = sizeof (Elf_External_Sym_Shndx);
- symtab_shndx_hdr->sh_addralign = sizeof (Elf_External_Sym_Shndx);
- amt = bfd_get_symcount (abfd) * sizeof (Elf_External_Sym_Shndx);
- symtab_shndx_hdr->sh_size = amt;
+ symtab_shndx_hdr = & elf_symtab_shndx_list (abfd)->hdr;
- off = _bfd_elf_assign_file_position_for_section (symtab_shndx_hdr,
- off, TRUE);
+ if (symtab_shndx_hdr != NULL && symtab_shndx_hdr->sh_name != 0)
+ {
+ symtab_shndx_hdr->sh_type = SHT_SYMTAB_SHNDX;
+ symtab_shndx_hdr->sh_entsize = sizeof (Elf_External_Sym_Shndx);
+ symtab_shndx_hdr->sh_addralign = sizeof (Elf_External_Sym_Shndx);
+ amt = bfd_get_symcount (abfd) * sizeof (Elf_External_Sym_Shndx);
+ symtab_shndx_hdr->sh_size = amt;
- if (bfd_seek (abfd, symtab_shndx_hdr->sh_offset, SEEK_SET) != 0
- || (bfd_bwrite (flinfo.symshndxbuf, amt, abfd) != amt))
- return FALSE;
+ off = _bfd_elf_assign_file_position_for_section (symtab_shndx_hdr,
+ off, TRUE);
+
+ if (bfd_seek (abfd, symtab_shndx_hdr->sh_offset, SEEK_SET) != 0
+ || (bfd_bwrite (flinfo.symshndxbuf, amt, abfd) != amt))
+ return FALSE;
+ }
}
symstrtab_hdr = &elf_tdata (abfd)->strtab_hdr;
--
2.9.3

View file

@ -1,348 +0,0 @@
From 2760f24c4942853eac7b921e4b8843d57a602654 Mon Sep 17 00:00:00 2001
From: Romain Geissler <romain.geissler@gmail.com>
Date: Tue, 8 Aug 2017 07:25:39 +0930
Subject: [PATCH] Add configure flag to enable gnu hash style by default.
ld/
* configure.ac: Add --enable-default-hash-style option.
* ldmain.c (main): Set link_info.emit_hash to DEFAULT_EMIT_SYSV_HASH.
Set link_info.emit_gnu_hash to DEFAULT_EMIT_GNU_HASH.
* configure: Regenerate.
* config.in: Regenerate.
gold/
* configure.ac: Add --enable-default-hash-style option.
* options.h (hash_style): Use DEFAULT_HASH_STYLE as default value.
* configure: Regenerate.
* config.in: Regenerate.
---
gold/ChangeLog | 8 ++++++++
gold/config.in | 3 +++
gold/configure | 27 +++++++++++++++++++++++++++
gold/configure.ac | 20 ++++++++++++++++++++
gold/options.h | 2 +-
ld/ChangeLog | 9 +++++++++
ld/config.in | 6 ++++++
ld/configure | 42 ++++++++++++++++++++++++++++++++++++++----
ld/configure.ac | 34 ++++++++++++++++++++++++++++++++++
ld/ldmain.c | 3 ++-
10 files changed, 148 insertions(+), 6 deletions(-)
diff --git a/gold/ChangeLog b/gold/ChangeLog
index d598386..93836dd 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,3 +1,11 @@
+2017-08-08 Romain Geissler <romain.geissler@gmail.com>
+ Alan Modra <amodra@gmail.com>
+
+ * configure.ac: Add --enable-default-hash-style option.
+ * options.h (hash_style): Use DEFAULT_HASH_STYLE as default value.
+ * configure: Regenerate.
+ * config.in: Regenerate.
+
2017-02-22 Alan Modra <amodra@gmail.com>
* powerpc.cc (Target_powerpc::make_iplt_section): Check that
diff --git a/gold/config.in b/gold/config.in
index d9f7b76..5855fca 100644
--- a/gold/config.in
+++ b/gold/config.in
@@ -10,6 +10,9 @@
/* Define if building universal (internal helper macro) */
#undef AC_APPLE_UNIVERSAL_BUILD
+/* Set the default --hash-style value */
+#undef DEFAULT_HASH_STYLE
+
/* Define to 1 if you want to enable -z relro in ELF linker by default. */
#undef DEFAULT_LD_Z_RELRO
diff --git a/gold/configure b/gold/configure
index cb020be..90a706d 100755
--- a/gold/configure
+++ b/gold/configure
@@ -797,6 +797,7 @@ enable_threads
enable_plugins
enable_relro
enable_targets
+enable_default_hash_style
with_lib_path
enable_dependency_tracking
enable_nls
@@ -1447,6 +1448,8 @@ Optional Features:
--enable-plugins linker plugins
--enable-relro enable -z relro in ELF linker by default
--enable-targets alternative target configurations
+ --enable-default-hash-style={sysv,gnu,both}
+ use this default hash style
--disable-dependency-tracking speeds up one-time build
--enable-dependency-tracking do not reject slow dependency extractors
--disable-nls do not use Native Language Support
@@ -3410,6 +3413,30 @@ if test -n "$enable_targets"; then
done
fi
+# Decide which "--hash-style" to use by default
+# Provide a configure time option to override our default.
+# Check whether --enable-default-hash-style was given.
+if test "${enable_default_hash_style+set}" = set; then :
+ enableval=$enable_default_hash_style; case "${enable_default_hash_style}" in
+ sysv | gnu | both) ;;
+ *) as_fn_error "bad value ${enable_default_hash_style} for enable-default-hash-style option" "$LINENO" 5 ;;
+esac
+else
+ case "${target}" in
+ # Enable gnu hash only on GNU targets, but not mips
+ mips*-*-*) enable_default_hash_style=sysv ;;
+ *-*-gnu* | *-*-linux* | *-*-nacl*) enable_default_hash_style=both ;;
+ *) enable_default_hash_style=sysv ;;
+esac
+fi
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define DEFAULT_HASH_STYLE "${enable_default_hash_style}"
+_ACEOF
+
+
# See which specific instantiations we need.
targetobjs=
all_targets=
diff --git a/gold/configure.ac b/gold/configure.ac
index cbe3380..d7fa1f8 100644
--- a/gold/configure.ac
+++ b/gold/configure.ac
@@ -161,6 +161,26 @@ if test -n "$enable_targets"; then
done
fi
+# Decide which "--hash-style" to use by default
+# Provide a configure time option to override our default.
+AC_ARG_ENABLE([default-hash-style],
+AS_HELP_STRING([--enable-default-hash-style={sysv,gnu,both}],
+ [use this default hash style]),
+[case "${enable_default_hash_style}" in
+ sysv | gnu | both) ;;
+ *) AC_MSG_ERROR([bad value ${enable_default_hash_style} for enable-default-hash-style option]) ;;
+esac],
+[case "${target}" in
+ # Enable gnu hash only on GNU targets, but not mips
+ mips*-*-*) enable_default_hash_style=sysv ;;
+ *-*-gnu* | *-*-linux* | *-*-nacl*) enable_default_hash_style=both ;;
+ *) enable_default_hash_style=sysv ;;
+esac])
+
+AC_DEFINE_UNQUOTED([DEFAULT_HASH_STYLE],
+ ["${enable_default_hash_style}"],
+ [Set the default --hash-style value])
+
# See which specific instantiations we need.
targetobjs=
all_targets=
diff --git a/gold/options.h b/gold/options.h
index a8b1d46..ce21a42 100644
--- a/gold/options.h
+++ b/gold/options.h
@@ -921,7 +921,7 @@ class General_options
N_("Min fraction of empty buckets in dynamic hash"),
N_("FRACTION"));
- DEFINE_enum(hash_style, options::TWO_DASHES, '\0', "sysv",
+ DEFINE_enum(hash_style, options::TWO_DASHES, '\0', DEFAULT_HASH_STYLE,
N_("Dynamic hash style"), N_("[sysv,gnu,both]"),
{"sysv", "gnu", "both"});
diff --git a/ld/ChangeLog b/ld/ChangeLog
index ba7d1d4..cf91d55 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,12 @@
+2017-08-08 Romain Geissler <romain.geissler@gmail.com>
+ Alan Modra <amodra@gmail.com>
+
+ * configure.ac: Add --enable-default-hash-style option.
+ * ldmain.c (main): Set link_info.emit_hash to DEFAULT_EMIT_SYSV_HASH.
+ Set link_info.emit_gnu_hash to DEFAULT_EMIT_GNU_HASH.
+ * configure: Regenerate.
+ * config.in: Regenerate.
+
2017-03-02 Tristan Gingold <gingold@adacore.com>
* configure: Regenerate.
diff --git a/ld/config.in b/ld/config.in
index 2c6d698..b2318e1 100644
--- a/ld/config.in
+++ b/ld/config.in
@@ -7,6 +7,12 @@
#endif
#define __CONFIG_H__ 1
+/* Define to 1 if you want to emit gnu hash in the ELF linker by default. */
+#undef DEFAULT_EMIT_GNU_HASH
+
+/* Define to 1 if you want to emit sysv hash in the ELF linker by default. */
+#undef DEFAULT_EMIT_SYSV_HASH
+
/* Define if you want compressed debug sections by default. */
#undef DEFAULT_FLAG_COMPRESS_DEBUG
diff --git a/ld/configure b/ld/configure
index 36af969..40c67fd 100755
--- a/ld/configure
+++ b/ld/configure
@@ -793,6 +793,7 @@ enable_gold
enable_got
enable_compressed_debug_sections
enable_relro
+enable_default_hash_style
enable_werror
enable_build_warnings
enable_nls
@@ -1452,6 +1453,8 @@ Optional Features:
--enable-compressed-debug-sections={all,ld,none}
compress debug sections by default]
--enable-relro enable -z relro in ELF linker by default
+ --enable-default-hash-style={sysv,gnu,both}
+ use this default hash style
--enable-werror treat compile warnings as errors
--enable-build-warnings enable build-time compiler warnings
--disable-nls do not use Native Language Support
@@ -11724,7 +11727,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 11727 "configure"
+#line 11730 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -11830,7 +11833,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 11833 "configure"
+#line 11836 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -15555,6 +15558,33 @@ if test "${enable_relro+set}" = set; then :
esac
fi
+# Decide which "--hash-style" to use by default
+# Provide a configure time option to override our default.
+# Check whether --enable-default-hash-style was given.
+if test "${enable_default_hash_style+set}" = set; then :
+ enableval=$enable_default_hash_style; case "${enable_default_hash_style}" in
+ sysv | gnu | both) ;;
+ *) as_fn_error "bad value ${enable_default_hash_style} for enable-default-hash-style option" "$LINENO" 5 ;;
+esac
+else
+ case "${target}" in
+ # Enable gnu hash only on GNU targets, but not mips
+ mips*-*-*) enable_default_hash_style=sysv ;;
+ *-*-gnu* | *-*-linux* | *-*-nacl*) enable_default_hash_style=both ;;
+ *) enable_default_hash_style=sysv ;;
+esac
+fi
+
+
+case "${enable_default_hash_style}" in
+ sysv | both) ac_default_emit_sysv_hash=1 ;;
+ *) ac_default_emit_sysv_hash=0 ;;
+esac
+
+case "${enable_default_hash_style}" in
+ gnu | both) ac_default_emit_gnu_hash=1 ;;
+ *) ac_default_emit_gnu_hash=0 ;;
+esac
# Set the 'development' global.
. $srcdir/../bfd/development.sh
@@ -17212,9 +17242,13 @@ cat >>confdefs.h <<_ACEOF
#define DEFAULT_LD_Z_RELRO $ac_default_ld_z_relro
_ACEOF
+cat >>confdefs.h <<_ACEOF
+#define DEFAULT_EMIT_SYSV_HASH $ac_default_emit_sysv_hash
+_ACEOF
-
-
+cat >>confdefs.h <<_ACEOF
+#define DEFAULT_EMIT_GNU_HASH $ac_default_emit_gnu_hash
+_ACEOF
diff --git a/ld/configure.ac b/ld/configure.ac
index 36a9f50..1876ad7 100644
--- a/ld/configure.ac
+++ b/ld/configure.ac
@@ -166,6 +166,32 @@ AC_ARG_ENABLE(relro,
no) ac_default_ld_z_relro=0 ;;
esac])dnl
+# Decide which "--hash-style" to use by default
+# Provide a configure time option to override our default.
+AC_ARG_ENABLE([default-hash-style],
+AS_HELP_STRING([--enable-default-hash-style={sysv,gnu,both}],
+ [use this default hash style]),
+[case "${enable_default_hash_style}" in
+ sysv | gnu | both) ;;
+ *) AC_MSG_ERROR([bad value ${enable_default_hash_style} for enable-default-hash-style option]) ;;
+esac],
+[case "${target}" in
+ # Enable gnu hash only on GNU targets, but not mips
+ mips*-*-*) enable_default_hash_style=sysv ;;
+ *-*-gnu* | *-*-linux* | *-*-nacl*) enable_default_hash_style=both ;;
+ *) enable_default_hash_style=sysv ;;
+esac])
+
+case "${enable_default_hash_style}" in
+ sysv | both) ac_default_emit_sysv_hash=1 ;;
+ *) ac_default_emit_sysv_hash=0 ;;
+esac
+
+case "${enable_default_hash_style}" in
+ gnu | both) ac_default_emit_gnu_hash=1 ;;
+ *) ac_default_emit_gnu_hash=0 ;;
+esac
+
AM_BINUTILS_WARNINGS
AM_LC_MESSAGES
@@ -394,6 +420,14 @@ AC_DEFINE_UNQUOTED(DEFAULT_LD_Z_RELRO,
$ac_default_ld_z_relro,
[Define to 1 if you want to enable -z relro in ELF linker by default.])
+AC_DEFINE_UNQUOTED([DEFAULT_EMIT_SYSV_HASH],
+ [$ac_default_emit_sysv_hash],
+ [Define to 1 if you want to emit sysv hash in the ELF linker by default.])
+
+AC_DEFINE_UNQUOTED([DEFAULT_EMIT_GNU_HASH],
+ [$ac_default_emit_gnu_hash],
+ [Define to 1 if you want to emit gnu hash in the ELF linker by default.])
+
AC_SUBST(elf_list_options)
AC_SUBST(elf_shlib_list_options)
AC_SUBST(elf_plt_unwind_list_options)
diff --git a/ld/ldmain.c b/ld/ldmain.c
index 1e48b1a..579d961 100644
--- a/ld/ldmain.c
+++ b/ld/ldmain.c
@@ -282,7 +282,8 @@ main (int argc, char **argv)
link_info.keep_memory = TRUE;
link_info.combreloc = TRUE;
link_info.strip_discarded = TRUE;
- link_info.emit_hash = TRUE;
+ link_info.emit_hash = DEFAULT_EMIT_SYSV_HASH;
+ link_info.emit_gnu_hash = DEFAULT_EMIT_GNU_HASH;
link_info.callbacks = &link_callbacks;
link_info.input_bfds_tail = &link_info.input_bfds;
/* SVR4 linkers seem to set DT_INIT and DT_FINI based on magic _init
--
2.14.2