binutils: Upgrade to 2.37 branch

This is next/latest release branch for binutils
Drop backports and CVE fixes which already are applied upstream

bfd_stdint.h has been removed in favor of using stdint.h

(From OE-Core rev: 08cd144fc4b5ac34ff99f71b1d825cbff96b642c)

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Khem Raj
2021-07-18 21:22:03 -07:00
committed by Richard Purdie
parent a926dd6cdd
commit 433d240084
27 changed files with 1301 additions and 3013 deletions

View File

@@ -18,7 +18,7 @@ PREFERRED_PROVIDER_virtual/gettext ??= "gettext"
GCCVERSION ?= "11.%"
SDKGCCVERSION ?= "${GCCVERSION}"
BINUVERSION ?= "2.36%"
BINUVERSION ?= "2.37%"
GDBVERSION ?= "10.%"
GLIBCVERSION ?= "2.33"
LINUXLIBCVERSION ?= "5.13%"

View File

@@ -12,13 +12,13 @@ LIC_FILES_CHKSUM="\
# When upgrading to 2.37, please make sure there is no trailing .0, so
# that upstream version check can work correctly.
PV = "2.36.1"
CVE_VERSION = "2.36.1"
SRCBRANCH ?= "binutils-2_36-branch"
PV = "2.37"
CVE_VERSION = "2.37"
SRCBRANCH ?= "binutils-2_37-branch"
UPSTREAM_CHECK_GITTAGREGEX = "binutils-(?P<pver>\d+_(\d_?)*)"
SRCREV ?= "7651a4871c225925ffdfda0a8c91a6ed370cd9a1"
SRCREV ?= "87d4632d36323091e731eb07b8aa65f90293da66"
BINUTILS_GIT_URI ?= "git://sourceware.org/git/binutils-gdb.git;branch=${SRCBRANCH};protocol=git"
SRC_URI = "\
${BINUTILS_GIT_URI} \
@@ -35,8 +35,5 @@ SRC_URI = "\
file://0014-Fix-rpath-in-libtool-when-sysroot-is-enabled.patch \
file://0015-sync-with-OE-libtool-changes.patch \
file://0016-Check-for-clang-before-checking-gcc-version.patch \
file://0017-Add-support-for-the-DW_FORM_strx-forms-to-the-BFD-li.patch \
file://0018-Add-DWARF-5-support-in-gold.patch \
file://CVE-2021-20197.patch \
"
S = "${WORKDIR}/git"

View File

@@ -15,9 +15,6 @@ do_configure[dirs] += "${B}/ld ${B}/bfd"
do_configure() {
# create config.h, oe enables initfini-array by default
echo "#define HAVE_INITFINI_ARRAY" > ${B}/ld/config.h
# use the bfd_stdint.h from binutils-native, this is the same of the one
# generated by binutils-cross
cp ${RECIPE_SYSROOT_NATIVE}/usr/include/bfd_stdint.h ${B}/bfd/
}
# target depends
@@ -82,4 +79,3 @@ do_check() {
done
}
addtask check after do_configure

View File

@@ -170,8 +170,6 @@ do_install () {
done
oe_multilib_header bfd.h
# bfd_stdint.h encodes the compiler name in the header
sed -i ${D}${includedir}/bfd_stdint.h -e "s,${TARGET_PREFIX},,"
}
inherit update-alternatives

View File

@@ -1,4 +1,4 @@
From 3b278a56a0e98d50ec62735598ee5f4b1834e8b3 Mon Sep 17 00:00:00 2001
From 257ad1ce148417e1cefe2332d8acc5c8216c2522 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Mon, 2 Mar 2015 01:58:54 +0000
Subject: [PATCH] binutils-crosssdk: Generate relocatable SDKs

View File

@@ -1,4 +1,4 @@
From cf4c8a97b7dc1fe36a7d5dabed417fe18b15ad6b Mon Sep 17 00:00:00 2001
From 6e93d0328f499569db7ce6396f94f304ce340df8 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Mon, 6 Mar 2017 23:37:05 -0800
Subject: [PATCH] binutils-cross: Do not generate linker script directories

View File

@@ -1,4 +1,4 @@
From 9701cab0fdf6a0c011978ae140c4c12a962956f6 Mon Sep 17 00:00:00 2001
From d49016d3faf684319bf3ac37450558920d70be03 Mon Sep 17 00:00:00 2001
From: Richard Purdie <richard.purdie@linuxfoundation.org>
Date: Wed, 19 Feb 2020 09:51:16 -0800
Subject: [PATCH] binutils-nativesdk: Search for alternative ld.so.conf in SDK
@@ -29,7 +29,7 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
5 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/ld/Makefile.am b/ld/Makefile.am
index 2c9a487335c..3b01357b651 100644
index f8e99325361..fd196541f59 100644
--- a/ld/Makefile.am
+++ b/ld/Makefile.am
@@ -42,7 +42,8 @@ ZLIBINC = @zlibinc@
@@ -43,10 +43,10 @@ index 2c9a487335c..3b01357b651 100644
NO_WERROR = @NO_WERROR@
AM_CFLAGS = $(WARN_CFLAGS) $(ELF_CLFAGS)
diff --git a/ld/Makefile.in b/ld/Makefile.in
index b41941c89e2..a6382bf2a45 100644
index ef2e99e08da..cb8f5bfb70e 100644
--- a/ld/Makefile.in
+++ b/ld/Makefile.in
@@ -554,7 +554,8 @@ ZLIB = @zlibdir@ -lz
@@ -555,7 +555,8 @@ ZLIB = @zlibdir@ -lz
ZLIBINC = @zlibinc@
ELF_CLFAGS = -DELF_LIST_OPTIONS=@elf_list_options@ \
-DELF_SHLIB_LIST_OPTIONS=@elf_shlib_list_options@ \
@@ -57,7 +57,7 @@ index b41941c89e2..a6382bf2a45 100644
AM_CFLAGS = $(WARN_CFLAGS) $(ELF_CLFAGS)
diff --git a/ld/ldelf.c b/ld/ldelf.c
index f7407ab55a7..b25781cc0c4 100644
index 21e655bb55c..d1615003ede 100644
--- a/ld/ldelf.c
+++ b/ld/ldelf.c
@@ -911,7 +911,7 @@ ldelf_check_ld_so_conf (const struct bfd_link_needed_list *l, int force,
@@ -70,7 +70,7 @@ index f7407ab55a7..b25781cc0c4 100644
if (!ldelf_parse_ld_so_conf (&info, tmppath))
{
diff --git a/ld/ldmain.c b/ld/ldmain.c
index 863df0293ea..080b1c4c6c2 100644
index 42660eb9a3c..5a4a4d5da3d 100644
--- a/ld/ldmain.c
+++ b/ld/ldmain.c
@@ -70,6 +70,7 @@ char *program_name;
@@ -82,7 +82,7 @@ index 863df0293ea..080b1c4c6c2 100644
/* The canonical representation of ld_sysroot. */
char *ld_canon_sysroot;
diff --git a/ld/ldmain.h b/ld/ldmain.h
index 38e63922d31..0966914938c 100644
index 39d08a6c378..4c3519e7970 100644
--- a/ld/ldmain.h
+++ b/ld/ldmain.h
@@ -23,6 +23,7 @@

View File

@@ -1,4 +1,4 @@
From 7e7512c82402363688cca6f1febea2c01cb03409 Mon Sep 17 00:00:00 2001
From b8d43b6b8d98e176346871c92935458b06598c5b Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Mon, 2 Mar 2015 01:07:33 +0000
Subject: [PATCH] configure: widen the regexp for SH architectures
@@ -14,10 +14,10 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/configure b/configure
index 68779feb42b..7b369071141 100755
index 3dd206525a7..e8ba1a1d3de 100755
--- a/configure
+++ b/configure
@@ -3887,7 +3887,7 @@ case "${target}" in
@@ -3892,7 +3892,7 @@ case "${target}" in
nvptx*-*-*)
noconfigdirs="$noconfigdirs target-libssp target-libstdc++-v3 target-libobjc"
;;
@@ -27,10 +27,10 @@ index 68779feb42b..7b369071141 100755
sh*-*-elf)
;;
diff --git a/configure.ac b/configure.ac
index d16a2757689..92f01fb3ed7 100644
index 797a624621e..3a8a3ae1f3b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1177,7 +1177,7 @@ case "${target}" in
@@ -1175,7 +1175,7 @@ case "${target}" in
nvptx*-*-*)
noconfigdirs="$noconfigdirs target-libssp target-libstdc++-v3 target-libobjc"
;;

View File

@@ -1,4 +1,4 @@
From 6a67d277941228d997b527990960413f8444fb81 Mon Sep 17 00:00:00 2001
From 1a9fcaae50e63b993019bd4dc00219e43421efdc Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Mon, 2 Mar 2015 01:09:58 +0000
Subject: [PATCH] Point scripts location to libdir
@@ -12,7 +12,7 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/ld/Makefile.am b/ld/Makefile.am
index 3b01357b651..b7a1f7491b0 100644
index fd196541f59..d94fa7e64e1 100644
--- a/ld/Makefile.am
+++ b/ld/Makefile.am
@@ -51,7 +51,7 @@ AM_CFLAGS = $(WARN_CFLAGS) $(ELF_CLFAGS)
@@ -25,10 +25,10 @@ index 3b01357b651..b7a1f7491b0 100644
EMUL = @EMUL@
EMULATION_OFILES = @EMULATION_OFILES@
diff --git a/ld/Makefile.in b/ld/Makefile.in
index a6382bf2a45..5ee3a4971be 100644
index cb8f5bfb70e..9a58879c5ca 100644
--- a/ld/Makefile.in
+++ b/ld/Makefile.in
@@ -562,7 +562,7 @@ AM_CFLAGS = $(WARN_CFLAGS) $(ELF_CLFAGS)
@@ -563,7 +563,7 @@ AM_CFLAGS = $(WARN_CFLAGS) $(ELF_CLFAGS)
# We put the scripts in the directory $(scriptdir)/ldscripts.
# We can't put the scripts in $(datadir) because the SEARCH_DIR
# directives need to be different for native and cross linkers.

