Merge pull request #134917 from NixOS/binutils-2.37

binutils: 2.35.1 -> 2.38
This commit is contained in:
Bernardo Meurer 2022-03-29 10:16:36 -07:00 committed by GitHub
commit e2d150f6b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 357 additions and 870 deletions

View file

@ -45,7 +45,19 @@ stdenv.mkDerivation rec {
# A strange type of bug: dbus is not immediately found by pkg-config
preConfigure = ''
export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE $(pkg-config dbus-1 --cflags)"
# binutils 2.37 fix
# https://github.com/afterstep/afterstep/issues/2
fixupList=(
"autoconf/Makefile.defines.in"
"libAfterImage/aftershow/Makefile.in"
"libAfterImage/apps/Makefile.in"
"libAfterBase/Makefile.in"
"libAfterImage/Makefile.in"
)
for toFix in "''${fixupList[@]}"; do
substituteInPlace "$toFix" --replace "clq" "cq"
done
export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE $(pkg-config dbus-1 --cflags)"
'';
# Parallel build fails due to missing dependencies between private libaries:

View file

@ -56,6 +56,19 @@ in stdenv.mkDerivation rec {
"LOCALE_ARCHIVE=${glibcLocales}/lib/locale/locale-archive"
];
preConfigure = ''
# binutils 2.37 fix
fixupList=(
"config/cf/Imake.tmpl"
"config/util/crayar.sh"
"config/util/crayar.sh"
"programs/dtwm/Makefile.tmpl"
)
for toFix in "''${fixupList[@]}"; do
substituteInPlace "$toFix" --replace "clq" "cq"
done
'';
preBuild = ''
while IFS= read -r -d ''$'\0' i; do
substituteInPlace "$i" --replace /usr/dt $out/opt/dt

View file

@ -0,0 +1,137 @@
From beca4a2c25ee86e4020f8b8bddc4d8e0ed3430b3 Mon Sep 17 00:00:00 2001
From: Andrew Childs <andrew.childs@bibo.com.ph>
Date: Tue, 22 Feb 2022 11:28:04 +0900
Subject: [PATCH] Revert "libtool.m4: fix nm BSD flag detection"
This reverts commit bef9ef8ca0f941d743c77cc55b5fe7985990b2a7.
---
ChangeLog | 9 ------
libtool.m4 | 88 ++++++++++++++++++++++++++----------------------------
2 files changed, 43 insertions(+), 54 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 18e8b6835da..c12f07403c3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -375,15 +375,6 @@
* src-release.sh (GDB_SUPPPORT_DIRS): Add libbacktrace.
-2021-09-27 Nick Alcock <nick.alcock@oracle.com>
-
- PR libctf/27967
- * libtool.m4 (LT_PATH_NM): Try BSDization flags with a user-provided
- NM, if there is one. Run nm on itself, not on /dev/null, to avoid
- errors from nms that refuse to work on non-regular files. Remove
- other workarounds for this problem. Strip out blank lines from the
- nm output.
-
2021-09-27 Nick Alcock <nick.alcock@oracle.com>
PR libctf/27967
diff --git a/libtool.m4 b/libtool.m4
index a216bb14e99..7a711249304 100644
--- a/libtool.m4
+++ b/libtool.m4
@@ -3200,55 +3200,53 @@ _LT_DECL([], [file_magic_cmd], [1],
# LT_PATH_NM
# ----------
-# find the pathname to a BSD- or MS-compatible name lister, and any flags
-# needed to make it compatible
+# find the pathname to a BSD- or MS-compatible name lister
AC_DEFUN([LT_PATH_NM],
[AC_REQUIRE([AC_PROG_CC])dnl
AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM,
[if test -n "$NM"; then
- # Let the user override the nm to test.
- lt_nm_to_check="$NM"
- else
- lt_nm_to_check="${ac_tool_prefix}nm"
- if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
- lt_nm_to_check="$lt_nm_to_check nm"
- fi
- fi
- for lt_tmp_nm in $lt_nm_to_check; do
- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
- for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
- IFS="$lt_save_ifs"
- test -z "$ac_dir" && ac_dir=.
- case "$lt_tmp_nm" in
- */*|*\\*) tmp_nm="$lt_tmp_nm";;
- *) tmp_nm="$ac_dir/$lt_tmp_nm";;
- esac
- if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
- # Check to see if the nm accepts a BSD-compat flag.
- # Adding the `sed 1q' prevents false positives on HP-UX, which says:
- # nm: unknown option "B" ignored
- case `"$tmp_nm" -B "$tmp_nm" 2>&1 | grep -v '^ *$' | sed '1q'` in
- *$tmp_nm*) lt_cv_path_NM="$tmp_nm -B"
- break
- ;;
- *)
- case `"$tmp_nm" -p "$tmp_nm" 2>&1 | grep -v '^ *$' | sed '1q'` in
- *$tmp_nm*)
- lt_cv_path_NM="$tmp_nm -p"
- break
- ;;
- *)
- lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
- continue # so that we can try to find one that supports BSD flags
- ;;
- esac
- ;;
- esac
- fi
- done
- IFS="$lt_save_ifs"
- done
- : ${lt_cv_path_NM=no}])
+ # Let the user override the test.
+ lt_cv_path_NM="$NM"
+else
+ lt_nm_to_check="${ac_tool_prefix}nm"
+ if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
+ lt_nm_to_check="$lt_nm_to_check nm"
+ fi
+ for lt_tmp_nm in $lt_nm_to_check; do
+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+ for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
+ IFS="$lt_save_ifs"
+ test -z "$ac_dir" && ac_dir=.
+ tmp_nm="$ac_dir/$lt_tmp_nm"
+ if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+ # Check to see if the nm accepts a BSD-compat flag.
+ # Adding the `sed 1q' prevents false positives on HP-UX, which says:
+ # nm: unknown option "B" ignored
+ # Tru64's nm complains that /dev/null is an invalid object file
+ case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
+ */dev/null* | *'Invalid file or object type'*)
+ lt_cv_path_NM="$tmp_nm -B"
+ break
+ ;;
+ *)
+ case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
+ */dev/null*)
+ lt_cv_path_NM="$tmp_nm -p"
+ break
+ ;;
+ *)
+ lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
+ continue # so that we can try to find one that supports BSD flags
+ ;;
+ esac
+ ;;
+ esac
+ fi
+ done
+ IFS="$lt_save_ifs"
+ done
+ : ${lt_cv_path_NM=no}
+fi])
if test "$lt_cv_path_NM" != "no"; then
NM="$lt_cv_path_NM"
else
--
2.34.1

View file

@ -0,0 +1,47 @@
From 33a8dc728eb5da3e1d3439c96810d1f6b2660b89 Mon Sep 17 00:00:00 2001
From: Andrew Childs <andrew.childs@bibo.com.ph>
Date: Tue, 22 Feb 2022 12:24:46 +0900
Subject: [PATCH] libtool.m4: update macos version detection block
Includes upstream change
9e8c882517082fe5755f2524d23efb02f1522490
---
libtool.m4 | 21 ++++++++-------------
1 file changed, 8 insertions(+), 13 deletions(-)
diff --git a/libtool.m4 b/libtool.m4
index 7a711249304..f452efb4300 100644
--- a/libtool.m4
+++ b/libtool.m4
@@ -996,20 +996,15 @@ _LT_EOF
])
case $host_os in
rhapsody* | darwin1.[[012]])
- _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
+ _lt_dar_allow_undefined='$wl-undefined ${wl}suppress' ;;
darwin1.*)
- _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
- darwin*) # darwin 5.x on
- # if running on 10.5 or later, the deployment target defaults
- # to the OS version, if on x86, and 10.4, the deployment
- # target defaults to 10.4. Don't you love it?
- case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
- 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*)
- _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
- 10.[[012]][[,.]]*)
- _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
- 10.*)
- _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+ _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;;
+ darwin*)
+ case $MACOSX_DEPLOYMENT_TARGET,$host in
+ 10.[[012]],*|,*powerpc*-darwin[[5-8]]*)
+ _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;;
+ *)
+ _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;;
esac
;;
esac
--
2.34.1

