Merge remote-tracking branch 'upstream/master' into gnu-config-arm

This commit is contained in:
John Ericson
2018-05-14 10:58:15 -04:00
4711 changed files with 136625 additions and 89164 deletions

View File

@@ -1,131 +0,0 @@
{ stdenv, buildPackages
, fetchurl, zlib
, buildPlatform, hostPlatform, targetPlatform
, noSysDirs, gold ? true, bison ? null
}:
let
version = "2.30";
basename = "binutils-${version}";
inherit (stdenv.lib) optional optionals optionalString;
# The targetPrefix prepended to binary names to allow multiple binuntils on the
# PATH to both be usable.
targetPrefix = optionalString (targetPlatform != hostPlatform) "${targetPlatform.config}-";
in
stdenv.mkDerivation rec {
name = targetPrefix + basename;
src = fetchurl {
url = "mirror://gnu/binutils/${basename}.tar.bz2";
sha256 = "028cklfqaab24glva1ks2aqa1zxa6w6xmc8q34zs1sb7h22dxspg";
};
patches = [
# Turn on --enable-new-dtags by default to make the linker set
# RUNPATH instead of RPATH on binaries. This is important because
# RUNPATH can be overriden using LD_LIBRARY_PATH at runtime.
./new-dtags.patch
# Since binutils 2.22, DT_NEEDED flags aren't copied for dynamic outputs.
# That requires upstream changes for things to work. So we can patch it to
# get the old behaviour by now.
./dtneeded.patch
# Make binutils output deterministic by default.
./deterministic.patch
# Always add PaX flags section to ELF files.
# This is needed, for instance, so that running "ldd" on a binary that is
# PaX-marked to disable mprotect doesn't fail with permission denied.
./pt-pax-flags.patch
# Bfd looks in BINDIR/../lib for some plugins that don't
# exist. This is pointless (since users can't install plugins
# there) and causes a cycle between the lib and bin outputs, so
# get rid of it.
./no-plugins.patch
# Help bfd choose between elf32-littlearm, elf32-littlearm-symbian, and
# elf32-littlearm-vxworks in favor of the first.
# https://github.com/NixOS/nixpkgs/pull/30484#issuecomment-345472766
./disambiguate-arm-targets.patch
# For some reason bfd ld doesn't search DT_RPATH when cross-compiling. It's
# not clear why this behavior was decided upon but it has the unfortunate
# consequence that the linker will fail to find transitive dependencies of
# shared objects when cross-compiling. Consequently, we are forced to
# override this behavior, forcing ld to search DT_RPATH even when
# cross-compiling.
./always-search-rpath.patch
];
outputs = [ "out" "info" "man" ];
depsBuildBuild = [ buildPackages.stdenv.cc ];
nativeBuildInputs = [ bison ];
buildInputs = [ zlib ];
inherit noSysDirs;
preConfigure = ''
# Clear the default library search path.
if test "$noSysDirs" = "1"; then
echo 'NATIVE_LIB_DIRS=' >> ld/configure.tgt
fi
# Use symlinks instead of hard links to save space ("strip" in the
# fixup phase strips each hard link separately).
for i in binutils/Makefile.in gas/Makefile.in ld/Makefile.in gold/Makefile.in; do
sed -i "$i" -e 's|ln |ln -s |'
done
'';
# As binutils takes part in the stdenv building, we don't want references
# to the bootstrap-tools libgcc (as uses to happen on arm/mips)
NIX_CFLAGS_COMPILE = if hostPlatform.isDarwin
then "-Wno-string-plus-int -Wno-deprecated-declarations"
else "-static-libgcc";
# TODO(@Ericson2314): Always pass "--target" and always targetPrefix.
configurePlatforms =
# TODO(@Ericson2314): Figure out what's going wrong with Arm
if buildPlatform == hostPlatform && hostPlatform == targetPlatform && targetPlatform.isAarch32
then []
else [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
configureFlags = [
"--enable-targets=all" "--enable-64-bit-bfd"
"--disable-install-libbfd"
"--disable-shared" "--enable-static"
"--with-system-zlib"
"--enable-deterministic-archives"
"--disable-werror"
"--enable-fix-loongson2f-nop"
] ++ optionals gold [ "--enable-gold" "--enable-plugins" ];
enableParallelBuilding = true;
passthru = {
inherit targetPrefix version;
};
meta = with stdenv.lib; {
description = "Tools for manipulating binaries (linker, assembler, etc.)";
longDescription = ''
The GNU Binutils are a collection of binary tools. The main
ones are `ld' (the GNU linker) and `as' (the GNU assembler).
They also include the BFD (Binary File Descriptor) library,
`gprof', `nm', `strip', etc.
'';
homepage = http://www.gnu.org/software/binutils/;
license = licenses.gpl3Plus;
maintainers = with maintainers; [ ericson2314 ];
platforms = platforms.unix;
/* Give binutils a lower priority than gcc-wrapper to prevent a
collision due to the ld/as wrappers/symlinks in the latter. */
priority = 10;
};
}

View File

@@ -1,14 +1,14 @@
{ stdenv, buildPackages
, fetchurl, zlib
, fetchurl, zlib, autoreconfHook264
, buildPlatform, hostPlatform, targetPlatform
, noSysDirs, gold ? true, bison ? null
}:
let
# Note to whoever is upgrading this: 2.29 is broken.
# ('nix-build pkgs/stdenv/linux/make-bootstrap-tools.nix -A test' segfaults on aarch64)
# Also glibc might need patching, see commit 733e20fee4a6700510f71fbe1a58ac23ea202f6a.
version = "2.28.1";
# Remove gold-symbol-visibility patch when updating, the proper fix
# is now upstream.
# https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commitdiff;h=330b90b5ffbbc20c5de6ae6c7f60c40fab2e7a4f;hp=99181ccac0fc7d82e7dabb05dc7466e91f1645d3
version = "2.30";
basename = "binutils-${version}";
inherit (stdenv.lib) optional optionals optionalString;
# The targetPrefix prepended to binary names to allow multiple binuntils on the
@@ -21,7 +21,7 @@ stdenv.mkDerivation rec {
src = fetchurl {
url = "mirror://gnu/binutils/${basename}.tar.bz2";
sha256 = "1sj234nd05cdgga1r36zalvvdkvpfbr12g5mir2n8i1dwsdrj939";
sha256 = "028cklfqaab24glva1ks2aqa1zxa6w6xmc8q34zs1sb7h22dxspg";
};
patches = [
@@ -61,12 +61,25 @@ stdenv.mkDerivation rec {
# override this behavior, forcing ld to search DT_RPATH even when
# cross-compiling.
./always-search-rpath.patch
# https://sourceware.org/bugzilla/show_bug.cgi?id=22868
./gold-symbol-visibility.patch
] ++ stdenv.lib.optional targetPlatform.isiOS ./support-ios.patch
++ stdenv.lib.optionals targetPlatform.isAarch64 [
# Version 2.30 introduced strict requirements on ELF relocations which cannot
# be satisfied on aarch64 platform. Add backported fix from bugzilla.
# https://sourceware.org/bugzilla/show_bug.cgi?id=22764
./relax-R_AARCH64_ABS32-R_AARCH64_ABS16-absolute.patch
];
outputs = [ "out" "info" "man" ];
depsBuildBuild = [ buildPackages.stdenv.cc ];
nativeBuildInputs = [ bison ];
nativeBuildInputs = [
bison
] ++ stdenv.lib.optionals targetPlatform.isiOS [
autoreconfHook264
];
buildInputs = [ zlib ];
inherit noSysDirs;

View File

@@ -0,0 +1,79 @@
commit 8564af037f5c4c6d2744a89497691359205b2bbc
Author: Shea Levy <shea@shealevy.com>
Date: Mon Mar 19 10:52:40 2018 -0400
Revert "Allow multiply-defined absolute symbols when they have the same value."
This reverts commit 5dc824ed42cd173c1525f5abc76f4091f11a4dbc.
diff --git a/gold/ChangeLog-2017 b/gold/ChangeLog-2017
index b2a47710b5..d7ca1b48c0 100644
--- a/gold/ChangeLog-2017
+++ b/gold/ChangeLog-2017
@@ -114,11 +114,6 @@
(localedir): Define as @localedir@.
(gnulocaledir, gettextsrcdir): Use @datarootdir@.
-2017-11-28 Cary Coutant <ccoutant@gmail.com>
-
- * resolve.cc (Symbol_table::resolve): Allow multiply-defined absolute
- symbols when they have the same value.
-
2017-11-28 Cary Coutant <ccoutant@gmail.com>
* object.h (class Sized_relobj_file): Remove discarded_eh_frame_shndx_.
diff --git a/gold/resolve.cc b/gold/resolve.cc
index 4a5784cf8b..803576bfed 100644
--- a/gold/resolve.cc
+++ b/gold/resolve.cc
@@ -247,28 +247,18 @@ Symbol_table::resolve(Sized_symbol<size>* to,
Object* object, const char* version,
bool is_default_version)
{
- bool to_is_ordinary;
- const unsigned int to_shndx = to->shndx(&to_is_ordinary);
-
// It's possible for a symbol to be defined in an object file
// using .symver to give it a version, and for there to also be
// a linker script giving that symbol the same version. We
// don't want to give a multiple-definition error for this
// harmless redefinition.
+ bool to_is_ordinary;
if (to->source() == Symbol::FROM_OBJECT
&& to->object() == object
- && to->is_defined()
&& is_ordinary
+ && to->is_defined()
+ && to->shndx(&to_is_ordinary) == st_shndx
&& to_is_ordinary
- && to_shndx == st_shndx
- && to->value() == sym.get_st_value())
- return;
-
- // Likewise for an absolute symbol defined twice with the same value.
- if (!is_ordinary
- && st_shndx == elfcpp::SHN_ABS
- && !to_is_ordinary
- && to_shndx == elfcpp::SHN_ABS
&& to->value() == sym.get_st_value())
return;
@@ -360,8 +350,8 @@ Symbol_table::resolve(Sized_symbol<size>* to,
&& (sym.get_st_bind() == elfcpp::STB_WEAK
|| to->binding() == elfcpp::STB_WEAK)
&& orig_st_shndx != elfcpp::SHN_UNDEF
+ && to->shndx(&to_is_ordinary) != elfcpp::SHN_UNDEF
&& to_is_ordinary
- && to_shndx != elfcpp::SHN_UNDEF
&& sym.get_st_size() != 0 // Ignore weird 0-sized symbols.
&& to->symsize() != 0
&& (sym.get_st_type() != to->type()
@@ -372,7 +362,7 @@ Symbol_table::resolve(Sized_symbol<size>* to,
{
Symbol_location fromloc
= { object, orig_st_shndx, static_cast<off_t>(sym.get_st_value()) };
- Symbol_location toloc = { to->object(), to_shndx,
+ Symbol_location toloc = { to->object(), to->shndx(&to_is_ordinary),
static_cast<off_t>(to->value()) };
this->candidate_odr_violations_[to->name()].insert(fromloc);
this->candidate_odr_violations_[to->name()].insert(toloc);

View File

@@ -0,0 +1,130 @@
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index c310da6ed3..d31f46171f 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,10 @@
+2018-02-05 Renlin Li <renlin.li@arm.com>
+
+ PR ld/22764
+ * elfnn-aarch64.c (elfNN_aarch64_check_relocs): Relax the
+ R_AARCH64_ABS32 and R_AARCH64_ABS16 for absolute symbol. Apply the
+ check for writeable section as well.
+
2018-01-27 Nick Clifton <nickc@redhat.com>
This is the 2.30 release:
diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c
index d5711e0eb1..973188220b 100644
--- a/bfd/elfnn-aarch64.c
+++ b/bfd/elfnn-aarch64.c
@@ -7074,10 +7074,19 @@ elfNN_aarch64_check_relocs (bfd *abfd, struct bfd_link_info *info,
#if ARCH_SIZE == 64
case BFD_RELOC_AARCH64_32:
#endif
- if (bfd_link_pic (info)
- && (sec->flags & SEC_ALLOC) != 0
- && (sec->flags & SEC_READONLY) != 0)
+ if (bfd_link_pic (info) && (sec->flags & SEC_ALLOC) != 0)
{
+ if (h != NULL
+ /* This is an absolute symbol. It represents a value instead
+ of an address. */
+ && ((h->root.type == bfd_link_hash_defined
+ && bfd_is_abs_section (h->root.u.def.section))
+ /* This is an undefined symbol. */
+ || h->root.type == bfd_link_hash_undefined))
+ break;
+
+ /* For local symbols, defined global symbols in a non-ABS section,
+ it is assumed that the value is an address. */
int howto_index = bfd_r_type - BFD_RELOC_AARCH64_RELOC_START;
_bfd_error_handler
/* xgettext:c-format */
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 6337cd0cb6..1aaa6da3b5 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,11 @@
+2018-02-05 Renlin Li <renlin.li@arm.com>
+
+ PR ld/22764
+ * testsuite/ld-aarch64/emit-relocs-258.s: Define symbol as an address.
+ * testsuite/ld-aarch64/emit-relocs-259.s: Likewise.
+ * testsuite/ld-aarch64/pr22764.s: New.
+ * testsuite/ld-aarch64/pr22764.d: New.
+
2018-01-27 Nick Clifton <nickc@redhat.com>
This is the 2.30 release:
diff --git a/ld/testsuite/ld-aarch64/aarch64-elf.exp b/ld/testsuite/ld-aarch64/aarch64-elf.exp
index f31089361b..d766f3736b 100644
--- a/ld/testsuite/ld-aarch64/aarch64-elf.exp
+++ b/ld/testsuite/ld-aarch64/aarch64-elf.exp
@@ -275,6 +275,7 @@ run_dump_test "pr17415"
run_dump_test_lp64 "tprel_g2_overflow"
run_dump_test "tprel_add_lo12_overflow"
run_dump_test "protected-data"
+run_dump_test_lp64 "pr22764"
# ifunc tests
run_dump_test "ifunc-1"
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-258.s b/ld/testsuite/ld-aarch64/emit-relocs-258.s
index f724776243..87bb657c5d 100644
--- a/ld/testsuite/ld-aarch64/emit-relocs-258.s
+++ b/ld/testsuite/ld-aarch64/emit-relocs-258.s
@@ -1,5 +1,6 @@
+.global dummy
.text
-
+dummy:
ldr x0, .L1
.L1:
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-259.s b/ld/testsuite/ld-aarch64/emit-relocs-259.s
index 7e1ba3ceb4..0977c9d869 100644
--- a/ld/testsuite/ld-aarch64/emit-relocs-259.s
+++ b/ld/testsuite/ld-aarch64/emit-relocs-259.s
@@ -1,5 +1,6 @@
+.global dummy
.text
-
+dummy:
ldr x0, .L1
.L1:
diff --git a/ld/testsuite/ld-aarch64/pr22764.d b/ld/testsuite/ld-aarch64/pr22764.d
new file mode 100644
index 0000000000..997519f469
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/pr22764.d
@@ -0,0 +1,18 @@
+#source: pr22764.s
+#ld: -shared -T relocs.ld -defsym sym_abs1=0x1 -defsym sym_abs2=0x2 -defsym sym_abs3=0x3 -e0 --emit-relocs
+#notarget: aarch64_be-*-*
+#objdump: -dr
+#...
+
+Disassembly of section \.text:
+
+0000000000010000 \<\.text\>:
+ 10000: d503201f nop
+ ...
+ 10004: R_AARCH64_ABS64 sym_abs1
+ 1000c: 00000002 \.word 0x00000002
+ 1000c: R_AARCH64_ABS32 sym_abs2
+ 10010: 0003 \.short 0x0003
+ 10010: R_AARCH64_ABS16 sym_abs3
+ 10012: 0000 \.short 0x0000
+ 10014: d503201f nop
diff --git a/ld/testsuite/ld-aarch64/pr22764.s b/ld/testsuite/ld-aarch64/pr22764.s
new file mode 100644
index 0000000000..25e36b4a12
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/pr22764.s
@@ -0,0 +1,6 @@
+ .text
+ nop
+ .xword sym_abs1
+ .word sym_abs2
+ .short sym_abs3
+ nop

View File

@@ -0,0 +1,112 @@
diff --git a/bfd/config.bfd b/bfd/config.bfd
index f04a993f06..3357022f35 100644
--- a/bfd/config.bfd
+++ b/bfd/config.bfd
@@ -238,7 +238,7 @@ case "${targ}" in
# START OF targmatch.h
#ifdef BFD64
- aarch64-*-darwin*)
+ aarch64-*-darwin* | aarch64-*-ios*)
targ_defvec=aarch64_mach_o_vec
targ_selvecs="arm_mach_o_vec mach_o_le_vec mach_o_be_vec mach_o_fat_vec"
targ_archs="$targ_archs bfd_i386_arch bfd_powerpc_arch bfd_rs6000_arch"
@@ -358,7 +358,7 @@ case "${targ}" in
targ_selvecs=arc_elf32_be_vec
;;
- arm-*-darwin*)
+ arm-*-darwin* | arm-*-ios*)
targ_defvec=arm_mach_o_vec
targ_selvecs="mach_o_le_vec mach_o_be_vec mach_o_fat_vec"
targ_archs="$targ_archs bfd_i386_arch bfd_powerpc_arch bfd_rs6000_arch"
diff --git a/configure.ac b/configure.ac
index aae94501e4..4b1121e0d1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -510,7 +510,7 @@ if test x$enable_libgomp = x ; then
;;
*-*-solaris2* | *-*-hpux11*)
;;
- *-*-darwin* | *-*-aix*)
+ *-*-darwin* | *-*-ios* | *-*-aix*)
;;
nvptx*-*-*)
;;
@@ -706,7 +706,7 @@ case "${target}" in
;;
x86_64-*-darwin[[912]]*)
;;
- *-*-darwin*)
+ *-*-darwin* | *-*-ios*)
noconfigdirs="$noconfigdirs target-libffi"
;;
*-*-netware*)
@@ -788,7 +788,7 @@ esac
# Disable the go frontend on systems where it is known to not work. Please keep
# this in sync with contrib/config-list.mk.
case "${target}" in
-*-*-darwin* | *-*-cygwin* | *-*-mingw*)
+*-*-darwin* | *-*-ios* | *-*-cygwin* | *-*-mingw*)
unsupported_languages="$unsupported_languages go"
;;
esac
@@ -797,7 +797,7 @@ esac
# For testing, you can easily override this with --enable-libgo.
if test x$enable_libgo = x; then
case "${target}" in
- *-*-darwin*)
+ *-*-darwin* | *-*-ios*)
# PR 46986
noconfigdirs="$noconfigdirs target-libgo"
;;
@@ -916,11 +916,11 @@ esac
case "${target}" in
*-*-chorusos)
;;
- aarch64-*-darwin*)
+ aarch64-*-darwin* | aarch64-*-ios*)
noconfigdirs="$noconfigdirs ld gas gdb gprof"
noconfigdirs="$noconfigdirs sim target-rda"
;;
- arm-*-darwin*)
+ arm-*-darwin* | arm-*-ios*)
noconfigdirs="$noconfigdirs ld gas gdb gprof"
noconfigdirs="$noconfigdirs sim target-rda"
;;
@@ -936,7 +936,7 @@ case "${target}" in
noconfigdirs="$noconfigdirs ld gas gprof"
noconfigdirs="$noconfigdirs sim target-rda"
;;
- *-*-darwin*)
+ *-*-darwin* | *-*-ios*)
noconfigdirs="$noconfigdirs ld gas gdb gprof"
noconfigdirs="$noconfigdirs sim target-rda"
;;
@@ -1226,7 +1226,7 @@ case "${host}" in
hppa*-*)
host_makefile_frag="config/mh-pa"
;;
- *-*-darwin*)
+ *-*-darwin* | *-*-ios*)
host_makefile_frag="config/mh-darwin"
;;
powerpc-*-aix*)
@@ -1708,7 +1708,7 @@ ACX_ELF_TARGET_IFELSE([# ELF platforms build the lto-plugin always.
# warn during gcc/ subconfigure; unless you're bootstrapping with
# -flto it won't be needed until after installation anyway.
case $target in
- *-cygwin* | *-mingw* | *-apple-darwin* | *djgpp*) ;;
+ *-cygwin* | *-mingw* | *-apple-darwin* | *-apple-ios* | *djgpp*) ;;
*) if test x"$enable_lto" = x"yes"; then
AC_MSG_ERROR([LTO support is not enabled for this target.])
fi
@@ -2590,7 +2590,7 @@ rm -f conftest*
# Decide which environment variable is used to find dynamic libraries.
case "${host}" in
*-*-hpux*) RPATH_ENVVAR=SHLIB_PATH ;;
- *-*-darwin*) RPATH_ENVVAR=DYLD_LIBRARY_PATH ;;
+ *-*-darwin* | *-*-ios* ) RPATH_ENVVAR=DYLD_LIBRARY_PATH ;;
*-*-mingw* | *-*-cygwin ) RPATH_ENVVAR=PATH ;;
*) RPATH_ENVVAR=LD_LIBRARY_PATH ;;
esac