View File

@@ -1,4 +1,4 @@
From 8ad249270414a23a3e65c74fd67a8e4adaebec78 Mon Sep 17 00:00:00 2001
From 29517900352336708495d41902b5b7e8cc9a401a Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Mon, 2 Mar 2015 01:27:17 +0000
Subject: [PATCH] Only generate an RPATH entry if LD_RUN_PATH is not empty
@@ -14,10 +14,10 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
1 file changed, 4 insertions(+)
diff --git a/ld/ldelf.c b/ld/ldelf.c
index b25781cc0c4..77d7fb8ff03 100644
index d1615003ede..6a894285b11 100644
--- a/ld/ldelf.c
+++ b/ld/ldelf.c
@@ -1248,6 +1248,8 @@ ldelf_after_open (int use_libpath, int native, int is_linux, int is_freebsd,
@@ -1250,6 +1250,8 @@ ldelf_after_open (int use_libpath, int native, int is_linux, int is_freebsd,
&& command_line.rpath == NULL)
{
path = (const char *) getenv ("LD_RUN_PATH");
@@ -26,7 +26,7 @@ index b25781cc0c4..77d7fb8ff03 100644
if (path
&& ldelf_search_needed (path, &n, force,
is_linux, elfsize))
@@ -1608,6 +1610,8 @@ ldelf_before_allocation (char *audit, char *depaudit,
@@ -1610,6 +1612,8 @@ ldelf_before_allocation (char *audit, char *depaudit,
rpath = command_line.rpath;
if (rpath == NULL)
rpath = (const char *) getenv ("LD_RUN_PATH");

View File

@@ -1,4 +1,4 @@
From 091870218f192a5698c4420adf938e7178553c07 Mon Sep 17 00:00:00 2001
From 37581c8ce9d98a1183706e12a2c9a73f7f40462d Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Mon, 2 Mar 2015 01:39:01 +0000
Subject: [PATCH] don't let the distro compiler point to the wrong installation
@@ -17,7 +17,7 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libiberty/Makefile.in b/libiberty/Makefile.in
index 788590957e1..1bca4aafeb7 100644
index 4f1213b983b..2ba18b75cac 100644
--- a/libiberty/Makefile.in
+++ b/libiberty/Makefile.in
@@ -367,7 +367,8 @@ install-strip: install

View File

@@ -1,4 +1,4 @@
From bb48edf1a87bbc711e8978dd1e9112fe953dc1bf Mon Sep 17 00:00:00 2001
From 99e1565b9d2b929d4ee4e9da6f63766b22b23fc3 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Fri, 15 Jan 2016 06:31:09 +0000
Subject: [PATCH] warn for uses of system directories when cross linking
@@ -62,11 +62,9 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
ld/lexsup.c | 16 ++++++++++++++++
9 files changed, 86 insertions(+)
diff --git a/ld/config.in b/ld/config.in
index 7b60d778587..37b8e9b6f6c 100644
--- a/ld/config.in
+++ b/ld/config.in
@@ -40,6 +40,9 @@
@@ -43,6 +43,9 @@
language is requested. */
#undef ENABLE_NLS
@@ -76,11 +74,9 @@ index 7b60d778587..37b8e9b6f6c 100644
/* Additional extension a shared object might have. */
#undef EXTRA_SHLIB_EXTENSION
diff --git a/ld/configure b/ld/configure
index b0969791959..50bb04ce6a8 100755
--- a/ld/configure
+++ b/ld/configure
@@ -828,6 +828,7 @@ with_lib_path
@@ -829,6 +829,7 @@ with_lib_path
enable_targets
enable_64_bit_bfd
with_sysroot
@@ -88,8 +84,8 @@ index b0969791959..50bb04ce6a8 100755
enable_gold
enable_got
enable_compressed_debug_sections
@@ -1496,6 +1497,8 @@ Optional Features:
--disable-largefile omit support for large files
@@ -1498,6 +1499,8 @@ Optional Features:
--enable-checking enable run-time checks
--enable-targets alternative target configurations
--enable-64-bit-bfd 64-bit support (on hosts with narrower word sizes)
+ --enable-poison-system-directories
@@ -97,7 +93,7 @@ index b0969791959..50bb04ce6a8 100755
--enable-gold[=ARG] build gold [ARG={default,yes,no}]
--enable-got=<type> GOT handling scheme (target, single, negative,
multigot)
@@ -15820,6 +15823,19 @@ fi
@@ -15215,6 +15218,19 @@ fi
@@ -117,11 +113,9 @@ index b0969791959..50bb04ce6a8 100755
# Check whether --enable-gold was given.
if test "${enable_gold+set}" = set; then :
enableval=$enable_gold; case "${enableval}" in
diff --git a/ld/configure.ac b/ld/configure.ac
index c9c69ab9245..59dab0a6ac4 100644
--- a/ld/configure.ac
+++ b/ld/configure.ac
@@ -94,6 +94,16 @@ AC_SUBST(use_sysroot)
@@ -106,6 +106,16 @@ AC_SUBST(use_sysroot)
AC_SUBST(TARGET_SYSTEM_ROOT)
AC_SUBST(TARGET_SYSTEM_ROOT_DEFINE)
@@ -138,30 +132,26 @@ index c9c69ab9245..59dab0a6ac4 100644
dnl Use --enable-gold to decide if this linker should be the default.
dnl "install_as_default" is set to false if gold is the default linker.
dnl "installed_linker" is the installed BFD linker name.
diff --git a/ld/ld.h b/ld/ld.h
index 93f5af92c7d..ff7f71a7b66 100644
--- a/ld/ld.h
+++ b/ld/ld.h
@@ -166,6 +166,14 @@ typedef struct
@@ -162,6 +162,14 @@ typedef struct
in the linker script. */
bfd_boolean force_group_allocation;
bool force_group_allocation;
+ /* If TRUE (the default) warn for uses of system directories when
+ cross linking. */
+ bfd_boolean poison_system_directories;
+ bool poison_system_directories;
+
+ /* If TRUE (default FALSE) give an error for uses of system
+ directories when cross linking instead of a warning. */
+ bfd_boolean error_poison_system_directories;
+ bool error_poison_system_directories;
+
/* Big or little endian as set on command line. */
enum endian_enum endian;
diff --git a/ld/ld.texi b/ld/ld.texi
index 7a602b9c6ab..cccbfbab3bb 100644
--- a/ld/ld.texi
+++ b/ld/ld.texi
@@ -2810,6 +2810,18 @@ string identifying the original linked file does not change.
@@ -2863,6 +2863,18 @@ string identifying the original linked f
Passing @code{none} for @var{style} disables the setting from any
@code{--build-id} options earlier on the command line.
@@ -180,11 +170,9 @@ index 7a602b9c6ab..cccbfbab3bb 100644
@end table
@c man end
diff --git a/ld/ldfile.c b/ld/ldfile.c
index 81cb86d51e2..cd5c2752679 100644
--- a/ld/ldfile.c
+++ b/ld/ldfile.c
@@ -117,6 +117,23 @@ ldfile_add_library_path (const char *name, bfd_boolean cmdline)
@@ -117,6 +117,23 @@ ldfile_add_library_path (const char *nam
new_dirs->name = concat (ld_sysroot, name + strlen ("$SYSROOT"), (const char *) NULL);
else
new_dirs->name = xstrdup (name);
@@ -208,11 +196,9 @@ index 81cb86d51e2..cd5c2752679 100644
}
/* Try to open a BFD for a lang_input_statement. */
diff --git a/ld/ldlex.h b/ld/ldlex.h
index b0101028321..77f5accb5d9 100644
--- a/ld/ldlex.h
+++ b/ld/ldlex.h
@@ -161,6 +161,8 @@ enum option_values
@@ -163,6 +163,8 @@ enum option_values
OPTION_CTF_VARIABLES,
OPTION_NO_CTF_VARIABLES,
OPTION_CTF_SHARE_TYPES,
@@ -221,24 +207,38 @@ index b0101028321..77f5accb5d9 100644
};
/* The initial parser states. */
diff --git a/ld/ldmain.c b/ld/ldmain.c
index 080b1c4c6c2..78d8a2df278 100644
--- a/ld/ldmain.c
+++ b/ld/ldmain.c
@@ -324,6 +324,8 @@ main (int argc, char **argv)
command_line.warn_mismatch = TRUE;
command_line.warn_search_mismatch = TRUE;
@@ -321,6 +321,8 @@ main (int argc, char **argv)
command_line.warn_mismatch = true;
command_line.warn_search_mismatch = true;
command_line.check_section_addresses = -1;
+ command_line.poison_system_directories = TRUE;
+ command_line.error_poison_system_directories = FALSE;
+ command_line.poison_system_directories = true;
+ command_line.error_poison_system_directories = false;
/* We initialize DEMANGLING based on the environment variable
COLLECT_NO_DEMANGLE. The gcc collect2 program will demangle the
diff --git a/ld/lexsup.c b/ld/lexsup.c
index f005a58a045..5eb8439fef7 100644
@@ -1444,7 +1446,7 @@ undefined_symbol (struct bfd_link_info *
argv[1] = "undefined-symbol";
argv[2] = (char *) name;
argv[3] = NULL;
-
+
if (verbose)
einfo (_("%P: About to run error handling script '%s' with arguments: '%s' '%s'\n"),
argv[0], argv[1], argv[2]);
@@ -1465,7 +1467,7 @@ undefined_symbol (struct bfd_link_info *
carry on to issue the normal error message. */
}
#endif /* SUPPORT_ERROR_HANDLING_SCRIPT */
-
+
if (section != NULL)
{
if (error_count < MAX_ERRORS_IN_A_ROW)
--- a/ld/lexsup.c
+++ b/ld/lexsup.c
@@ -591,6 +591,14 @@ static const struct ld_option ld_options[] =
@@ -595,6 +595,14 @@ static const struct ld_option ld_options
" <method> is: share-unconflicted (default),\n"
" share-duplicated"),
TWO_DASHES },
@@ -253,16 +253,16 @@ index f005a58a045..5eb8439fef7 100644
};
#define OPTION_COUNT ARRAY_SIZE (ld_options)
@@ -1676,6 +1684,14 @@ parse_args (unsigned argc, char **argv)
config.print_map_discarded = TRUE;
@@ -1686,6 +1694,14 @@ parse_args (unsigned argc, char **argv)
config.print_map_discarded = true;
break;
+ case OPTION_NO_POISON_SYSTEM_DIRECTORIES:
+ command_line.poison_system_directories = FALSE;
+ command_line.poison_system_directories = false;
+ break;
+
+ case OPTION_ERROR_POISON_SYSTEM_DIRECTORIES:
+ command_line.error_poison_system_directories = TRUE;
+ command_line.error_poison_system_directories = true;
+ break;
+
case OPTION_DEPENDENCY_FILE:

View File

@@ -1,4 +1,4 @@
From 5bd94030de598d3a13091dafaed3b956e0ab708f Mon Sep 17 00:00:00 2001
From fb6d52dda9c230baf869ed5f981581a7b5094b70 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Mon, 2 Mar 2015 01:44:14 +0000
Subject: [PATCH] Change default emulation for mips64*-*-linux
@@ -14,10 +14,10 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/bfd/config.bfd b/bfd/config.bfd
index e7b55b0dd78..2caf492e172 100644
index 30087e3b8f8..1896e11790c 100644
--- a/bfd/config.bfd
+++ b/bfd/config.bfd
@@ -896,12 +896,12 @@ case "${targ}" in
@@ -891,12 +891,12 @@ case "${targ}" in
targ_selvecs="mips_elf32_le_vec mips_elf64_be_vec mips_elf64_le_vec mips_ecoff_be_vec mips_ecoff_le_vec"
;;
mips64*el-*-linux*)
@@ -35,10 +35,10 @@ index e7b55b0dd78..2caf492e172 100644
mips*el-*-linux*)
targ_defvec=mips_elf32_trad_le_vec
diff --git a/ld/configure.tgt b/ld/configure.tgt
index 0c780b24d57..47431770a17 100644
index 6205d7c9872..c08533658e5 100644
--- a/ld/configure.tgt
+++ b/ld/configure.tgt
@@ -531,12 +531,12 @@ mips*-*-vxworks*) targ_emul=elf32ebmipvxworks
@@ -530,12 +530,12 @@ mips*-*-vxworks*) targ_emul=elf32ebmipvxworks
;;
mips*-*-windiss) targ_emul=elf32mipswindiss
;;

View File