View file

@ -1,77 +0,0 @@
From 8642dafaef21aa6747cec01df1977e9c52eb4679 Mon Sep 17 00:00:00 2001
From: Alan Modra <amodra@gmail.com>
Date: Fri, 4 Sep 2020 19:19:18 +0930
Subject: [PATCH] PR26574, heap buffer overflow in
_bfd_elf_slurp_secondary_reloc_section
A horribly fuzzed object with section headers inside the ELF header.
Disallow that, and crazy reloc sizes.
PR 26574
* elfcode.h (elf_object_p): Sanity check section header offset.
* elf.c (_bfd_elf_slurp_secondary_reloc_section): Sanity check
sh_entsize.
---
bfd/elf.c | 4 +++-
bfd/elfcode.h | 8 ++++----
3 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/bfd/elf.c b/bfd/elf.c
index ac2095f787d..5a02f8dc309 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -12576,7 +12576,9 @@ _bfd_elf_slurp_secondary_reloc_section (bfd * abfd,
Elf_Internal_Shdr * hdr = & elf_section_data (relsec)->this_hdr;
if (hdr->sh_type == SHT_SECONDARY_RELOC
- && hdr->sh_info == (unsigned) elf_section_data (sec)->this_idx)
+ && hdr->sh_info == (unsigned) elf_section_data (sec)->this_idx
+ && (hdr->sh_entsize == ebd->s->sizeof_rel
+ || hdr->sh_entsize == ebd->s->sizeof_rela))
{
bfd_byte * native_relocs;
bfd_byte * native_reloc;
diff --git a/bfd/elfcode.h b/bfd/elfcode.h
index 2ed2f135c34..606ff64fd4d 100644
--- a/bfd/elfcode.h
+++ b/bfd/elfcode.h
@@ -571,7 +571,7 @@ elf_object_p (bfd *abfd)
/* If this is a relocatable file and there is no section header
table, then we're hosed. */
- if (i_ehdrp->e_shoff == 0 && i_ehdrp->e_type == ET_REL)
+ if (i_ehdrp->e_shoff < sizeof (x_ehdr) && i_ehdrp->e_type == ET_REL)
goto got_wrong_format_error;
/* As a simple sanity check, verify that what BFD thinks is the
@@ -581,7 +581,7 @@ elf_object_p (bfd *abfd)
goto got_wrong_format_error;
/* Further sanity check. */
- if (i_ehdrp->e_shoff == 0 && i_ehdrp->e_shnum != 0)
+ if (i_ehdrp->e_shoff < sizeof (x_ehdr) && i_ehdrp->e_shnum != 0)
goto got_wrong_format_error;
ebd = get_elf_backend_data (abfd);
@@ -618,7 +618,7 @@ elf_object_p (bfd *abfd)
&& ebd->elf_osabi != ELFOSABI_NONE)
goto got_wrong_format_error;
- if (i_ehdrp->e_shoff != 0)
+ if (i_ehdrp->e_shoff >= sizeof (x_ehdr))
{
file_ptr where = (file_ptr) i_ehdrp->e_shoff;
@@ -819,7 +819,7 @@ elf_object_p (bfd *abfd)
}
}
- if (i_ehdrp->e_shstrndx != 0 && i_ehdrp->e_shoff != 0)
+ if (i_ehdrp->e_shstrndx != 0 && i_ehdrp->e_shoff >= sizeof (x_ehdr))
{
unsigned int num_sec;
--
2.27.0

View file

@ -1,73 +0,0 @@
From: Nick Clifton <nickc@redhat.com>
Date: Thu, 26 Nov 2020 17:08:33 +0000 (+0000)
Subject: Prevent a memory allocation failure when parsing corrupt DWARF debug sections.
X-Git-Tag: binutils-2_36~485
X-Git-Url: https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff_plain;h=647cebce12a6b0a26960220caff96ff38978cf24;hp=239ca5e497dda2c151009d664d500086a5c2173a
Prevent a memory allocation failure when parsing corrupt DWARF debug sections.
PR 26946
* dwarf2.c (read_section): Check for debug sections with excessive
sizes.
---
diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c
index 977bf43a6a1..8bbfc81d3e7 100644
--- a/bfd/dwarf2.c
+++ b/bfd/dwarf2.c
@@ -531,22 +531,24 @@ read_section (bfd * abfd,
bfd_byte ** section_buffer,
bfd_size_type * section_size)
{
- asection *msec;
const char *section_name = sec->uncompressed_name;
bfd_byte *contents = *section_buffer;
- bfd_size_type amt;
/* The section may have already been read. */
if (contents == NULL)
{
+ bfd_size_type amt;
+ asection *msec;
+ ufile_ptr filesize;
+
msec = bfd_get_section_by_name (abfd, section_name);
- if (! msec)
+ if (msec == NULL)
{
section_name = sec->compressed_name;
if (section_name != NULL)
msec = bfd_get_section_by_name (abfd, section_name);
}
- if (! msec)
+ if (msec == NULL)
{
_bfd_error_handler (_("DWARF error: can't find %s section."),
sec->uncompressed_name);
@@ -554,12 +556,23 @@ read_section (bfd * abfd,
return FALSE;
}
- *section_size = msec->rawsize ? msec->rawsize : msec->size;
+ amt = bfd_get_section_limit_octets (abfd, msec);
+ filesize = bfd_get_file_size (abfd);
+ if (amt >= filesize)
+ {
+ /* PR 26946 */
+ _bfd_error_handler (_("DWARF error: section %s is larger than its filesize! (0x%lx vs 0x%lx)"),
+ section_name, (long) amt, (long) filesize);
+ bfd_set_error (bfd_error_bad_value);
+ return FALSE;
+ }
+ *section_size = amt;
/* Paranoia - alloc one extra so that we can make sure a string
section is NUL terminated. */
- amt = *section_size + 1;
+ amt += 1;
if (amt == 0)
{
+ /* Paranoia - this should never happen. */
bfd_set_error (bfd_error_no_memory);
return FALSE;
}

View file

@ -1,239 +0,0 @@
based on upstream https://sourceware.org/git/?p=binutils-gdb.git;a=patch;h=161e87d12167b1e36193385485c1f6ce92f74f02;hp=d5c94731766bf4f276146fd29c1df8eebc2aaf69
adapted by ris to apply to 2.35.2 (simply capitalizing booleans)
diff --git a/binutils/stabs.c b/binutils/stabs.c
index 274bfb0e7fa..83ee3ea5fa4 100644
--- a/binutils/stabs.c
+++ b/binutils/stabs.c
@@ -202,7 +202,7 @@ static debug_type stab_find_type (void *, struct stab_handle *, const int *);
static bool stab_record_type
(void *, struct stab_handle *, const int *, debug_type);
static debug_type stab_xcoff_builtin_type
- (void *, struct stab_handle *, int);
+ (void *, struct stab_handle *, unsigned int);
static debug_type stab_find_tagged_type
(void *, struct stab_handle *, const char *, int, enum debug_type_kind);
static debug_type *stab_demangle_argtypes
@@ -3496,166 +3496,167 @@ stab_record_type (void *dhandle ATTRIBUTE_UNUSED, struct stab_handle *info,
static debug_type
stab_xcoff_builtin_type (void *dhandle, struct stab_handle *info,
- int typenum)
+ unsigned int typenum)
{
debug_type rettype;
const char *name;
- if (typenum >= 0 || typenum < -XCOFF_TYPE_COUNT)
+ typenum = -typenum - 1;
+ if (typenum >= XCOFF_TYPE_COUNT)
{
- fprintf (stderr, _("Unrecognized XCOFF type %d\n"), typenum);
+ fprintf (stderr, _("Unrecognized XCOFF type %d\n"), -typenum - 1);
return DEBUG_TYPE_NULL;
}
- if (info->xcoff_types[-typenum] != NULL)
- return info->xcoff_types[-typenum];
+ if (info->xcoff_types[typenum] != NULL)
+ return info->xcoff_types[typenum];
- switch (-typenum)
+ switch (typenum)
{
- case 1:
+ case 0:
/* The size of this and all the other types are fixed, defined
by the debugging format. */
name = "int";
rettype = debug_make_int_type (dhandle, 4, FALSE);
break;
- case 2:
+ case 1:
name = "char";
rettype = debug_make_int_type (dhandle, 1, FALSE);
break;
- case 3:
+ case 2:
name = "short";
rettype = debug_make_int_type (dhandle, 2, FALSE);
break;
- case 4:
+ case 3:
name = "long";
rettype = debug_make_int_type (dhandle, 4, FALSE);
break;
- case 5:
+ case 4:
name = "unsigned char";
rettype = debug_make_int_type (dhandle, 1, TRUE);
break;
- case 6:
+ case 5:
name = "signed char";
rettype = debug_make_int_type (dhandle, 1, FALSE);
break;
- case 7:
+ case 6:
name = "unsigned short";
rettype = debug_make_int_type (dhandle, 2, TRUE);
break;
- case 8:
+ case 7:
name = "unsigned int";
rettype = debug_make_int_type (dhandle, 4, TRUE);
break;
- case 9:
+ case 8:
name = "unsigned";
rettype = debug_make_int_type (dhandle, 4, TRUE);
break;
- case 10:
+ case 9:
name = "unsigned long";
rettype = debug_make_int_type (dhandle, 4, TRUE);
break;
- case 11:
+ case 10:
name = "void";
rettype = debug_make_void_type (dhandle);
break;
- case 12:
+ case 11:
/* IEEE single precision (32 bit). */
name = "float";
rettype = debug_make_float_type (dhandle, 4);
break;
- case 13:
+ case 12:
/* IEEE double precision (64 bit). */
name = "double";
rettype = debug_make_float_type (dhandle, 8);
break;
- case 14:
+ case 13:
/* This is an IEEE double on the RS/6000, and different machines
with different sizes for "long double" should use different
negative type numbers. See stabs.texinfo. */
name = "long double";
rettype = debug_make_float_type (dhandle, 8);
break;
- case 15:
+ case 14:
name = "integer";
rettype = debug_make_int_type (dhandle, 4, FALSE);
break;
- case 16:
+ case 15:
name = "boolean";
rettype = debug_make_bool_type (dhandle, 4);
break;
- case 17:
+ case 16:
name = "short real";
rettype = debug_make_float_type (dhandle, 4);
break;
- case 18:
+ case 17:
name = "real";
rettype = debug_make_float_type (dhandle, 8);
break;
- case 19:
+ case 18:
/* FIXME */
name = "stringptr";
rettype = NULL;
break;
- case 20:
+ case 19:
/* FIXME */
name = "character";
rettype = debug_make_int_type (dhandle, 1, TRUE);
break;
- case 21:
+ case 20:
name = "logical*1";
rettype = debug_make_bool_type (dhandle, 1);
break;
- case 22:
+ case 21:
name = "logical*2";
rettype = debug_make_bool_type (dhandle, 2);
break;
- case 23:
+ case 22:
name = "logical*4";
rettype = debug_make_bool_type (dhandle, 4);
break;
- case 24:
+ case 23:
name = "logical";
rettype = debug_make_bool_type (dhandle, 4);
break;
- case 25:
+ case 24:
/* Complex type consisting of two IEEE single precision values. */
name = "complex";
rettype = debug_make_complex_type (dhandle, 8);
break;
- case 26:
+ case 25:
/* Complex type consisting of two IEEE double precision values. */
name = "double complex";
rettype = debug_make_complex_type (dhandle, 16);
break;
- case 27:
+ case 26:
name = "integer*1";
rettype = debug_make_int_type (dhandle, 1, FALSE);
break;
- case 28:
+ case 27:
name = "integer*2";
rettype = debug_make_int_type (dhandle, 2, FALSE);
break;
- case 29:
+ case 28:
name = "integer*4";
rettype = debug_make_int_type (dhandle, 4, FALSE);
break;
- case 30:
+ case 29:
/* FIXME */
name = "wchar";
rettype = debug_make_int_type (dhandle, 2, FALSE);
break;
- case 31:
+ case 30:
name = "long long";
rettype = debug_make_int_type (dhandle, 8, FALSE);
break;
- case 32:
+ case 31:
name = "unsigned long long";
rettype = debug_make_int_type (dhandle, 8, TRUE);
break;
- case 33:
+ case 32:
name = "logical*8";
rettype = debug_make_bool_type (dhandle, 8);
break;
- case 34:
+ case 33:
name = "integer*8";
rettype = debug_make_int_type (dhandle, 8, FALSE);
break;
@@ -3664,9 +3665,7 @@ stab_xcoff_builtin_type (void *dhandle, struct stab_handle *info,
}
rettype = debug_name_type (dhandle, name, rettype);
-
- info->xcoff_types[-typenum] = rettype;
-
+ info->xcoff_types[typenum] = rettype;
return rettype;
}
--
2.27.0

View file

@ -1,26 +0,0 @@
X-Git-Url: https://sourceware.org/git/?p=binutils-gdb.git;a=blobdiff_plain;f=bfd%2Felf.c;h=af62aadc3d446cd5b1f0201b207c90c22e7809b1;hp=36733e080dd9d9be28b576b246aaf5bd8c8569c7;hb=84fd26d8209e99fc3a432dd0b09b6c053de1ce65;hpb=abe2a28aaa7a2bfd0f3061c72a98eb898976b721
diff --git a/bfd/elf.c b/bfd/elf.c
index 36733e080dd..af62aadc3d4 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -2454,6 +2454,8 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
"for section %pA found - ignoring"),
abfd, name, target_sect);
}
+ else
+ esdt->has_secondary_relocs = TRUE;
goto success;
}
@@ -12587,6 +12589,9 @@ _bfd_elf_slurp_secondary_reloc_section (bfd * abfd,
#endif
r_sym = elf32_r_sym;
+ if (!elf_section_data (sec)->has_secondary_relocs)
+ return TRUE;
+
/* Discover if there are any secondary reloc sections
associated with SEC. */
for (relsec = abfd->sections; relsec != NULL; relsec = relsec->next)

View file

@ -1,8 +1,8 @@
diff --git a/bfd/configure.ac b/bfd/configure.ac
index c5bfbd5d..45ad4c26 100644
index fec067b2135..377e1f5443f 100644
--- a/bfd/configure.ac
+++ b/bfd/configure.ac
@@ -278,31 +278,19 @@ AC_CACHE_CHECK(linker --as-needed support, bfd_cv_ld_as_needed,
@@ -292,30 +292,16 @@ AC_CACHE_CHECK(linker --as-needed support, bfd_cv_ld_as_needed,
LT_LIB_M
@ -21,24 +21,22 @@ index c5bfbd5d..45ad4c26 100644
- if test -n "$x"; then
- SHARED_LIBADD="-L`pwd`/../libiberty/pic -liberty"
- fi
-fi
-
SHARED_LIBADD="$SHARED_LIBADD $LIBINTL"
-if test "$enable_shared" = "yes"; then
case "${host}" in
# More hacks to build DLLs on Windows.
*-*-cygwin*)
SHARED_LDFLAGS="-no-undefined"
- SHARED_LIBADD="-L`pwd`/../libiberty -liberty -L`pwd`/../intl -lintl -lcygwin -lkernel32"
+ SHARED_LIBADD="-liberty -lintl -lcygwin -lkernel32"
;;
# Use built-in libintl on macOS, since it is not provided by libc.
*-*-darwin*)
- SHARED_LIBADD="-L`pwd`/../libiberty/pic -L`pwd`/../intl -liberty -lintl"
+ SHARED_LIBADD="-liberty -lintl"
- SHARED_LIBADD="-L`pwd`/../libiberty -liberty $SHARED_LIBADD -lcygwin -lkernel32"
+ SHARED_LIBADD="-liberty $SHARED_LIBADD -lcygwin -lkernel32"
;;
esac
diff --git a/opcodes/Makefile.am b/opcodes/Makefile.am
index 4f06074a..6836c589 100644
index 0e04b4c05c4..848a02662e7 100644
--- a/opcodes/Makefile.am
+++ b/opcodes/Makefile.am
@@ -51,7 +51,7 @@ libopcodes_la_LDFLAGS += -rpath $(rpath_bfdlibdir)
@ -50,7 +48,7 @@ index 4f06074a..6836c589 100644
BUILD_LIBS = @BUILD_LIBS@
BUILD_LIB_DEPS = @BUILD_LIB_DEPS@
@@ -301,7 +301,7 @@ OFILES = @BFD_MACHINES@
@@ -303,7 +303,7 @@ OFILES = @BFD_MACHINES@
# development.sh is used to determine -Werror default.
CONFIG_STATUS_DEPENDENCIES = $(BFDDIR)/development.sh
@ -59,10 +57,7 @@ index 4f06074a..6836c589 100644
disassemble.lo: disassemble.c
if am__fastdepCC
@@ -322,12 +322,21 @@ libopcodes_la_SOURCES = dis-buf.c disassemble.c dis-init.c
# old version of libbfd, or to pick up libbfd for the wrong architecture
# if host != build. So for building with shared libraries we use a
# hardcoded path to libbfd.so instead of relying on the entries in libbfd.la.
@@ -327,9 +327,18 @@ libopcodes_la_SOURCES = dis-buf.c disassemble.c dis-init.c
-libopcodes_la_DEPENDENCIES = $(OFILES) @SHARED_DEPENDENCIES@
+libopcodes_la_DEPENDENCIES = $(OFILES) @SHARED_DEPENDENCIES@ libtool-soversion
libopcodes_la_LIBADD = $(OFILES) @SHARED_LIBADD@
@ -84,18 +79,19 @@ index 4f06074a..6836c589 100644
# the build directory so that we don't have to convert all the
# programs that use libopcodes.a simultaneously. This is a hack which
diff --git a/opcodes/configure.ac b/opcodes/configure.ac
index 00be9c88..6e589ae4 100644
index e564f067334..5da62a3d58b 100644
--- a/opcodes/configure.ac
+++ b/opcodes/configure.ac
@@ -86,6 +86,7 @@ AC_PROG_INSTALL
@@ -98,6 +98,8 @@ BFD_64_BIT
AC_SUBST(HDEFINES)
AC_PROG_INSTALL
AC_CHECK_HEADERS(string.h strings.h stdlib.h limits.h)
ACX_HEADER_STRING
+GCC_HEADER_STDINT(bfd_stdint.h)
+
AC_CHECK_DECLS([basename, stpcpy])
@@ -137,61 +138,27 @@ AC_CACHE_CHECK(linker --as-needed support, bfd_cv_ld_as_needed,
# Check if sigsetjmp is available. Using AC_CHECK_FUNCS won't do
@@ -148,44 +150,21 @@ AC_CACHE_CHECK(linker --as-needed support, bfd_cv_ld_as_needed,
LT_LIB_M
@ -122,7 +118,7 @@ index 00be9c88..6e589ae4 100644
-SHARED_LIBADD=
+SHARED_LIBADD=-liberty
SHARED_DEPENDENCIES=
if test "$enable_shared" = "yes"; then
-if test "$enable_shared" = "yes"; then
-# When building a shared libopcodes, link against the pic version of libiberty
-# so that apps that use libopcodes won't need libiberty just to satisfy any
-# libopcodes references.
@ -131,32 +127,27 @@ index 00be9c88..6e589ae4 100644
# Note that linking against libbfd as we do here, which is itself linked
# against libiberty, may not satisfy all the libopcodes libiberty references
# since libbfd may not pull in the entirety of libiberty.
# Also, jam libintl into the right place in all of this: after libiberty,
# which uses it, but before -lcygwin, which it uses.
-changequote(,)dnl
- x=`sed -n -e 's/^[ ]*PICFLAG[ ]*=[ ]*//p' < ../libiberty/Makefile | sed -n '$p'`
-changequote([,])dnl
- if test -n "$x"; then
- SHARED_LIBADD="-L`pwd`/../libiberty/pic -liberty"
- fi
-
-fi
SHARED_LIBADD="$SHARED_LIBADD $LIBINTL"
@@ -193,11 +172,10 @@ if test "$enable_shared" = "yes"; then
case "${host}" in
*-*-cygwin*)
SHARED_LDFLAGS="-no-undefined"
- SHARED_LIBADD="-L`pwd`/../bfd -lbfd -L`pwd`/../libiberty -liberty -L`pwd`/../intl -lintl -lcygwin"
+ SHARED_LIBADD="-lbfd -liberty -lintl -lcygwin"
- SHARED_LIBADD="-L`pwd`/../bfd -lbfd -L`pwd`/../libiberty -liberty $SHARED_LIBADD"
+ SHARED_LIBADD="-lbfd -liberty $SHARED_LIBADD"
;;
- *-*-darwin*)
- SHARED_LIBADD="-Wl,`pwd`/../bfd/.libs/libbfd.dylib ${SHARED_LIBADD}"
- SHARED_DEPENDENCIES="../bfd/libbfd.la"
- ;;
*)
- case "$host_vendor" in
- hp)
- SHARED_LIBADD="-Wl,`pwd`/../bfd/.libs/libbfd.sl ${SHARED_LIBADD}"
- ;;
- *)
- SHARED_LIBADD="-Wl,`pwd`/../bfd/.libs/libbfd.so ${SHARED_LIBADD}"
- ;;
- esac
- SHARED_LIBADD="../bfd/libbfd.la ${SHARED_LIBADD}"
- SHARED_DEPENDENCIES="../bfd/libbfd.la"
+ SHARED_LIBADD="-lbfd ${SHARED_LIBADD}"
;;