@@ -1,4 +1,4 @@
From c64a5ca02a55b748311032e2c7d9c4f87bd74c63 Mon Sep 17 00:00:00 2001
From 21920b7a3d10a7dae4c1f18a4bb185de78048e3f Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Sun, 14 Feb 2016 17:06:19 +0000
Subject: [PATCH] Add support for Netlogic XLP
@@ -28,14 +28,14 @@ Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
gas/configure | 3 +++
gas/configure.ac | 3 +++
include/elf/mips.h | 1 +
include/opcode/mips.h | 6 ++++++
include/opcode/mips.h | 8 +++++++-
ld/configure.tgt | 3 +++
opcodes/mips-dis.c | 12 +++++-------
opcodes/mips-opc.c | 31 ++++++++++++++++++++-----------
15 files changed, 65 insertions(+), 21 deletions(-)
15 files changed, 66 insertions(+), 22 deletions(-)
diff --git a/bfd/aoutx.h b/bfd/aoutx.h
index 8025b8c5241..cdcb7876896 100644
index 17560bd8f54..10b1cad74e6 100644
--- a/bfd/aoutx.h
+++ b/bfd/aoutx.h
@@ -810,6 +810,7 @@ NAME (aout, machine_type) (enum bfd_architecture arch,
@@ -47,7 +47,7 @@ index 8025b8c5241..cdcb7876896 100644
arch_flags = M_MIPS2;
break;
diff --git a/bfd/archures.c b/bfd/archures.c
index 8c1d32ca930..b4b2927ebc0 100644
index 390691bfba1..b0b7a5fa7a0 100644
--- a/bfd/archures.c
+++ b/bfd/archures.c
@@ -185,6 +185,7 @@ DESCRIPTION
@@ -59,10 +59,10 @@ index 8c1d32ca930..b4b2927ebc0 100644
.#define bfd_mach_mipsisa32r2 33
.#define bfd_mach_mipsisa32r3 34
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index 7eff85b7eaa..6c9eb12865e 100644
index 57b3c453649..a00b0d44359 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -1590,6 +1590,7 @@ enum bfd_architecture
@@ -1562,6 +1562,7 @@ enum bfd_architecture
#define bfd_mach_mips_octeon3 6503
#define bfd_mach_mips_xlr 887682 /* decimal 'XLR'. */
#define bfd_mach_mips_interaptiv_mr2 736550 /* decimal 'IA2'. */
@@ -71,10 +71,10 @@ index 7eff85b7eaa..6c9eb12865e 100644
#define bfd_mach_mipsisa32r2 33
#define bfd_mach_mipsisa32r3 34
diff --git a/bfd/config.bfd b/bfd/config.bfd
index 2caf492e172..e75417da4d8 100644
index 1896e11790c..8270fd2708d 100644
--- a/bfd/config.bfd
+++ b/bfd/config.bfd
@@ -879,6 +879,11 @@ case "${targ}" in
@@ -874,6 +874,11 @@ case "${targ}" in
targ_defvec=mips_elf32_le_vec
targ_selvecs="mips_elf32_be_vec mips_elf64_be_vec mips_elf64_le_vec"
;;
@@ -87,7 +87,7 @@ index 2caf492e172..e75417da4d8 100644
targ_defvec=mips_elf32_be_vec
targ_selvecs="mips_elf32_le_vec mips_elf64_be_vec mips_elf64_le_vec"
diff --git a/bfd/cpu-mips.c b/bfd/cpu-mips.c
index 5a944ceee81..c57d12ba3dd 100644
index 76b507e3c77..c1563cf4319 100644
--- a/bfd/cpu-mips.c
+++ b/bfd/cpu-mips.c
@@ -108,7 +108,8 @@ enum
@@ -101,17 +101,17 @@ index 5a944ceee81..c57d12ba3dd 100644
#define NN(index) (&arch_info_struct[(index) + 1])
@@ -163,7 +164,8 @@ static const bfd_arch_info_type arch_info_struct[] =
N (64, 64, bfd_mach_mips_xlr, "mips:xlr", FALSE, NN(I_xlr)),
N (32, 32, bfd_mach_mips_interaptiv_mr2, "mips:interaptiv-mr2", FALSE,
N (64, 64, bfd_mach_mips_xlr, "mips:xlr", false, NN(I_xlr)),
N (32, 32, bfd_mach_mips_interaptiv_mr2, "mips:interaptiv-mr2", false,
NN(I_interaptiv_mr2)),
- N (64, 64, bfd_mach_mips_micromips, "mips:micromips", FALSE, NULL)
+ N (64, 64, bfd_mach_mips_micromips, "mips:micromips", FALSE, NN(I_micromips)),
+ N (64, 64, bfd_mach_mips_xlp, "mips:xlp", FALSE, NULL)
- N (64, 64, bfd_mach_mips_micromips, "mips:micromips", false, NULL)
+ N (64, 64, bfd_mach_mips_micromips, "mips:micromips", false, NN(I_micromips)),
+ N (64, 64, bfd_mach_mips_xlp, "mips:xlp", false, NULL)
};
/* The default architecture is mips:3000, but with a machine number of
diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
index 3cbb3cf9495..0c6cd47b40c 100644
index e4827fd17de..fa8c2512837 100644
--- a/bfd/elfxx-mips.c
+++ b/bfd/elfxx-mips.c
@@ -6980,6 +6980,9 @@ _bfd_elf_mips_mach (flagword flags)
@@ -124,7 +124,7 @@ index 3cbb3cf9495..0c6cd47b40c 100644
default:
switch (flags & EF_MIPS_ARCH)
{
@@ -12335,6 +12338,10 @@ mips_set_isa_flags (bfd *abfd)
@@ -12339,6 +12342,10 @@ mips_set_isa_flags (bfd *abfd)
val = E_MIPS_ARCH_64R2 | E_MIPS_MACH_OCTEON2;
break;
@@ -135,7 +135,7 @@ index 3cbb3cf9495..0c6cd47b40c 100644
case bfd_mach_mipsisa32:
val = E_MIPS_ARCH_32;
break;
@@ -14352,6 +14359,7 @@ static const struct mips_mach_extension mips_mach_extensions[] =
@@ -14428,6 +14435,7 @@ static const struct mips_mach_extension mips_mach_extensions[] =
{ bfd_mach_mips_gs264e, bfd_mach_mips_gs464e },
{ bfd_mach_mips_gs464e, bfd_mach_mips_gs464 },
{ bfd_mach_mips_gs464, bfd_mach_mipsisa64r2 },
@@ -144,10 +144,10 @@ index 3cbb3cf9495..0c6cd47b40c 100644
/* MIPS64 extensions. */
{ bfd_mach_mipsisa64r2, bfd_mach_mipsisa64 },
diff --git a/binutils/readelf.c b/binutils/readelf.c
index ad16b4571c9..4bf2b732502 100644
index a6073f7ec80..2f2448b5eba 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -3502,6 +3502,7 @@ get_machine_flags (Filedata * filedata, unsigned e_flags, unsigned e_machine)
@@ -3613,6 +3613,7 @@ get_machine_flags (Filedata * filedata, unsigned e_flags, unsigned e_machine)
case E_MIPS_MACH_OCTEON3: strcat (buf, ", octeon3"); break;
case E_MIPS_MACH_XLR: strcat (buf, ", xlr"); break;
case E_MIPS_MACH_IAMR2: strcat (buf, ", interaptiv-mr2"); break;
@@ -156,10 +156,10 @@ index ad16b4571c9..4bf2b732502 100644
/* We simply ignore the field in this case to avoid confusion:
MIPS ELF does not specify EF_MIPS_MACH, it is a GNU
diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c
index 538b69710f5..b021b64f14b 100644
index 0201f816814..a3cfcdbe982 100644
--- a/gas/config/tc-mips.c
+++ b/gas/config/tc-mips.c
@@ -568,6 +568,7 @@ static int mips_32bitmode = 0;
@@ -570,6 +570,7 @@ static int mips_32bitmode = 0;
|| mips_opts.arch == CPU_RM7000 \
|| mips_opts.arch == CPU_VR5500 \
|| mips_opts.micromips \
@@ -167,7 +167,7 @@ index 538b69710f5..b021b64f14b 100644
)
/* Whether the processor uses hardware interlocks to protect reads
@@ -597,6 +598,7 @@ static int mips_32bitmode = 0;
@@ -599,6 +600,7 @@ static int mips_32bitmode = 0;
&& mips_opts.isa != ISA_MIPS3) \
|| mips_opts.arch == CPU_R4300 \
|| mips_opts.micromips \
@@ -175,7 +175,7 @@ index 538b69710f5..b021b64f14b 100644
)
/* Whether the processor uses hardware interlocks to protect reads
@@ -20156,7 +20158,7 @@ static const struct mips_cpu_info mips_cpu_info_table[] =
@@ -20157,7 +20159,7 @@ static const struct mips_cpu_info mips_cpu_info_table[] =
/* Broadcom XLP.
XLP is mostly like XLR, with the prominent exception that it is
MIPS64R2 rather than MIPS64. */
@@ -185,10 +185,10 @@ index 538b69710f5..b021b64f14b 100644
/* MIPS 64 Release 6. */
{ "i6400", 0, ASE_VIRT | ASE_MSA, ISA_MIPS64R6, CPU_MIPS64R6},
diff --git a/gas/configure b/gas/configure
index d03432c6dc6..d5ae54925e9 100755
index 110d707f079..789d1b38b33 100755
--- a/gas/configure
+++ b/gas/configure
@@ -12761,6 +12761,9 @@ _ACEOF
@@ -12083,6 +12083,9 @@ _ACEOF
mipsisa64r6 | mipsisa64r6el)
mips_cpu=mips64r6
;;
@@ -199,10 +199,10 @@ index d03432c6dc6..d5ae54925e9 100755
mips_cpu=r3900
;;
diff --git a/gas/configure.ac b/gas/configure.ac
index 82706561886..f1c27bf2878 100644
index 78efba88e23..c1b4ef6b3b0 100644
--- a/gas/configure.ac
+++ b/gas/configure.ac
@@ -332,6 +332,9 @@ changequote([,])dnl
@@ -331,6 +331,9 @@ changequote([,])dnl
mipsisa64r6 | mipsisa64r6el)
mips_cpu=mips64r6
;;
@@ -225,10 +225,19 @@ index 4bd86307120..2d7df22abf2 100644
#define E_MIPS_MACH_OCTEON3 0x008e0000
#define E_MIPS_MACH_5400 0x00910000
diff --git a/include/opcode/mips.h b/include/opcode/mips.h
index d1b4a2574ac..879c68fcfd4 100644
index 9add3c9d5bf..a99c53f652f 100644
--- a/include/opcode/mips.h
+++ b/include/opcode/mips.h
@@ -1260,6 +1260,8 @@ static const unsigned int mips_isa_table[] = {
@@ -1157,7 +1157,7 @@ mips_opcode_32bit_p (const struct mips_opcode *mo)
#define INSN_ISA32R3 8
#define INSN_ISA32R5 9
#define INSN_ISA32R6 10
-#define INSN_ISA64 11
+#define INSN_ISA64 11
#define INSN_ISA64R2 12
#define INSN_ISA64R3 13
#define INSN_ISA64R5 14
@@ -1265,6 +1265,8 @@ static const unsigned int mips_isa_table[] = {
#define INSN_XLR 0x00000020
/* Imagination interAptiv MR2. */
#define INSN_INTERAPTIV_MR2 0x04000000
@@ -237,7 +246,7 @@ index d1b4a2574ac..879c68fcfd4 100644
/* DSP ASE */
#define ASE_DSP 0x00000001
@@ -1384,6 +1386,7 @@ static const unsigned int mips_isa_table[] = {
@@ -1389,6 +1391,7 @@ static const unsigned int mips_isa_table[] = {
#define CPU_OCTEON3 6503
#define CPU_XLR 887682 /* decimal 'XLR' */
#define CPU_INTERAPTIV_MR2 736550 /* decimal 'IA2' */
@@ -245,21 +254,21 @@ index d1b4a2574ac..879c68fcfd4 100644
/* Return true if the given CPU is included in INSN_* mask MASK. */
@@ -1461,6 +1464,9 @@ cpu_is_member (int cpu, unsigned int mask)
return ((mask & INSN_ISA_MASK) == INSN_ISA32R6)
|| ((mask & INSN_ISA_MASK) == INSN_ISA64R6);
@@ -1459,6 +1462,9 @@ cpu_is_member (int cpu, unsigned int mask)
case CPU_INTERAPTIV_MR2:
return (mask & INSN_INTERAPTIV_MR2) != 0;
+ case CPU_XLP:
+ return (mask & INSN_XLP) != 0;
+
default:
return FALSE;
return false;
}
diff --git a/ld/configure.tgt b/ld/configure.tgt
index 47431770a17..f714744eab3 100644
index c08533658e5..7abf32215c2 100644
--- a/ld/configure.tgt
+++ b/ld/configure.tgt
@@ -510,6 +510,9 @@ mips*-sde-elf* | mips*-mti-elf* | mips*-img-elf*)
@@ -509,6 +509,9 @@ mips*-sde-elf* | mips*-mti-elf* | mips*-img-elf*)
targ_emul=elf32btsmip
targ_extra_emuls="elf32ltsmip elf32btsmipn32 elf64btsmip elf32ltsmipn32 elf64ltsmip"
;;
@@ -270,10 +279,10 @@ index 47431770a17..f714744eab3 100644
targ_extra_emuls="elf32lr5900"
targ_extra_libpath=$targ_extra_emuls
diff --git a/opcodes/mips-dis.c b/opcodes/mips-dis.c
index 317ced51204..6869f890656 100644
index 591caf11e28..00120afed47 100644
--- a/opcodes/mips-dis.c
+++ b/opcodes/mips-dis.c
@@ -674,13 +674,11 @@ const struct mips_arch_choice mips_arch_choices[] =
@@ -698,13 +698,11 @@ const struct mips_arch_choice mips_arch_choices[] =
mips_cp0sel_names_xlr, ARRAY_SIZE (mips_cp0sel_names_xlr),
mips_cp1_names_mips3264, mips_hwr_names_numeric },
@@ -293,10 +302,10 @@ index 317ced51204..6869f890656 100644
/* This entry, mips16, is here only for ISA/processor selection; do
not print its name. */
diff --git a/opcodes/mips-opc.c b/opcodes/mips-opc.c
index b45eb40bf69..2f4eb5c0354 100644
index db72c039bfd..ff2fa614de1 100644
--- a/opcodes/mips-opc.c
+++ b/opcodes/mips-opc.c
@@ -328,6 +328,7 @@ decode_mips_operand (const char *p)
@@ -329,6 +329,7 @@ decode_mips_operand (const char *p)
#define IOCT3 INSN_OCTEON3
#define XLR INSN_XLR
#define IAMR2 INSN_INTERAPTIV_MR2
@@ -304,15 +313,15 @@ index b45eb40bf69..2f4eb5c0354 100644
#define IVIRT ASE_VIRT
#define IVIRT64 ASE_VIRT64
@@ -990,6 +991,7 @@ const struct mips_opcode mips_builtin_opcodes[] =
@@ -991,6 +992,7 @@ const struct mips_opcode mips_builtin_opcodes[] =
{"clo", "U,s", 0x70000021, 0xfc0007ff, WR_1|RD_2, 0, I32|N55, 0, I37 },
{"clz", "d,s", 0x00000050, 0xfc1f07ff, WR_1|RD_2, 0, I37, 0, 0 },
{"clz", "U,s", 0x70000020, 0xfc0007ff, WR_1|RD_2, 0, I32|N55, 0, I37 },
+{"crc", "d,s,t", 0x7000001c, 0xfc0007ff, WR_1|RD_2|RD_3, 0, XLP, 0, 0 },
/* ctc0 is at the bottom of the table. */
{"ctc1", "t,G", 0x44c00000, 0xffe007ff, RD_1|WR_CC|CM, 0, I1, 0, 0 },
{"ctc1", "t,g", 0x44c00000, 0xffe007ff, RD_1|WR_CC|CM, 0, I1, 0, 0 },
{"ctc1", "t,S", 0x44c00000, 0xffe007ff, RD_1|WR_CC|CM, 0, I1, 0, 0 },
@@ -1022,12 +1024,13 @@ const struct mips_opcode mips_builtin_opcodes[] =
@@ -1023,12 +1025,13 @@ const struct mips_opcode mips_builtin_opcodes[] =
{"daddiu", "t,r,j", 0x64000000, 0xfc000000, WR_1|RD_2, 0, I3, 0, 0 },
{"daddu", "d,v,t", 0x0000002d, 0xfc0007ff, WR_1|RD_2|RD_3, 0, I3, 0, 0 },
{"daddu", "t,r,I", 0, (int) M_DADDU_I, INSN_MACRO, 0, I3, 0, 0 },
@@ -327,7 +336,7 @@ index b45eb40bf69..2f4eb5c0354 100644
/* dctr and dctw are used on the r5000. */
{"dctr", "o(b)", 0xbc050000, 0xfc1f0000, RD_2, 0, I3, 0, 0 },
{"dctw", "o(b)", 0xbc090000, 0xfc1f0000, RD_2, 0, I3, 0, 0 },
@@ -1099,6 +1102,7 @@ const struct mips_opcode mips_builtin_opcodes[] =
@@ -1100,6 +1103,7 @@ const struct mips_opcode mips_builtin_opcodes[] =
{"dmfc0", "t,G,H", 0x40200000, 0xffe007f8, WR_1|RD_C0|LC, 0, I64, 0, 0 },
{"dmfgc0", "t,G", 0x40600100, 0xffe007ff, WR_1|RD_C0|LC, 0, 0, IVIRT64, 0 },
{"dmfgc0", "t,G,H", 0x40600100, 0xffe007f8, WR_1|RD_C0|LC, 0, 0, IVIRT64, 0 },
@@ -335,16 +344,16 @@ index b45eb40bf69..2f4eb5c0354 100644
{"dmt", "", 0x41600bc1, 0xffffffff, TRAP, 0, 0, MT32, 0 },
{"dmt", "t", 0x41600bc1, 0xffe0ffff, WR_1|TRAP, 0, 0, MT32, 0 },
{"dmtc0", "t,G", 0x40a00000, 0xffe007ff, RD_1|WR_C0|WR_CC|CM, 0, I3, 0, EE },
@@ -1114,6 +1118,8 @@ const struct mips_opcode mips_builtin_opcodes[] =
/* dmfc3 is at the bottom of the table. */
/* dmtc3 is at the bottom of the table. */
@@ -1113,6 +1117,8 @@ const struct mips_opcode mips_builtin_opcodes[] =
/* dmfc2 is at the bottom of the table. */
/* dmtc2 is at the bottom of the table. */
{"dmuh", "d,s,t", 0x000000dc, 0xfc0007ff, WR_1|RD_2|RD_3, 0, I69, 0, 0 },
+{"dmtur", "t,d", 0x7000001f, 0xffe007ff, RD_1, 0, XLP, 0, 0 },
+{"dmul", "d,s,t", 0x70000006, 0xfc0007ff, WR_1|RD_2|RD_3, 0, XLP, 0, 0 },
{"dmul", "d,s,t", 0x0000009c, 0xfc0007ff, WR_1|RD_2|RD_3, 0, I69, 0, 0 },
{"dmul", "d,v,t", 0x70000003, 0xfc0007ff, WR_1|RD_2|RD_3|WR_HILO, 0, IOCT, 0, 0 },
{"dmul", "d,v,t", 0, (int) M_DMUL, INSN_MACRO, 0, I3, 0, M32|I69 },
@@ -1267,9 +1273,9 @@ const struct mips_opcode mips_builtin_opcodes[] =
@@ -1266,9 +1272,9 @@ const struct mips_opcode mips_builtin_opcodes[] =
{"ld", "s,-b(+R)", 0xec180000, 0xfc1c0000, WR_1, RD_pc, I69, 0, 0 },
{"ld", "t,A(b)", 0, (int) M_LD_AB, INSN_MACRO, 0, I1, 0, 0 },
{"ld", "t,o(b)", 0xdc000000, 0xfc000000, WR_1|RD_3|LM, 0, I3, 0, 0 },
@@ -357,7 +366,7 @@ index b45eb40bf69..2f4eb5c0354 100644
{"ldc1", "T,o(b)", 0xd4000000, 0xfc000000, WR_1|RD_3|CLD|FP_D, 0, I2, 0, SF },
{"ldc1", "E,o(b)", 0xd4000000, 0xfc000000, WR_1|RD_3|CLD|FP_D, 0, I2, 0, SF },
{"ldc1", "T,A(b)", 0, (int) M_LDC1_AB, INSN_MACRO, INSN2_M_FP_D, I2, 0, SF },
@@ -1438,7 +1444,7 @@ const struct mips_opcode mips_builtin_opcodes[] =
@@ -1437,7 +1443,7 @@ const struct mips_opcode mips_builtin_opcodes[] =
{"mflo", "d,9", 0x00000012, 0xff9f07ff, WR_1|RD_LO, 0, 0, D32, 0 },
{"mflo1", "d", 0x70000012, 0xffff07ff, WR_1|RD_LO, 0, EE, 0, 0 },
{"mflhxu", "d", 0x00000052, 0xffff07ff, WR_1|MOD_HILO, 0, 0, SMT, 0 },
@@ -366,7 +375,7 @@ index b45eb40bf69..2f4eb5c0354 100644
{"mfsa", "d", 0x00000028, 0xffff07ff, WR_1, 0, EE, 0, 0 },
{"min.ob", "X,Y,Q", 0x78000006, 0xfc20003f, WR_1|RD_2|RD_3|FP_D, 0, SB1, MX, 0 },
{"min.ob", "D,S,Q", 0x48000006, 0xfc20003f, WR_1|RD_2|RD_3|FP_D, 0, N54, 0, 0 },
@@ -1483,10 +1489,13 @@ const struct mips_opcode mips_builtin_opcodes[] =
@@ -1482,10 +1488,13 @@ const struct mips_opcode mips_builtin_opcodes[] =
/* move is at the top of the table. */
{"msgn.qh", "X,Y,Q", 0x78200000, 0xfc20003f, WR_1|RD_2|RD_3|FP_D, 0, 0, MX, 0 },
{"msgsnd", "t", 0, (int) M_MSGSND, INSN_MACRO, 0, XLR, 0, 0 },
@@ -382,7 +391,7 @@ index b45eb40bf69..2f4eb5c0354 100644
{"msub.d", "D,R,S,T", 0x4c000029, 0xfc00003f, WR_1|RD_2|RD_3|RD_4|FP_D, 0, I4_33, 0, I37 },
{"msub.d", "D,S,T", 0x46200019, 0xffe0003f, WR_1|RD_2|RD_3|FP_D, 0, IL2E, 0, 0 },
{"msub.d", "D,S,T", 0x72200019, 0xffe0003f, WR_1|RD_2|RD_3|FP_D, 0, IL2F, 0, 0 },
@@ -1536,7 +1545,7 @@ const struct mips_opcode mips_builtin_opcodes[] =
@@ -1535,7 +1544,7 @@ const struct mips_opcode mips_builtin_opcodes[] =
{"mtlo", "s,7", 0x00000013, 0xfc1fe7ff, RD_1|WR_LO, 0, 0, D32, 0 },
{"mtlo1", "s", 0x70000013, 0xfc1fffff, RD_1|WR_LO, 0, EE, 0, 0 },
{"mtlhx", "s", 0x00000053, 0xfc1fffff, RD_1|MOD_HILO, 0, 0, SMT, 0 },
@@ -391,7 +400,7 @@ index b45eb40bf69..2f4eb5c0354 100644
{"mtm0", "s", 0x70000008, 0xfc1fffff, RD_1, 0, IOCT, 0, 0 },
{"mtm0", "s,t", 0x70000008, 0xfc00ffff, RD_1|RD_2, 0, IOCT3, 0, 0 },
{"mtm1", "s", 0x7000000c, 0xfc1fffff, RD_1, 0, IOCT, 0, 0 },
@@ -1978,9 +1987,9 @@ const struct mips_opcode mips_builtin_opcodes[] =
@@ -1977,9 +1986,9 @@ const struct mips_opcode mips_builtin_opcodes[] =
{"suxc1", "S,t(b)", 0x4c00000d, 0xfc0007ff, RD_1|RD_2|RD_3|SM|FP_D, 0, I5_33|N55, 0, I37},
{"sw", "t,o(b)", 0xac000000, 0xfc000000, RD_1|RD_3|SM, 0, I1, 0, 0 },
{"sw", "t,A(b)", 0, (int) M_SW_AB, INSN_MACRO, 0, I1, 0, 0 },
@@ -401,6 +410,6 @@ index b45eb40bf69..2f4eb5c0354 100644
+{"swapw", "t,b", 0x70000014, 0xfc00ffff, MOD_1|RD_2|SM, 0, XLR|XLP, 0, 0 },
+{"swapwu", "t,b", 0x70000015, 0xfc00ffff, MOD_1|RD_2|SM, 0, XLR|XLP, 0, 0 },
+{"swapd", "t,b", 0x70000016, 0xfc00ffff, MOD_1|RD_2|SM, 0, XLR|XLP, 0, 0 },
{"swc0", "E,o(b)", 0xe0000000, 0xfc000000, RD_3|RD_C0|SM, 0, I1, 0, IOCT|IOCTP|IOCT2|I37 },
{"swc0", "E,A(b)", 0, (int) M_SWC0_AB, INSN_MACRO, 0, I1, 0, IOCT|IOCTP|IOCT2|I37 },
{"swc0", "E,o(b)", 0xe0000000, 0xfc000000, RD_3|RD_C0|SM, 0, I1, 0, I2 },
{"swc0", "E,A(b)", 0, (int) M_SWC0_AB, INSN_MACRO, 0, I1, 0, I2 },
{"swc1", "T,o(b)", 0xe4000000, 0xfc000000, RD_1|RD_3|SM|FP_S, 0, I1, 0, 0 },

View File

@@ -1,4 +1,4 @@
From 7f4938d062146e40b4e6d427a5eca6cc6acaaeee Mon Sep 17 00:00:00 2001
From b77c5a67d4ac2513d0b4bab5e4dd1c33b339689b Mon Sep 17 00:00:00 2001
From: Zhenhua Luo <zhenhua.luo@nxp.com>
Date: Sat, 11 Jun 2016 22:08:29 -0500
Subject: [PATCH] fix the incorrect assembling for ppc wait mnemonic
@@ -11,22 +11,22 @@ Upstream-Status: Pending
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/opcodes/ppc-opc.c b/opcodes/ppc-opc.c
index bbbadffad8f..72092355e12 100644
index 13d8b6c3c07..cd979f9c80c 100644
--- a/opcodes/ppc-opc.c
+++ b/opcodes/ppc-opc.c
@@ -6302,8 +6302,6 @@ const struct powerpc_opcode powerpc_opcodes[] = {
@@ -6378,8 +6378,6 @@ const struct powerpc_opcode powerpc_opcodes[] = {
{"waitasec", X(31,30), XRTRARB_MASK, POWER8, POWER9, {0}},
{"waitrsv", XWCPL(31,30,1,0),0xffffffff, POWER10, 0, {0}},
{"pause_short", XWCPL(31,30,2,0),0xffffffff, POWER10, 0, {0}},
{"waitrsv", XWCPL(31,30,1,0),0xffffffff, POWER10, EXT, {0}},
{"pause_short", XWCPL(31,30,2,0),0xffffffff, POWER10, EXT, {0}},
-{"wait", X(31,30), XWCPL_MASK, POWER10, 0, {WC, PL}},
-{"wait", X(31,30), XWC_MASK, POWER9, POWER10, {WC}},
{"lwepx", X(31,31), X_MASK, E500MC|PPCA2, 0, {RT, RA0, RB}},
@@ -6363,7 +6361,7 @@ const struct powerpc_opcode powerpc_opcodes[] = {
@@ -6433,7 +6431,7 @@ const struct powerpc_opcode powerpc_opcodes[] = {
{"waitrsv", X(31,62)|(1<<21), 0xffffffff, E500MC|PPCA2, 0, {0}},
{"waitimpl", X(31,62)|(2<<21), 0xffffffff, E500MC|PPCA2, 0, {0}},
{"waitrsv", X(31,62)|(1<<21), 0xffffffff, E500MC|PPCA2, EXT, {0}},
{"waitimpl", X(31,62)|(2<<21), 0xffffffff, E500MC|PPCA2, EXT, {0}},
-{"wait", X(31,62), XWC_MASK, E500MC|PPCA2, 0, {WC}},
+{"wait", X(31,62), XWC_MASK, E500MC|PPCA2|POWER9|POWER10, 0, {WC}},

View File

@@ -1,4 +1,4 @@
From bb229568e505f2276ca58b72fef6781034fa839f Mon Sep 17 00:00:00 2001
From 02374940dd34fddd2b04624af3f23e01f9cb81cd Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Fri, 31 Mar 2017 11:42:03 -0700
Subject: [PATCH] Detect 64-bit MIPS targets

View File

@@ -1,4 +1,4 @@
From 0e026a8758a5416b548de21d5245477cf8e33ed2 Mon Sep 17 00:00:00 2001
From ff256618bf85acca889920a1fb63ddea64cc98bc Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Mon, 2 Mar 2015 01:42:38 +0000
Subject: [PATCH] Fix rpath in libtool when sysroot is enabled

View File

@@ -1,4 +1,4 @@
From 9d41698ca97b2c5c20ac83147de1f02d385fa66f Mon Sep 17 00:00:00 2001
From 4b612f902c596838ab260194f840a466f8291618 Mon Sep 17 00:00:00 2001
From: Ross Burton <ross.burton@intel.com>
Date: Mon, 6 Mar 2017 23:33:27 -0800
Subject: [PATCH] sync with OE libtool changes

View File

@@ -1,4 +1,4 @@
From 805e3ce0c20bee5049ff167ab6f620a230c6db51 Mon Sep 17 00:00:00 2001
From 707a5d49ecaa4fd722176d764251360a44fc5655 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Wed, 15 Apr 2020 14:17:20 -0700
Subject: [PATCH] Check for clang before checking gcc version
@@ -18,10 +18,10 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/configure b/configure
index 7b369071141..7da69e27ce9 100755
index e8ba1a1d3de..e00d4764583 100755
--- a/configure
+++ b/configure
@@ -5093,7 +5093,7 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
@@ -5275,7 +5275,7 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
@@ -31,10 +31,10 @@ index 7b369071141..7da69e27ce9 100755
#endif
int main() {}
diff --git a/configure.ac b/configure.ac
index 92f01fb3ed7..e99d67ab86b 100644
index 3a8a3ae1f3b..c7f08b802d0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1311,7 +1311,7 @@ if test "$GCC" = yes; then
@@ -1309,7 +1309,7 @@ if test "$GCC" = yes; then
AC_MSG_CHECKING([whether g++ accepts -static-libstdc++ -static-libgcc])
AC_LANG_PUSH(C++)
AC_LINK_IFELSE([AC_LANG_SOURCE([

View File

@@ -1,183 +0,0 @@
From a50c11a7a47b26e6a3e095dfb72aa2e465919fb6 Mon Sep 17 00:00:00 2001
From: Nick Clifton <nickc@redhat.com>
Date: Fri, 5 Mar 2021 17:06:59 +0000
Subject: [PATCH] Add support for the DW_FORM_strx* forms to the BFD library.
PR 27521
* dwarf2.c (is_str_attr): Add DW_FORM_strx* forms.
(read_indexed_string): Placeholder function.
(read_attribute_value): Handle DW_FORM_strx* and DW_FORM_addrx*
forms.
Upstream-Status: Backport [https://sourceware.org/bugzilla/show_bug.cgi?id=27521]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
bfd/dwarf2.c | 105 ++++++++++++++++++++++++++++++++-------------------
1 file changed, 67 insertions(+), 38 deletions(-)
diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c
index 5651696c0f7..5ffcd93f54c 100644
--- a/bfd/dwarf2.c
+++ b/bfd/dwarf2.c
@@ -1160,8 +1160,23 @@ read_abbrevs (bfd *abfd, bfd_uint64_t offset, struct dwarf2_debug *stash,
static inline bfd_boolean
is_str_attr (enum dwarf_form form)
{
- return (form == DW_FORM_string || form == DW_FORM_strp
- || form == DW_FORM_line_strp || form == DW_FORM_GNU_strp_alt);
+ return (form == DW_FORM_string
+ || form == DW_FORM_strp
+ || form == DW_FORM_strx
+ || form == DW_FORM_strx1
+ || form == DW_FORM_strx2
+ || form == DW_FORM_strx3
+ || form == DW_FORM_strx4
+ || form == DW_FORM_line_strp
+ || form == DW_FORM_GNU_strp_alt);
+}
+
+static const char *
+read_indexed_string (bfd_uint64_t index ATTRIBUTE_UNUSED,
+ struct comp_unit * unit ATTRIBUTE_UNUSED)
+{
+ /* FIXME: Add support for indexed strings. */
+ return "<indexed strings not yet supported>";
}
/* Read and fill in the value of attribute ATTR as described by FORM.
@@ -1192,6 +1207,9 @@ read_attribute_value (struct attribute * attr,
switch (form)
{
+ case DW_FORM_flag_present:
+ attr->u.val = 1;
+ break;
case DW_FORM_ref_addr:
/* DW_FORM_ref_addr is an address in DWARF2, and an offset in
DWARF3. */
@@ -1237,15 +1255,32 @@ read_attribute_value (struct attribute * attr,
info_ptr = read_n_bytes (info_ptr, info_ptr_end, blk);
attr->u.blk = blk;
break;
+ case DW_FORM_ref1:
+ case DW_FORM_flag:
+ case DW_FORM_data1:
+ case DW_FORM_addrx1:
+ attr->u.val = read_1_byte (abfd, info_ptr, info_ptr_end);
+ info_ptr += 1;
+ break;
case DW_FORM_data2:
+ case DW_FORM_ref2:
attr->u.val = read_2_bytes (abfd, info_ptr, info_ptr_end);
info_ptr += 2;
break;
+ case DW_FORM_addrx3:
+ attr->u.val = read_4_bytes (abfd, info_ptr, info_ptr_end);
+ attr->u.val &= 0xffffff;
+ info_ptr += 3;
+ break;
+ case DW_FORM_ref4:
case DW_FORM_data4:
+ case DW_FORM_addrx4:
attr->u.val = read_4_bytes (abfd, info_ptr, info_ptr_end);
info_ptr += 4;
break;
case DW_FORM_data8:
+ case DW_FORM_ref8:
+ case DW_FORM_ref_sig8:
attr->u.val = read_8_bytes (abfd, info_ptr, info_ptr_end);
info_ptr += 8;
break;
@@ -1265,6 +1300,33 @@ read_attribute_value (struct attribute * attr,
attr->u.str = read_alt_indirect_string (unit, info_ptr, info_ptr_end, &bytes_read);
info_ptr += bytes_read;
break;
+ case DW_FORM_strx1:
+ attr->u.val = read_1_byte (abfd, info_ptr, info_ptr_end);
+ info_ptr += 1;
+ attr->u.str = (char *) read_indexed_string (attr->u.val, unit);
+ break;
+ case DW_FORM_strx2:
+ attr->u.val = read_2_bytes (abfd, info_ptr, info_ptr_end);
+ info_ptr += 2;
+ attr->u.str = (char *) read_indexed_string (attr->u.val, unit);
+ break;
+ case DW_FORM_strx3:
+ attr->u.val = read_4_bytes (abfd, info_ptr, info_ptr_end);
+ info_ptr += 3;
+ attr->u.val &= 0xffffff;
+ attr->u.str = (char *) read_indexed_string (attr->u.val, unit);
+ break;
+ case DW_FORM_strx4:
+ attr->u.val = read_4_bytes (abfd, info_ptr, info_ptr_end);
+ info_ptr += 4;
+ attr->u.str = (char *) read_indexed_string (attr->u.val, unit);
+ break;
+ case DW_FORM_strx:
+ attr->u.val = _bfd_safe_read_leb128 (abfd, info_ptr, &bytes_read,
+ FALSE, info_ptr_end);
+ info_ptr += bytes_read;
+ attr->u.str = (char *) read_indexed_string (attr->u.val, unit);
+ break;
case DW_FORM_exprloc:
case DW_FORM_block:
amt = sizeof (struct dwarf_block);
@@ -1287,48 +1349,14 @@ read_attribute_value (struct attribute * attr,
info_ptr = read_n_bytes (info_ptr, info_ptr_end, blk);
attr->u.blk = blk;
break;
- case DW_FORM_data1:
- attr->u.val = read_1_byte (abfd, info_ptr, info_ptr_end);
- info_ptr += 1;
- break;
- case DW_FORM_flag:
- attr->u.val = read_1_byte (abfd, info_ptr, info_ptr_end);
- info_ptr += 1;
- break;
- case DW_FORM_flag_present:
- attr->u.val = 1;
- break;
case DW_FORM_sdata:
attr->u.sval = _bfd_safe_read_leb128 (abfd, info_ptr, &bytes_read,
TRUE, info_ptr_end);
info_ptr += bytes_read;
break;
- case DW_FORM_udata:
- attr->u.val = _bfd_safe_read_leb128 (abfd, info_ptr, &bytes_read,
- FALSE, info_ptr_end);
- info_ptr += bytes_read;
- break;
- case DW_FORM_ref1:
- attr->u.val = read_1_byte (abfd, info_ptr, info_ptr_end);
- info_ptr += 1;
- break;
- case DW_FORM_ref2:
- attr->u.val = read_2_bytes (abfd, info_ptr, info_ptr_end);
- info_ptr += 2;
- break;
- case DW_FORM_ref4:
- attr->u.val = read_4_bytes (abfd, info_ptr, info_ptr_end);
- info_ptr += 4;
- break;
- case DW_FORM_ref8:
- attr->u.val = read_8_bytes (abfd, info_ptr, info_ptr_end);
- info_ptr += 8;
- break;
- case DW_FORM_ref_sig8:
- attr->u.val = read_8_bytes (abfd, info_ptr, info_ptr_end);
- info_ptr += 8;
- break;
case DW_FORM_ref_udata:
+ case DW_FORM_udata:
+ case DW_FORM_addrx:
attr->u.val = _bfd_safe_read_leb128 (abfd, info_ptr, &bytes_read,
FALSE, info_ptr_end);
info_ptr += bytes_read;
@@ -1361,6 +1389,7 @@ read_attribute_value (struct attribute * attr,
info_ptr = read_n_bytes (info_ptr, info_ptr_end, blk);
attr->u.blk = blk;
break;
+
default:
_bfd_error_handler (_("DWARF error: invalid or unhandled FORM value: %#x"),
form);

View File

@@ -1,388 +0,0 @@
From d3edaa91d4cf7202ec14342410194841e2f67f12 Mon Sep 17 00:00:00 2001
From: Alan Modra <amodra@gmail.com>
Date: Fri, 26 Feb 2021 11:30:32 +1030
Subject: [PATCH] Reinstate various pieces backed out from smart_rename changes
In the interests of a stable release various last minute smart_rename
patches were backed out of the 2.36 branch. The main reason to
reinstate some of those backed out changes here is to make necessary
followup fixes to commit 8e03235147a9 simple cherry-picks from
mainline. A secondary reason is that ar -M support isn't fixed for
pr26945 without this patch.
PR 26945
* ar.c: Don't include libbfd.h.
(write_archive): Replace xmalloc+strcpy with xstrdup.
* arsup.c (temp_name, real_ofd): New static variables.
(ar_open): Use make_tempname and bfd_fdopenw.
(ar_save): Adjust to suit ar_open changes.
* objcopy.c: Don't include libbfd.h.
* rename.c: Rename and reorder variables.
(cherry picked from commit 95b91a043aeaeb546d2fea556d84a2de1e917770)
Upstream-Status: Backport [https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=d3edaa91d4cf7202ec14342410194841e2f67f12]
CVE: CVE-2021-20197
Signed-off-by: Vinay Kumar <vinay.m.engg@gmail.com>
---
binutils/ar.c | 6 +-
binutils/arsup.c | 37 ++++++++----
binutils/bucomm.h | 3 +-
binutils/objcopy.c | 9 +--
binutils/rename.c | 148 +++++++++++----------------------------------
5 files changed, 67 insertions(+), 136 deletions(-)
diff --git a/binutils/ar.c b/binutils/ar.c
index 45a34e3a6cf..44df48c5c67 100644
--- a/binutils/ar.c
+++ b/binutils/ar.c
@@ -25,7 +25,6 @@
#include "sysdep.h"
#include "bfd.h"
-#include "libbfd.h"
#include "libiberty.h"
#include "progress.h"
#include "getopt.h"
@@ -1255,8 +1254,7 @@ write_archive (bfd *iarch)
bfd *contents_head = iarch->archive_next;
int ofd = -1;
- old_name = (char *) xmalloc (strlen (bfd_get_filename (iarch)) + 1);
- strcpy (old_name, bfd_get_filename (iarch));
+ old_name = xstrdup (bfd_get_filename (iarch));
new_name = make_tempname (old_name, &ofd);
if (new_name == NULL)
@@ -1308,7 +1306,7 @@ write_archive (bfd *iarch)
/* We don't care if this fails; we might be creating the archive. */
bfd_close (iarch);
- if (smart_rename (new_name, old_name, 0) != 0)
+ if (smart_rename (new_name, old_name, NULL) != 0)
xexit (1);
free (old_name);
free (new_name);
diff --git a/binutils/arsup.c b/binutils/arsup.c
index 5403a0c5d74..f7ce8f0bc82 100644
--- a/binutils/arsup.c
+++ b/binutils/arsup.c
@@ -42,6 +42,8 @@ extern int deterministic;
static bfd *obfd;
static char *real_name;
+static char *temp_name;
+static int real_ofd;
static FILE *outfile;
static void
@@ -149,27 +151,24 @@ maybequit (void)
void
ar_open (char *name, int t)
{
- char *tname;
- const char *bname = lbasename (name);
- real_name = name;
+ real_name = xstrdup (name);
+ temp_name = make_tempname (real_name, &real_ofd);
- /* Prepend tmp- to the beginning, to avoid file-name clashes after
- truncation on filesystems with limited namespaces (DOS). */
- if (asprintf (&tname, "%.*stmp-%s", (int) (bname - name), name, bname) == -1)
+ if (temp_name == NULL)
{
- fprintf (stderr, _("%s: Can't allocate memory for temp name (%s)\n"),
+ fprintf (stderr, _("%s: Can't open temporary file (%s)\n"),
program_name, strerror(errno));
maybequit ();
return;
}
- obfd = bfd_openw (tname, NULL);
+ obfd = bfd_fdopenw (temp_name, NULL, real_ofd);
if (!obfd)
{
fprintf (stderr,
_("%s: Can't open output archive %s\n"),
- program_name, tname);
+ program_name, temp_name);
maybequit ();
}
@@ -344,16 +343,30 @@ ar_save (void)
}
else
{
- char *ofilename = xstrdup (bfd_get_filename (obfd));
+ struct stat target_stat;
if (deterministic > 0)
obfd->flags |= BFD_DETERMINISTIC_OUTPUT;
bfd_close (obfd);
- smart_rename (ofilename, real_name, 0);
+ if (stat (real_name, &target_stat) != 0)
+ {
+ /* The temp file created in ar_open has mode 0600 as per mkstemp.
+ Create the real empty output file here so smart_rename will
+ update the mode according to the process umask. */
+ obfd = bfd_openw (real_name, NULL);
+ if (obfd != NULL)
+ {
+ bfd_set_format (obfd, bfd_archive);
+ bfd_close (obfd);
+ }
+ }
+
+ smart_rename (temp_name, real_name, NULL);
obfd = 0;
- free (ofilename);
+ free (temp_name);
+ free (real_name);
}
}
diff --git a/binutils/bucomm.h b/binutils/bucomm.h
index 91f6a5b228f..aa7e33d8cd1 100644
--- a/binutils/bucomm.h
+++ b/binutils/bucomm.h
@@ -71,7 +71,8 @@ extern void print_version (const char *);
/* In rename.c. */
extern void set_times (const char *, const struct stat *);
-extern int smart_rename (const char *, const char *, int);
+extern int smart_rename (const char *, const char *, struct stat *);
+
/* In libiberty. */
void *xmalloc (size_t);
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index eab3b6db585..73aa8bc2514 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -20,7 +20,6 @@
#include "sysdep.h"
#include "bfd.h"
-#include "libbfd.h"
#include "progress.h"
#include "getopt.h"
#include "libiberty.h"
@@ -4861,12 +4860,10 @@ strip_main (int argc, char *argv[])
output_target, NULL);
if (status == 0)
{
- if (preserve_dates)
- set_times (tmpname, &statbuf);
if (output_file != tmpname)
status = (smart_rename (tmpname,
output_file ? output_file : argv[i],
- preserve_dates) != 0);
+ preserve_dates ? &statbuf : NULL) != 0);
if (status == 0)
status = hold_status;
}
@@ -5931,11 +5928,9 @@ copy_main (int argc, char *argv[])
output_target, input_arch);
if (status == 0)
{
- if (preserve_dates)
- set_times (tmpname, &statbuf);
if (tmpname != output_filename)
status = (smart_rename (tmpname, input_filename,
- preserve_dates) != 0);
+ preserve_dates ? &statbuf : NULL) != 0);
}
else
unlink_if_ordinary (tmpname);
diff --git a/binutils/rename.c b/binutils/rename.c
index 65ad5bf52c4..72a9323d72c 100644
--- a/binutils/rename.c
+++ b/binutils/rename.c
@@ -24,14 +24,9 @@
#ifdef HAVE_GOOD_UTIME_H
#include <utime.h>
-#else /* ! HAVE_GOOD_UTIME_H */
-#ifdef HAVE_UTIMES
+#elif defined HAVE_UTIMES
#include <sys/time.h>
-#endif /* HAVE_UTIMES */
-#endif /* ! HAVE_GOOD_UTIME_H */
-
-#if ! defined (_WIN32) || defined (__CYGWIN32__)
-static int simple_copy (const char *, const char *);
+#endif
/* The number of bytes to copy at once. */
#define COPY_BUF 8192
@@ -82,7 +77,6 @@ simple_copy (const char *from, const char *to)
}
return 0;
}
-#endif /* __CYGWIN32__ or not _WIN32 */
/* Set the times of the file DESTINATION to be the same as those in
STATBUF. */
@@ -91,122 +85,52 @@ void
set_times (const char *destination, const struct stat *statbuf)
{
int result;
-
- {
#ifdef HAVE_GOOD_UTIME_H
- struct utimbuf tb;
-
- tb.actime = statbuf->st_atime;
- tb.modtime = statbuf->st_mtime;
- result = utime (destination, &tb);
-#else /* ! HAVE_GOOD_UTIME_H */
-#ifndef HAVE_UTIMES
- long tb[2];
-
- tb[0] = statbuf->st_atime;
- tb[1] = statbuf->st_mtime;
- result = utime (destination, tb);
-#else /* HAVE_UTIMES */
- struct timeval tv[2];
-
- tv[0].tv_sec = statbuf->st_atime;
- tv[0].tv_usec = 0;
- tv[1].tv_sec = statbuf->st_mtime;
- tv[1].tv_usec = 0;
- result = utimes (destination, tv);
-#endif /* HAVE_UTIMES */
-#endif /* ! HAVE_GOOD_UTIME_H */
- }
+ struct utimbuf tb;
+
+ tb.actime = statbuf->st_atime;
+ tb.modtime = statbuf->st_mtime;
+ result = utime (destination, &tb);
+#elif defined HAVE_UTIMES
+ struct timeval tv[2];
+
+ tv[0].tv_sec = statbuf->st_atime;
+ tv[0].tv_usec = 0;
+ tv[1].tv_sec = statbuf->st_mtime;
+ tv[1].tv_usec = 0;
+ result = utimes (destination, tv);
+#else
+ long tb[2];
+
+ tb[0] = statbuf->st_atime;
+ tb[1] = statbuf->st_mtime;
+ result = utime (destination, tb);
+#endif
if (result != 0)
non_fatal (_("%s: cannot set time: %s"), destination, strerror (errno));
}
-#ifndef S_ISLNK
-#ifdef S_IFLNK
-#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
-#else
-#define S_ISLNK(m) 0
-#define lstat stat
-#endif
-#endif
-
-/* Rename FROM to TO, copying if TO is a link.
- Return 0 if ok, -1 if error. */
+/* Copy FROM to TO. TARGET_STAT has the file status that, if non-NULL,
+ is used to fix up timestamps. Return 0 if ok, -1 if error.
+ At one time this function renamed files, but file permissions are
+ tricky to update given the number of different schemes used by
+ various systems. So now we just copy. */
int
-smart_rename (const char *from, const char *to, int preserve_dates ATTRIBUTE_UNUSED)
+smart_rename (const char *from, const char *to,
+ struct stat *target_stat)
{
- bfd_boolean exists;
- struct stat s;
- int ret = 0;
-
- exists = lstat (to, &s) == 0;
-
-#if defined (_WIN32) && !defined (__CYGWIN32__)
- /* Win32, unlike unix, will not erase `to' in `rename(from, to)' but
- fail instead. Also, chown is not present. */
+ int ret;
- if (exists)
- remove (to);
-
- ret = rename (from, to);
+ ret = simple_copy (from, to);
if (ret != 0)
- {
- /* We have to clean up here. */
- non_fatal (_("unable to rename '%s'; reason: %s"), to, strerror (errno));
- unlink (from);
- }
-#else
- /* Use rename only if TO is not a symbolic link and has
- only one hard link, and we have permission to write to it. */
- if (! exists
- || (!S_ISLNK (s.st_mode)
- && S_ISREG (s.st_mode)
- && (s.st_mode & S_IWUSR)
- && s.st_nlink == 1)
- )
- {
- ret = rename (from, to);
- if (ret == 0)
- {
- if (exists)
- {
- /* Try to preserve the permission bits and ownership of
- TO. First get the mode right except for the setuid
- bit. Then change the ownership. Then fix the setuid
- bit. We do the chmod before the chown because if the
- chown succeeds, and we are a normal user, we won't be
- able to do the chmod afterward. We don't bother to
- fix the setuid bit first because that might introduce
- a fleeting security problem, and because the chown
- will clear the setuid bit anyhow. We only fix the
- setuid bit if the chown succeeds, because we don't
- want to introduce an unexpected setuid file owned by
- the user running objcopy. */
- chmod (to, s.st_mode & 0777);
- if (chown (to, s.st_uid, s.st_gid) >= 0)
- chmod (to, s.st_mode & 07777);
- }
- }
- else
- {
- /* We have to clean up here. */
- non_fatal (_("unable to rename '%s'; reason: %s"), to, strerror (errno));
- unlink (from);
- }
- }
- else
- {
- ret = simple_copy (from, to);
- if (ret != 0)
- non_fatal (_("unable to copy file '%s'; reason: %s"), to, strerror (errno));
+ non_fatal (_("unable to copy file '%s'; reason: %s"),
+ to, strerror (errno));
- if (preserve_dates)
- set_times (to, &s);
- unlink (from);
- }
-#endif /* _WIN32 && !__CYGWIN32__ */
+ if (target_stat != NULL)
+ set_times (to, target_stat);
+ unlink (from);
return ret;
}
--
2.17.1