View file

@ -2,64 +2,77 @@ let
execFormatIsELF = platform: platform.parsed.kernel.execFormat.name == "elf";
in
{ stdenv, lib, buildPackages
, fetchFromGitHub, fetchurl, zlib, autoreconfHook, gettext
# Enabling all targets increases output size to a multiple.
, withAllTargets ? false, libbfd, libopcodes
, enableShared ? !stdenv.hostPlatform.isStatic
, noSysDirs
, gold ? execFormatIsELF stdenv.targetPlatform
, bison ? null
{ stdenv
, autoreconfHook
, autoconf269, automake, libtool
, bison
, buildPackages
, fetchFromGitHub
, fetchurl
, flex
, texinfo
, gettext
, lib
, noSysDirs
, perl
, texinfo
, zlib
, enableGold ? execFormatIsELF stdenv.targetPlatform
, enableShared ? !stdenv.hostPlatform.isStatic
# WARN: Enabling all targets increases output size to a multiple.
, withAllTargets ? false, libbfd, libopcodes
}:
# configure silently disables ld.gold if it's unsupported,
# so we need to make sure that intent matches result ourselves.
assert gold -> execFormatIsELF stdenv.targetPlatform;
# WARN: configure silently disables ld.gold if it's unsupported, so we need to
# make sure that intent matches result ourselves.
assert enableGold -> execFormatIsELF stdenv.targetPlatform;
# Note: this package is used for bootstrapping fetchurl, and thus
# cannot use fetchpatch! All mutable patches (generated by GitHub or
# cgit) that are needed here should be included directly in Nixpkgs as
# files.
let
reuseLibs = enableShared && withAllTargets;
inherit (stdenv) buildPlatform hostPlatform targetPlatform;
version = "2.35.2";
basename = "binutils";
# The targetPrefix prepended to binary names to allow multiple binuntils on the
# PATH to both be usable.
targetPrefix = lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
"${stdenv.targetPlatform.config}-";
vc4-binutils-src = fetchFromGitHub {
owner = "itszor";
repo = "binutils-vc4";
rev = "708acc851880dbeda1dd18aca4fd0a95b2573b36";
sha256 = "1kdrz6fki55lm15rwwamn74fnqpy0zlafsida2zymk76n3656c63";
version = "2.38";
srcs = {
normal = fetchurl {
url = "mirror://gnu/binutils/binutils-${version}.tar.bz2";
sha256 = "sha256-Bw7HHPB3pqWOC5WfBaCaNQFTeMLYpR6Q866r/jBZDvg=";
};
vc4-none = fetchFromGitHub {
owner = "itszor";
repo = "binutils-vc4";
rev = "708acc851880dbeda1dd18aca4fd0a95b2573b36";
sha256 = "1kdrz6fki55lm15rwwamn74fnqpy0zlafsida2zymk76n3656c63";
};
};
# HACK to ensure that we preserve source from bootstrap binutils to not rebuild LLVM
normal-src = stdenv.__bootPackages.binutils-unwrapped.src or (fetchurl {
url = "mirror://gnu/binutils/${basename}-${version}.tar.bz2";
sha256 = "sha256-z6dkTb7PRZHhNutAfBwdoWV4vSsD8MLorNzroZS7nWE=";
});
#INFO: The targetPrefix prepended to binary names to allow multiple binuntils
# on the PATH to both be usable.
targetPrefix = lib.optionalString (targetPlatform != hostPlatform) "${targetPlatform.config}-";
in
stdenv.mkDerivation {
pname = targetPrefix + basename;
pname = targetPrefix + "binutils";
inherit version;
src = if stdenv.targetPlatform.isVc4 then vc4-binutils-src else normal-src;
# HACK: Ensure that we preserve source from bootstrap binutils to not rebuild LLVM
src = stdenv.__bootPackages.binutils-unwrapped.src
or srcs.${targetPlatform.system}
or srcs.normal;
# WARN: this package is used for bootstrapping fetchurl, and thus cannot use
# fetchpatch! All mutable patches (generated by GitHub or cgit) that are
# needed here should be included directly in Nixpkgs as files.
patches = [
# Make binutils output deterministic by default.
./deterministic.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
# Breaks nm BSD flag detection
./0001-Revert-libtool.m4-fix-nm-BSD-flag-detection.patch
# Required for newer macos versions
./0001-libtool.m4-update-macos-version-detection-block.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
@ -68,34 +81,17 @@ stdenv.mkDerivation {
# override this behavior, forcing ld to search DT_RPATH even when
# cross-compiling.
./always-search-rpath.patch
# Fix quadratic slowdown in `strip` performance.
# See #129467 and https://sourceware.org/bugzilla/show_bug.cgi?id=28058
# Remove when we're on binutils > 2.36.1.
# The patch is downloaded from
# https://sourceware.org/git/?p=binutils-gdb.git;a=blobdiff_plain;f=bfd/elf.c;h=af62aadc3d446cd5b1f0201b207c90c22e7809b1;hp=36733e080dd9d9be28b576b246aaf5bd8c8569c7;hb=84fd26d8209e99fc3a432dd0b09b6c053de1ce65;hpb=abe2a28aaa7a2bfd0f3061c72a98eb898976b721
# which is the 2.36 backport (using `TRUE` instead of `true` of binutils master commit:
# https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=956ea65cd707707c0f725930214cbc781367a831
./bfd-elf-Dont-read-non-existing-secondary-relocs.patch
# Fix building plv8s v8.
# https://github.com/NixOS/nixpkgs/issues/134190
# Obtained from: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=586e30940e640f67bd55bd72e1d1355a4faf8079
./gold-Update-GNU_PROPERTY_X86_XXX-macros.patch
./CVE-2020-35448.patch
./CVE-2021-3487.patch
./CVE-2021-45078.patch
] ++ lib.optional stdenv.targetPlatform.isiOS ./support-ios.patch
++ # This patch was suggested by Nick Clifton to fix
# https://sourceware.org/bugzilla/show_bug.cgi?id=16177
# It can be removed when that 7-year-old bug is closed.
# This binutils bug causes GHC to emit broken binaries on armv7, and
# indeed GHC will refuse to compile with a binutils suffering from it. See
# this comment for more information:
# https://gitlab.haskell.org/ghc/ghc/issues/4210#note_78333
lib.optional (stdenv.targetPlatform.isAarch32 && stdenv.hostPlatform.system != stdenv.targetPlatform.system) ./R_ARM_COPY.patch
++ lib.optional stdenv.targetPlatform.isWindows ./windres-locate-gcc.patch;
]
++ lib.optional targetPlatform.isiOS ./support-ios.patch
# This patch was suggested by Nick Clifton to fix
# https://sourceware.org/bugzilla/show_bug.cgi?id=16177
# It can be removed when that 7-year-old bug is closed.
# This binutils bug causes GHC to emit broken binaries on armv7, and indeed
# GHC will refuse to compile with a binutils suffering from it. See this
# comment for more information:
# https://gitlab.haskell.org/ghc/ghc/issues/4210#note_78333
++ lib.optional (targetPlatform.isAarch32 && hostPlatform.system != targetPlatform.system) ./R_ARM_COPY.patch
++ lib.optional targetPlatform.isWindows ./windres-locate-gcc.patch;
outputs = [ "out" "info" "man" ];
@ -104,14 +100,26 @@ stdenv.mkDerivation {
bison
perl
texinfo
] ++ (lib.optionals stdenv.targetPlatform.isiOS [
autoreconfHook
]) ++ lib.optionals stdenv.targetPlatform.isVc4 [ flex ];
]
++ lib.optionals targetPlatform.isiOS [ autoreconfHook ]
++ lib.optionals targetPlatform.isDarwin [ autoconf269 automake gettext libtool ]
++ lib.optionals targetPlatform.isVc4 [ flex ]
;
buildInputs = [ zlib gettext ];
inherit noSysDirs;
preConfigure = ''
preConfigure = (lib.optionalString targetPlatform.isDarwin ''
for i in */configure.ac; do
pushd "$(dirname "$i")"
echo "Running autoreconf in $PWD"
# autoreconf doesn't work, don't know why
# autoreconf ''${autoreconfFlags:---install --force --verbose}
autoconf
popd
done
'') + ''
# Clear the default library search path.
if test "$noSysDirs" = "1"; then
echo 'NATIVE_LIB_DIRS=' >> ld/configure.tgt
@ -126,7 +134,8 @@ stdenv.mkDerivation {
# 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 stdenv.hostPlatform.isDarwin
NIX_CFLAGS_COMPILE =
if hostPlatform.isDarwin
then "-Wno-string-plus-int -Wno-deprecated-declarations"
else "-static-libgcc";
@ -134,11 +143,7 @@ stdenv.mkDerivation {
configurePlatforms = [ "build" "host" "target" ];
configureFlags =
(if enableShared then [ "--enable-shared" "--disable-static" ]
else [ "--disable-shared" "--enable-static" ])
++ lib.optional withAllTargets "--enable-targets=all"
++ [
configureFlags = [
"--enable-64-bit-bfd"
"--with-system-zlib"
@ -151,35 +156,40 @@ stdenv.mkDerivation {
# RUNPATH can be overriden using LD_LIBRARY_PATH at runtime.
"--enable-new-dtags"
# force target prefix. Some versions of binutils will make it empty
# if `--host` and `--target` are too close, even if Nixpkgs thinks
# the platforms are different (e.g. because not all the info makes
# the `config`). Other versions of binutils will always prefix if
# `--target` is passed, even if `--host` and `--target` are the same.
# The easiest thing for us to do is not leave it to chance, and force
# the program prefix to be what we want it to be.
# force target prefix. Some versions of binutils will make it empty if
# `--host` and `--target` are too close, even if Nixpkgs thinks the
# platforms are different (e.g. because not all the info makes the
# `config`). Other versions of binutils will always prefix if `--target` is
# passed, even if `--host` and `--target` are the same. The easiest thing
# for us to do is not leave it to chance, and force the program prefix to be
# what we want it to be.
"--program-prefix=${targetPrefix}"
] ++ lib.optionals gold [
"--enable-gold"
"--enable-plugins"
];
]
++ lib.optionals withAllTargets [ "--enable-targets=all" ]
++ lib.optionals enableGold [ "--enable-gold" "--enable-plugins" ]
++ (if enableShared
then [ "--enable-shared" "--disable-static" ]
else [ "--disable-shared" "--enable-static" ])
;
doCheck = false; # fails
# Fails
doCheck = false;
postFixup = lib.optionalString reuseLibs ''
postFixup = lib.optionalString (enableShared && withAllTargets) ''
rm "$out"/lib/lib{bfd,opcodes}-${version}.so
ln -s '${lib.getLib libbfd}/lib/libbfd-${version}.so' "$out/lib/"
ln -s '${lib.getLib libopcodes}/lib/libopcodes-${version}.so' "$out/lib/"
'';
# else fails with "./sanity.sh: line 36: $out/bin/size: not found"
doInstallCheck = stdenv.buildPlatform == stdenv.hostPlatform && stdenv.hostPlatform == stdenv.targetPlatform;
# INFO: Otherwise it fails with:
# `./sanity.sh: line 36: $out/bin/size: not found`
doInstallCheck = (buildPlatform == hostPlatform) && (hostPlatform == targetPlatform);
enableParallelBuilding = true;
passthru = {
inherit targetPrefix;
hasGold = gold;
hasGold = enableGold;
isGNU = true;
};
@ -193,11 +203,11 @@ stdenv.mkDerivation {
'';
homepage = "https://www.gnu.org/software/binutils/";
license = licenses.gpl3Plus;
maintainers = with maintainers; [ ericson2314 ];
maintainers = with maintainers; [ ericson2314 lovesegfault ];
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. */
# INFO: 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,23 +0,0 @@
diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index 9f956d3..f5b61f1 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -19585,7 +19585,10 @@ elf32_arm_vxworks_final_write_processing (bfd *abfd, bfd_boolean linker)
#undef ELF_MAXPAGESIZE
#define ELF_MAXPAGESIZE 0x1000
+/* Prioritize elf32-*arm (priority 1) over elf32-*arm-vxworks (priority 2) */
+#define elf_match_priority 2
#include "elf32-target.h"
+#undef elf_match_priority
/* Merge backend specific data from an object file to the output
@@ -19974,4 +19977,7 @@ elf32_arm_symbian_plt_sym_val (bfd_vma i, const asection *plt,
#undef ELF_MAXPAGESIZE
#define ELF_MAXPAGESIZE 0x8000
+/* Prioritize elf32-*arm (priority 1) over elf32-*arm-symbian (priority 2) */
+#define elf_match_priority 2
#include "elf32-target.h"
+#undef elf_match_priority

View file

@ -1,292 +0,0 @@
From 586e30940e640f67bd55bd72e1d1355a4faf8079 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Tue, 13 Oct 2020 05:20:49 -0700
Subject: [PATCH] gold: Update GNU_PROPERTY_X86_XXX macros
This patch updates GNU_PROPERTY_X86_XXX macros for gold:
1. GNU_PROPERTY_X86_UINT32_AND_XXX: A 4-byte unsigned integer property.
A bit is set if it is set in all relocatable inputs:
#define GNU_PROPERTY_X86_UINT32_AND_LO 0xc0000002
#define GNU_PROPERTY_X86_UINT32_AND_HI 0xc0007fff
2. GNU_PROPERTY_X86_UINT32_OR_XXX: A 4-byte unsigned integer property.
A bit is set if it is set in any relocatable inputs:
#define GNU_PROPERTY_X86_UINT32_OR_LO 0xc0008000
#define GNU_PROPERTY_X86_UINT32_OR_HI 0xc000ffff
3. GNU_PROPERTY_X86_UINT32_OR_AND_XXX: A 4-byte unsigned integer property.
A bit is set if it is set in any relocatable inputs and the property is
present in all relocatable inputs:
#define GNU_PROPERTY_X86_UINT32_OR_AND_LO 0xc0010000
#define GNU_PROPERTY_X86_UINT32_OR_AND_HI 0xc0017fff
4. GNU_PROPERTY_X86_FEATURE_2_NEEDED, GNU_PROPERTY_X86_FEATURE_2_USED
and GNU_PROPERTY_X86_FEATURE_2_XXX bits.
GNU_PROPERTY_X86_FEATURE_1_AND is unchanged. GNU_PROPERTY_X86_ISA_1_USED
and GNU_PROPERTY_X86_ISA_1_NEEDED are updated to better support targeted
processors since GNU_PROPERTY_X86_ISA_1_?86 aren't isn't very useful.
A new set of GNU_PROPERTY_X86_ISA_1_XXX bits are defined. The previous
GNU_PROPERTY_X86_ISA_1_XXX macros are deprecated and renamed to
GNU_PROPERTY_X86_COMPAT_ISA_1_XXX and GNU_PROPERTY_X86_COMPAT_2_ISA_1_XXX.
elfcpp/
* elfcpp.h (GNU_PROPERTY_X86_ISA_1_USED): Renamed to ...
(GNU_PROPERTY_X86_COMPAT_ISA_1_USED): This.
(GNU_PROPERTY_X86_ISA_1_NEEDED): Renamed to ...
(GNU_PROPERTY_X86_COMPAT_ISA_1_NEEDED): This.
(GNU_PROPERTY_X86_UINT32_AND_LO): New.
(GNU_PROPERTY_X86_UINT32_AND_HI): Likewise.
(GNU_PROPERTY_X86_UINT32_OR_LO): Likewise.
(GNU_PROPERTY_X86_UINT32_OR_HI): Likewise.
(GNU_PROPERTY_X86_UINT32_OR_AND_LO): Likewise.
(GNU_PROPERTY_X86_UINT32_OR_AND_HI): Likewise.
(GNU_PROPERTY_X86_COMPAT_2_ISA_1_NEEDED): New.
(GNU_PROPERTY_X86_COMPAT_2_ISA_1_NEEDED): Likewise.
(GNU_PROPERTY_X86_FEATURE_1_AND): Updated to
(GNU_PROPERTY_X86_UINT32_AND_LO + 0).
(GNU_PROPERTY_X86_ISA_1_NEEDED): New. Defined to
GNU_PROPERTY_X86_UINT32_OR_LO + 2.
(GNU_PROPERTY_X86_FEATURE_2_NEEDED): New. Defined to
(GNU_PROPERTY_X86_UINT32_OR_LO + 1).
(GNU_PROPERTY_X86_ISA_1_USED): New. Defined to
GNU_PROPERTY_X86_UINT32_OR_AND_LO + 2.
(GNU_PROPERTY_X86_FEATURE_2_USED): New. Defined to
(GNU_PROPERTY_X86_UINT32_OR_AND_LO + 1).
gold/
* x86_64.cc (Target_x86_64::Target_x86_64): Initialize
feature_2_used_, feature_2_needed_ and object_feature_2_used_.
(Target_x86_64::feature_2_used_): New data member.
(Target_x86_64::feature_2_needed_): Likewise.
(Target_x86_64::object_isa_1_used_): Likewise.
(Target_x86_64::record_gnu_property): Support
GNU_PROPERTY_X86_COMPAT_ISA_1_USED,
GNU_PROPERTY_X86_COMPAT_ISA_1_NEEDED,
GNU_PROPERTY_X86_COMPAT_2_ISA_1_USED,
GNU_PROPERTY_X86_COMPAT_2_ISA_1_NEEDED,
GNU_PROPERTY_X86_FEATURE_2_USED and
GNU_PROPERTY_X86_FEATURE_2_NEEDED.
(Target_x86_64::merge_gnu_properties): Merge FEATURE_2_USED bits.
Initialize object_feature_2_used_.
(Target_x86_64::do_finalize_gnu_properties): Support
GNU_PROPERTY_X86_FEATURE_2_USED and
GNU_PROPERTY_X86_FEATURE_2_NEEDED.
* testsuite/gnu_property_a.S (GNU_PROPERTY_X86_ISA_1_USED): Set
to 0xc0010002.
(GNU_PROPERTY_X86_ISA_1_NEEDED): Set to 0xc0008002.
* testsuite/gnu_property_b.S (GNU_PROPERTY_X86_ISA_1_USED): Set
to 0xc0010002.
(GNU_PROPERTY_X86_ISA_1_NEEDED): Set to 0xc0008002.
* testsuite/gnu_property_c.S (GNU_PROPERTY_X86_ISA_1_USED): Set
to 0xc0010002.
(GNU_PROPERTY_X86_ISA_1_NEEDED): Set to 0xc0008002.
* testsuite/gnu_property_test.sh: Updated.
---
elfcpp/ChangeLog | [omitted]
elfcpp/elfcpp.h | 18 ++++++++++++---
gold/ChangeLog | [omitted]
gold/testsuite/gnu_property_a.S | 4 ++--
gold/testsuite/gnu_property_b.S | 4 ++--
gold/testsuite/gnu_property_c.S | 4 ++--
gold/testsuite/gnu_property_test.sh | 4 ++--
gold/x86_64.cc | 34 +++++++++++++++++++++++++++--
8 files changed, 110 insertions(+), 13 deletions(-)
diff --git a/elfcpp/elfcpp.h b/elfcpp/elfcpp.h
index 65d803c00e2..4b6ff94a654 100644
--- a/elfcpp/elfcpp.h
+++ b/elfcpp/elfcpp.h
@@ -1013,9 +1013,21 @@ enum
GNU_PROPERTY_STACK_SIZE = 1,
GNU_PROPERTY_NO_COPY_ON_PROTECTED = 2,
GNU_PROPERTY_LOPROC = 0xc0000000,
- GNU_PROPERTY_X86_ISA_1_USED = 0xc0000000,
- GNU_PROPERTY_X86_ISA_1_NEEDED = 0xc0000001,
- GNU_PROPERTY_X86_FEATURE_1_AND = 0xc0000002,
+ GNU_PROPERTY_X86_COMPAT_ISA_1_USED = 0xc0000000,
+ GNU_PROPERTY_X86_COMPAT_ISA_1_NEEDED = 0xc0000001,
+ GNU_PROPERTY_X86_UINT32_AND_LO = 0xc0000002,
+ GNU_PROPERTY_X86_UINT32_AND_HI = 0xc0007fff,
+ GNU_PROPERTY_X86_UINT32_OR_LO = 0xc0008000,
+ GNU_PROPERTY_X86_UINT32_OR_HI = 0xc000ffff,
+ GNU_PROPERTY_X86_UINT32_OR_AND_LO = 0xc0010000,
+ GNU_PROPERTY_X86_UINT32_OR_AND_HI = 0xc0017fff,
+ GNU_PROPERTY_X86_COMPAT_2_ISA_1_NEEDED = GNU_PROPERTY_X86_UINT32_OR_LO + 0,
+ GNU_PROPERTY_X86_COMPAT_2_ISA_1_USED = GNU_PROPERTY_X86_UINT32_OR_AND_LO + 0,
+ GNU_PROPERTY_X86_FEATURE_1_AND = GNU_PROPERTY_X86_UINT32_AND_LO + 0,
+ GNU_PROPERTY_X86_ISA_1_NEEDED = GNU_PROPERTY_X86_UINT32_OR_LO + 2,
+ GNU_PROPERTY_X86_FEATURE_2_NEEDED = GNU_PROPERTY_X86_UINT32_OR_LO + 1,
+ GNU_PROPERTY_X86_ISA_1_USED = GNU_PROPERTY_X86_UINT32_OR_AND_LO + 2,
+ GNU_PROPERTY_X86_FEATURE_2_USED = GNU_PROPERTY_X86_UINT32_OR_AND_LO + 1,
GNU_PROPERTY_HIPROC = 0xdfffffff,
GNU_PROPERTY_LOUSER = 0xe0000000,
GNU_PROPERTY_HIUSER = 0xffffffff
diff --git a/gold/testsuite/gnu_property_a.S b/gold/testsuite/gnu_property_a.S
index 463bc8e52fe..5fbbbc9c4bb 100644
--- a/gold/testsuite/gnu_property_a.S
+++ b/gold/testsuite/gnu_property_a.S
@@ -1,8 +1,8 @@
#define NT_GNU_PROPERTY_TYPE_0 5
#define GNU_PROPERTY_STACK_SIZE 1
-#define GNU_PROPERTY_X86_ISA_1_USED 0xc0000000
-#define GNU_PROPERTY_X86_ISA_1_NEEDED 0xc0000001
+#define GNU_PROPERTY_X86_ISA_1_USED 0xc0010002
+#define GNU_PROPERTY_X86_ISA_1_NEEDED 0xc0008002
#define GNU_PROPERTY_X86_FEATURE_1_AND 0xc0000002
#if __SIZEOF_PTRDIFF_T__ == 8
diff --git a/gold/testsuite/gnu_property_b.S b/gold/testsuite/gnu_property_b.S
index 0c0c038ead1..7028f73d7ab 100644
--- a/gold/testsuite/gnu_property_b.S
+++ b/gold/testsuite/gnu_property_b.S
@@ -2,8 +2,8 @@
#define GNU_PROPERTY_STACK_SIZE 1
#define GNU_PROPERTY_NO_COPY_ON_PROTECTED 2
-#define GNU_PROPERTY_X86_ISA_1_USED 0xc0000000
-#define GNU_PROPERTY_X86_ISA_1_NEEDED 0xc0000001
+#define GNU_PROPERTY_X86_ISA_1_USED 0xc0010002
+#define GNU_PROPERTY_X86_ISA_1_NEEDED 0xc0008002
#define GNU_PROPERTY_X86_FEATURE_1_AND 0xc0000002
#if __SIZEOF_PTRDIFF_T__ == 8
diff --git a/gold/testsuite/gnu_property_c.S b/gold/testsuite/gnu_property_c.S
index ace159a9a9d..c8cbd8bce28 100644
--- a/gold/testsuite/gnu_property_c.S
+++ b/gold/testsuite/gnu_property_c.S
@@ -2,8 +2,8 @@
#define GNU_PROPERTY_STACK_SIZE 1
#define GNU_PROPERTY_NO_COPY_ON_PROTECTED 2
-#define GNU_PROPERTY_X86_ISA_1_USED 0xc0000000
-#define GNU_PROPERTY_X86_ISA_1_NEEDED 0xc0000001
+#define GNU_PROPERTY_X86_ISA_1_USED 0xc0010002
+#define GNU_PROPERTY_X86_ISA_1_NEEDED 0xc0008002
#define GNU_PROPERTY_X86_FEATURE_1_AND 0xc0000002
#if __SIZEOF_PTRDIFF_T__ == 8
diff --git a/gold/testsuite/gnu_property_test.sh b/gold/testsuite/gnu_property_test.sh
index 1806d3474cc..a4096005b78 100755
--- a/gold/testsuite/gnu_property_test.sh
+++ b/gold/testsuite/gnu_property_test.sh
@@ -77,8 +77,8 @@ check_count gnu_property_test.stdout "^ NOTE" 2
check gnu_property_test.stdout "stack size: 0x111100"
check gnu_property_test.stdout "no copy on protected"
-check gnu_property_test.stdout "x86 ISA used: i486, SSE2, SSE4_2, AVX512CD"
-check gnu_property_test.stdout "x86 ISA needed: i486, SSE2, SSE4_2, AVX512CD"
+check gnu_property_test.stdout "x86 ISA used: x86-64-v2, <unknown: 10>, <unknown: 100>, <unknown: 1000>"
+check gnu_property_test.stdout "x86 ISA needed: x86-64-v2, <unknown: 10>, <unknown: 100>, <unknown: 1000>"
check gnu_property_test.stdout "x86 feature: IBT"
exit 0
diff --git a/gold/x86_64.cc b/gold/x86_64.cc
index 9cb2cf0a322..378bac16f78 100644
--- a/gold/x86_64.cc
+++ b/gold/x86_64.cc
@@ -706,8 +706,9 @@ class Target_x86_64 : public Sized_target<size, false>
rela_irelative_(NULL), copy_relocs_(elfcpp::R_X86_64_COPY),
got_mod_index_offset_(-1U), tlsdesc_reloc_info_(),
tls_base_symbol_defined_(false), isa_1_used_(0), isa_1_needed_(0),
- feature_1_(0), object_isa_1_used_(0), object_feature_1_(0),
- seen_first_object_(false)
+ feature_1_(0), feature_2_used_(0), feature_2_needed_(0),
+ object_isa_1_used_(0), object_feature_1_(0),
+ object_feature_2_used_(0), seen_first_object_(false)
{ }
// Hook for a new output section.
@@ -1382,6 +1383,8 @@ class Target_x86_64 : public Sized_target<size, false>
uint32_t isa_1_used_;
uint32_t isa_1_needed_;
uint32_t feature_1_;
+ uint32_t feature_2_used_;
+ uint32_t feature_2_needed_;
// Target-specific properties from the current object.
// These bits get ORed into ISA_1_USED_ after all properties for the object
// have been processed. But if either is all zeroes (as when the property
@@ -1391,6 +1394,7 @@ class Target_x86_64 : public Sized_target<size, false>
// These bits get ANDed into FEATURE_1_ after all properties for the object
// have been processed.
uint32_t object_feature_1_;
+ uint32_t object_feature_2_used_;
// Whether we have seen our first object, for use in initializing FEATURE_1_.
bool seen_first_object_;
};
@@ -1594,9 +1598,15 @@ Target_x86_64<size>::record_gnu_property(
switch (pr_type)
{
+ case elfcpp::GNU_PROPERTY_X86_COMPAT_ISA_1_USED:
+ case elfcpp::GNU_PROPERTY_X86_COMPAT_ISA_1_NEEDED:
+ case elfcpp::GNU_PROPERTY_X86_COMPAT_2_ISA_1_USED:
+ case elfcpp::GNU_PROPERTY_X86_COMPAT_2_ISA_1_NEEDED:
case elfcpp::GNU_PROPERTY_X86_ISA_1_USED:
case elfcpp::GNU_PROPERTY_X86_ISA_1_NEEDED:
case elfcpp::GNU_PROPERTY_X86_FEATURE_1_AND:
+ case elfcpp::GNU_PROPERTY_X86_FEATURE_2_USED:
+ case elfcpp::GNU_PROPERTY_X86_FEATURE_2_NEEDED:
if (pr_datasz != 4)
{
gold_warning(_("%s: corrupt .note.gnu.property section "
@@ -1625,6 +1635,12 @@ Target_x86_64<size>::record_gnu_property(
// If we see multiple feature props in one object, OR them together.
this->object_feature_1_ |= val;
break;
+ case elfcpp::GNU_PROPERTY_X86_FEATURE_2_USED:
+ this->object_feature_2_used_ |= val;
+ break;
+ case elfcpp::GNU_PROPERTY_X86_FEATURE_2_NEEDED:
+ this->feature_2_needed_ |= val;
+ break;
}
}
@@ -1642,15 +1658,23 @@ Target_x86_64<size>::merge_gnu_properties(const Object*)
else if (this->isa_1_used_ != 0)
this->isa_1_used_ |= this->object_isa_1_used_;
this->feature_1_ &= this->object_feature_1_;
+ // If any object is missing the FEATURE_2_USED property, we must
+ // omit it from the output file.
+ if (this->object_feature_2_used_ == 0)
+ this->feature_2_used_ = 0;
+ else if (this->feature_2_used_ != 0)
+ this->feature_2_used_ |= this->object_feature_2_used_;
}
else
{
this->isa_1_used_ = this->object_isa_1_used_;
this->feature_1_ = this->object_feature_1_;
+ this->feature_2_used_ = this->object_feature_2_used_;
this->seen_first_object_ = true;
}
this->object_isa_1_used_ = 0;
this->object_feature_1_ = 0;
+ this->object_feature_2_used_ = 0;
}
static inline void
@@ -1676,6 +1700,12 @@ Target_x86_64<size>::do_finalize_gnu_properties(Layout* layout) const
if (this->feature_1_ != 0)
add_property(layout, elfcpp::GNU_PROPERTY_X86_FEATURE_1_AND,
this->feature_1_);
+ if (this->feature_2_used_ != 0)
+ add_property(layout, elfcpp::GNU_PROPERTY_X86_FEATURE_2_USED,
+ this->feature_2_used_);
+ if (this->feature_2_needed_ != 0)
+ add_property(layout, elfcpp::GNU_PROPERTY_X86_FEATURE_2_NEEDED,
+ this->feature_2_needed_);
}
// Write the first three reserved words of the .got.plt section.
--
2.27.0

View file

@ -204,7 +204,7 @@ in
# Rebuild binutils to use from stage2 onwards.
overrides = self: super: {
binutils-unwrapped = super.binutils-unwrapped.override {
gold = false;
enableGold = false;
};
inherit (prevStage)
ccWrapperStdenv

View file

@ -37,7 +37,7 @@ in with pkgs; rec {
bootBinutils = binutils.bintools.override {
withAllTargets = false;
# Don't need two linkers, disable whatever's not primary/default.
gold = false;
enableGold = false;
# bootstrap is easier w/static
enableShared = false;
};
@ -172,7 +172,7 @@ in with pkgs; rec {
for i in as ld ar ranlib nm strip readelf objdump; do
cp ${bootBinutils.out}/bin/$i $out/bin
done
cp '${lib.getLib binutils.bintools}'/lib/* "$out/lib/"
cp -r '${lib.getLib binutils.bintools}'/lib/* "$out/lib/"
chmod -R u+w $out
@ -186,6 +186,7 @@ in with pkgs; rec {
nuke-refs $out/bin/*
nuke-refs $out/lib/*
nuke-refs $out/lib/*/*
nuke-refs $out/libexec/gcc/*/*/*
nuke-refs $out/lib/gcc/*/*/*
nuke-refs $out/lib/gcc/*/*/include-fixed/*{,/*}

View file

@ -38,6 +38,12 @@ stdenv.mkDerivation rec {
ln -s libNX_X11.so.6.3.0
'';
preConfigure = ''
# binutils 2.37 fix
# https://github.com/ArcticaProject/nx-libs/issues/1003
substituteInPlace nx-X11/config/cf/Imake.tmpl --replace "clq" "cq"
'';
PREFIX=""; # Don't install to $out/usr/local
installPhase = ''
make DESTDIR="$out" install

View file

@ -14642,7 +14642,7 @@ with pkgs;
bingrep = callPackage ../development/tools/analysis/bingrep { };
binutils-unwrapped = callPackage ../development/tools/misc/binutils {
autoreconfHook = if targetPlatform.isiOS then autoreconfHook269 else autoreconfHook;
autoreconfHook = autoreconfHook269;
# FHS sys dirs presumably only have stuff for the build platform
noSysDirs = (stdenv.targetPlatform != stdenv.hostPlatform) || noSysDirs;
};
@ -14651,7 +14651,7 @@ with pkgs;
};
binutils_nogold = lowPrio (wrapBintoolsWith {
bintools = binutils-unwrapped.override {
gold = false;
enableGold = false;
};
});
binutilsNoLibc = wrapBintoolsWith {