binutils: Upgrade to binutils 2.32

Changes
https://sourceware.org/ml/binutils/2019-02/msg00010.html

0007-Add-the-armv5e-architecture-to-binutils.patch is dropped since we
armv5 is not a used option anymore in OE armv5te is default, and gcc9
will drop it completely anyway

CVE patches were backports from master which is already past of 2.32
release

Other dropped patches were partial or full backports as well

(From OE-Core rev: b71294c4decf35d544a2c8adb4e67d141841fc68)

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Khem Raj
2019-02-04 13:18:08 -08:00
committed by Richard Purdie
parent 3c6764b098
commit db9bca2b3b
31 changed files with 865 additions and 2011 deletions

View File

@@ -20,7 +20,7 @@ PREFERRED_PROVIDER_virtual/gettext ??= "gettext"
GCCVERSION ?= "8.%"
SDKGCCVERSION ?= "${GCCVERSION}"
BINUVERSION ?= "2.31%"
BINUVERSION ?= "2.32%"
GDBVERSION ?= "8.2%"
GLIBCVERSION ?= "2.29%"
LINUXLIBCVERSION ?= "4.19%"

View File

@@ -14,38 +14,30 @@ def binutils_branch_version(d):
pvsplit = d.getVar('PV').split('.')
return pvsplit[0] + "_" + pvsplit[1]
PV = "2.32.0"
BINUPV = "${@binutils_branch_version(d)}"
PV .= ".1"
#BRANCH = "binutils-${BINUPV}-branch"
BRANCH ?= "binutils-2_32-branch"
UPSTREAM_CHECK_GITTAGREGEX = "binutils-(?P<pver>\d+_(\d_?)*)"
SRCREV ?= "c909e7afdc4710851a53e86ebed8cea3879b26e5"
BINUTILS_GIT_URI ?= "git://sourceware.org/git/binutils-gdb.git;branch=binutils-${BINUPV}-branch;protocol=git"
SRCREV ?= "b8c1f608db9ef3edd483d21a921d1fbedc71df6f"
BINUTILS_GIT_URI ?= "git://sourceware.org/git/binutils-gdb.git;branch=${BRANCH};protocol=git"
SRC_URI = "\
${BINUTILS_GIT_URI} \
file://0003-configure-widen-the-regexp-for-SH-architectures.patch \
file://0004-Point-scripts-location-to-libdir.patch \
file://0005-Only-generate-an-RPATH-entry-if-LD_RUN_PATH-is-not-e.patch \
file://0006-Use-libtool-2.4.patch \
file://0007-Add-the-armv5e-architecture-to-binutils.patch \
file://0008-don-t-let-the-distro-compiler-point-to-the-wrong-ins.patch \
file://0009-warn-for-uses-of-system-directories-when-cross-linki.patch \
file://0010-Fix-rpath-in-libtool-when-sysroot-is-enabled.patch \
file://0011-Change-default-emulation-for-mips64-linux.patch \
file://0012-Add-support-for-Netlogic-XLP.patch \
file://0013-fix-the-incorrect-assembling-for-ppc-wait-mnemonic.patch \
file://0014-Detect-64-bit-MIPS-targets.patch \
file://0015-sync-with-OE-libtool-changes.patch \
file://0016-add-i386pep-emulation-for-x86_64.patch \
file://0022-Handle-ELF-compressed-header-alignment-correctly-by-.patch \
file://0023-gold-Get-alignment-of-uncompressed-section-from-ch_a.patch \
file://clang-bfd-fix.patch \
file://CVE-2018-17358.patch \
file://CVE-2018-17360.patch \
file://CVE-2018-18309.patch \
file://CVE-2018-18605.patch \
file://CVE-2018-18606.patch \
file://CVE-2018-18607.patch \
file://0007-don-t-let-the-distro-compiler-point-to-the-wrong-ins.patch \
file://0008-warn-for-uses-of-system-directories-when-cross-linki.patch \
file://0009-Fix-rpath-in-libtool-when-sysroot-is-enabled.patch \
file://0010-Change-default-emulation-for-mips64-linux.patch \
file://0011-Add-support-for-Netlogic-XLP.patch \
file://0012-fix-the-incorrect-assembling-for-ppc-wait-mnemonic.patch \
file://0013-Detect-64-bit-MIPS-targets.patch \
file://0014-sync-with-OE-libtool-changes.patch \
file://0015-binutils-enable-x86_64-pep-for-producing-EFI-binarie.patch \
"
S = "${WORKDIR}/git"

View File

@@ -1,4 +1,4 @@
From 4a99f058030c86794bb96b582a7dbd631f963b06 Mon Sep 17 00:00:00 2001
From 5bcd884f8af5106d0fa380c42cffe07f3c993ed2 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 01/15] binutils-crosssdk: Generate relocatable SDKs
@@ -18,10 +18,10 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/ld/genscripts.sh b/ld/genscripts.sh
index 370b22269d..a5c367aa8f 100755
index 77ddbbc8f8..d789e77943 100755
--- a/ld/genscripts.sh
+++ b/ld/genscripts.sh
@@ -279,6 +279,7 @@ DATA_ALIGNMENT_u="${DATA_ALIGNMENT_u-${DATA_ALIGNMENT_r}}"
@@ -310,6 +310,7 @@ DATA_ALIGNMENT_u="${DATA_ALIGNMENT_u-${DATA_ALIGNMENT_r}}"
LD_FLAG=r
DATA_ALIGNMENT=${DATA_ALIGNMENT_r}
DEFAULT_DATA_ALIGNMENT="ALIGN(${SEGMENT_SIZE})"
@@ -29,7 +29,7 @@ index 370b22269d..a5c367aa8f 100755
( echo "/* Script for ld -r: link without relocation */"
. ${CUSTOMIZER_SCRIPT}
. ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
@@ -287,10 +288,12 @@ DEFAULT_DATA_ALIGNMENT="ALIGN(${SEGMENT_SIZE})"
@@ -318,10 +319,12 @@ DEFAULT_DATA_ALIGNMENT="ALIGN(${SEGMENT_SIZE})"
LD_FLAG=u
DATA_ALIGNMENT=${DATA_ALIGNMENT_u}
CONSTRUCTING=" "
@@ -43,7 +43,7 @@ index 370b22269d..a5c367aa8f 100755
DATA_ALIGNMENT=${DATA_ALIGNMENT_}
RELOCATING=" "
diff --git a/ld/scripttempl/elf.sc b/ld/scripttempl/elf.sc
index 444aef2942..afa99f736d 100644
index bd7584120e..8bbe052d4b 100644
--- a/ld/scripttempl/elf.sc
+++ b/ld/scripttempl/elf.sc
@@ -139,8 +139,8 @@ if test -z "$DATA_SEGMENT_ALIGN"; then
@@ -58,5 +58,5 @@ index 444aef2942..afa99f736d 100644
if test -z "$PLT"; then
IPLT=".iplt ${RELOCATING-0} : { *(.iplt) }"
--
2.18.0
2.20.1

View File

@@ -1,4 +1,4 @@
From 6e78b1c88c040a742b7af82542ac7eb92eddda3d Mon Sep 17 00:00:00 2001
From 11927913560fc5a5d51af3bc5eb8ad62a86c9840 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 02/15] binutils-cross: Do not generate linker script
@@ -23,10 +23,10 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
1 file changed, 25 deletions(-)
diff --git a/ld/genscripts.sh b/ld/genscripts.sh
index a5c367aa8f..6cc9eed976 100755
index d789e77943..144e2e8736 100755
--- a/ld/genscripts.sh
+++ b/ld/genscripts.sh
@@ -189,31 +189,6 @@ append_to_lib_path()
@@ -220,31 +220,6 @@ append_to_lib_path()
fi
}
@@ -59,5 +59,5 @@ index a5c367aa8f..6cc9eed976 100755
libs=${NATIVE_LIB_DIRS}
if [ "x${NATIVE}" = "xyes" ] ; then
--
2.18.0
2.20.1

View File

@@ -1,4 +1,4 @@
From 4c6fd8f5eb9bc7c0d02f1a98ad86e395d4d2ab3b Mon Sep 17 00:00:00 2001
From da3939de6fb36da2c6484f14f08a37be195d9dc3 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 03/15] configure: widen the regexp for SH architectures
@@ -14,10 +14,10 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/configure b/configure
index 08dd35c3ea..815e74ddb7 100755
index 3747645961..78b5240101 100755
--- a/configure
+++ b/configure
@@ -3855,7 +3855,7 @@ case "${target}" in
@@ -3861,7 +3861,7 @@ case "${target}" in
nvptx*-*-*)
noconfigdirs="$noconfigdirs target-libssp target-libstdc++-v3 target-libobjc"
;;
@@ -27,7 +27,7 @@ index 08dd35c3ea..815e74ddb7 100755
sh*-*-elf)
;;
diff --git a/gprof/configure b/gprof/configure
index 447cea7884..a730e20509 100755
index f84efaba20..ab32bab2b6 100755
--- a/gprof/configure
+++ b/gprof/configure
@@ -6162,6 +6162,11 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu)
@@ -43,5 +43,5 @@ index 447cea7884..a730e20509 100755
if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
--
2.18.0
2.20.1

View File

@@ -1,4 +1,4 @@
From 48ad5292b10408d4e5d5739022753a7183a1cbb3 Mon Sep 17 00:00:00 2001
From fc1ff860fd88fa2d0584bd19181c880a76331a8d 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 04/15] 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 d86ad0940c..c95b0ef025 100644
index c2c798b4fe..d7faf19271 100644
--- a/ld/Makefile.am
+++ b/ld/Makefile.am
@@ -57,7 +57,7 @@ endif
@@ -25,7 +25,7 @@ index d86ad0940c..c95b0ef025 100644
EMUL = @EMUL@
EMULATION_OFILES = @EMULATION_OFILES@
diff --git a/ld/Makefile.in b/ld/Makefile.in
index 4792b2b013..789df2d01b 100644
index fc687fc516..8b14f5236c 100644
--- a/ld/Makefile.in
+++ b/ld/Makefile.in
@@ -563,7 +563,7 @@ AM_CFLAGS = $(WARN_CFLAGS) $(ELF_CLFAGS)
@@ -38,5 +38,5 @@ index 4792b2b013..789df2d01b 100644
BFDDIR = $(BASEDIR)/bfd
INCDIR = $(BASEDIR)/include
--
2.18.0
2.20.1

View File

@@ -1,4 +1,4 @@
From 79e53510b1f9e16a21db312698fb1c1c442481e7 Mon Sep 17 00:00:00 2001
From 66861bff389434e3454c7650ee29fade7a1cc5ed 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 05/15] Only generate an RPATH entry if LD_RUN_PATH is not
@@ -15,7 +15,7 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
1 file changed, 4 insertions(+)
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
index 1ad9d6b6fa..6a025a45b4 100644
index f4f7ad6b4e..cfd787ff28 100644
--- a/ld/emultempl/elf32.em
+++ b/ld/emultempl/elf32.em
@@ -1471,6 +1471,8 @@ fragment <<EOF
@@ -27,7 +27,7 @@ index 1ad9d6b6fa..6a025a45b4 100644
if (path
&& gld${EMULATION_NAME}_search_needed (path, &n, force))
break;
@@ -1751,6 +1753,8 @@ gld${EMULATION_NAME}_before_allocation (void)
@@ -1746,6 +1748,8 @@ gld${EMULATION_NAME}_before_allocation (void)
rpath = command_line.rpath;
if (rpath == NULL)
rpath = (const char *) getenv ("LD_RUN_PATH");
@@ -37,5 +37,5 @@ index 1ad9d6b6fa..6a025a45b4 100644
for (abfd = link_info.input_bfds; abfd; abfd = abfd->link.next)
if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
--
2.18.0
2.20.1

View File

@@ -1,35 +0,0 @@
From ef50d848d983f81e4a86dd3eef4933e3579336f1 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Mon, 2 Mar 2015 01:37:10 +0000
Subject: [PATCH 07/15] Add the armv5e architecture to binutils
Binutils has a comment that indicates it is supposed to match gcc for
all of the support "-march=" settings, but it was lacking the armv5e setting.
This was a simple way to add it, as thumb instructions shouldn't be generated
by the compiler anyway.
Upstream-Status: Denied
Upstream maintainer indicated that we should not be using armv5e, even
though it is a legal archicture defined by our gcc.
Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
gas/config/tc-arm.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/gas/config/tc-arm.c b/gas/config/tc-arm.c
index 3f5384e1c7..8d5bc145af 100644
--- a/gas/config/tc-arm.c
+++ b/gas/config/tc-arm.c
@@ -26294,6 +26294,7 @@ static const struct arm_arch_option_table arm_archs[] =
ARM_ARCH_OPT ("armv4t", ARM_ARCH_V4T, FPU_ARCH_FPA),
ARM_ARCH_OPT ("armv4txm", ARM_ARCH_V4TxM, FPU_ARCH_FPA),
ARM_ARCH_OPT ("armv5", ARM_ARCH_V5, FPU_ARCH_VFP),
+ ARM_ARCH_OPT ("armv5e", ARM_ARCH_V5TE, FPU_ARCH_VFP),
ARM_ARCH_OPT ("armv5t", ARM_ARCH_V5T, FPU_ARCH_VFP),
ARM_ARCH_OPT ("armv5txm", ARM_ARCH_V5TxM, FPU_ARCH_VFP),
ARM_ARCH_OPT ("armv5te", ARM_ARCH_V5TE, FPU_ARCH_VFP),
--
2.18.0

View File

@@ -1,7 +1,7 @@
From ca25d55cef8398bad508c2b2be29aea5aa3c4d26 Mon Sep 17 00:00:00 2001
From 8cb013106c379e81fe40cfdf486d9805c9e276ad 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 08/15] don't let the distro compiler point to the wrong
Subject: [PATCH 07/15] don't let the distro compiler point to the wrong
installation location
Thanks to RP for helping find the source code causing the issue.
@@ -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 ed1b334c36..d4ffd8b57b 100644
index 0be45b4ae8..4817616bb2 100644
--- a/libiberty/Makefile.in
+++ b/libiberty/Makefile.in
@@ -364,7 +364,8 @@ install-strip: install
@@ -31,5 +31,5 @@ index ed1b334c36..d4ffd8b57b 100644
if test -n "${target_header_dir}"; then \
${mkinstalldirs} $(DESTDIR)$(libdir)/$(MULTIOSDIR); \
--
2.18.0
2.20.1

View File

@@ -1,7 +1,7 @@
From a3667059fc0d52d890b505bed0e5050ea3d7002e Mon Sep 17 00:00:00 2001
From 98f68c0892ba4bbd53b0a0a4cbbdf0b7197e0320 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 09/15] warn for uses of system directories when cross linking
Subject: [PATCH 08/15] warn for uses of system directories when cross linking
2008-07-02 Joseph Myers <joseph@codesourcery.com>
@@ -77,7 +77,7 @@ index d93c9b0830..5da2742bea 100644
#undef EXTRA_SHLIB_EXTENSION
diff --git a/ld/configure b/ld/configure
index 2b291f0da8..facc386563 100755
index 43c391c2b3..ff9f6b3c02 100755
--- a/ld/configure
+++ b/ld/configure
@@ -826,6 +826,7 @@ with_lib_path
@@ -118,7 +118,7 @@ index 2b291f0da8..facc386563 100755
if test "${enable_gold+set}" = set; then :
enableval=$enable_gold; case "${enableval}" in
diff --git a/ld/configure.ac b/ld/configure.ac
index d10c553650..9f1b57b120 100644
index d335f21091..7f692d9387 100644
--- a/ld/configure.ac
+++ b/ld/configure.ac
@@ -94,6 +94,16 @@ AC_SUBST(use_sysroot)
@@ -139,7 +139,7 @@ index d10c553650..9f1b57b120 100644
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 ba914b921e..9df17dab6c 100644
index b97d977f37..f3bbd2d55d 100644
--- a/ld/ld.h
+++ b/ld/ld.h
@@ -180,6 +180,14 @@ typedef struct
@@ -158,10 +158,10 @@ index ba914b921e..9df17dab6c 100644
enum endian_enum endian;
diff --git a/ld/ld.texi b/ld/ld.texi
index b9fe2324da..43486605e0 100644
index 5179af3e0e..f78bf74682 100644
--- a/ld/ld.texi
+++ b/ld/ld.texi
@@ -2479,6 +2479,18 @@ string identifying the original linked file does not change.
@@ -2524,6 +2524,18 @@ string identifying the original linked file does not change.
Passing @code{none} for @var{style} disables the setting from any
@code{--build-id} options earlier on the command line.
@@ -181,7 +181,7 @@ index b9fe2324da..43486605e0 100644
@c man end
diff --git a/ld/ldfile.c b/ld/ldfile.c
index a72ff13526..dc5148f748 100644
index fcadc08c73..63e295ce8a 100644
--- a/ld/ldfile.c
+++ b/ld/ldfile.c
@@ -116,6 +116,23 @@ ldfile_add_library_path (const char *name, bfd_boolean cmdline)
@@ -209,7 +209,7 @@ index a72ff13526..dc5148f748 100644
/* Try to open a BFD for a lang_input_statement. */
diff --git a/ld/ldlex.h b/ld/ldlex.h
index 04d6fd5f96..d7df005bb2 100644
index 32853debe4..8135361c49 100644
--- a/ld/ldlex.h
+++ b/ld/ldlex.h
@@ -148,6 +148,8 @@ enum option_values
@@ -222,10 +222,10 @@ index 04d6fd5f96..d7df005bb2 100644
/* The initial parser states. */
diff --git a/ld/ldmain.c b/ld/ldmain.c
index f31eeb29c3..25f8497888 100644
index 77cdbd0dd2..725512f126 100644
--- a/ld/ldmain.c
+++ b/ld/ldmain.c
@@ -268,6 +268,8 @@ main (int argc, char **argv)
@@ -269,6 +269,8 @@ main (int argc, char **argv)
command_line.warn_mismatch = TRUE;
command_line.warn_search_mismatch = TRUE;
command_line.check_section_addresses = -1;
@@ -235,7 +235,7 @@ index f31eeb29c3..25f8497888 100644
/* 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 86a033a383..4a40d48020 100644
index 88e85c73f4..eed1b71456 100644
--- a/ld/lexsup.c
+++ b/ld/lexsup.c
@@ -543,6 +543,14 @@ static const struct ld_option ld_options[] =
@@ -269,5 +269,5 @@ index 86a033a383..4a40d48020 100644
}
--
2.18.0
2.20.1

View File

@@ -1,7 +1,7 @@
From 9e1d8f9a657a8bd48048c2ea6407cf60b723bd68 Mon Sep 17 00:00:00 2001
From 2cd5613a86f8772f9d7f188532718363668ed99d 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 10/15] Fix rpath in libtool when sysroot is enabled
Subject: [PATCH 09/15] Fix rpath in libtool when sysroot is enabled
Enabling sysroot support in libtool exposed a bug where the final
library had an RPATH encoded into it which still pointed to the
@@ -48,5 +48,5 @@ index 70e856e065..11ee684ccc 100644
if test -z "$hardcode_libdirs"; then
hardcode_libdirs="$libdir"
--
2.18.0
2.20.1

View File

@@ -1,7 +1,7 @@
From 2d2e2fcdd9646849716ee99d8d3e5d72ae8889bc Mon Sep 17 00:00:00 2001
From d540e95d05cd7c4b8924ac7b257c14ae0105d0ab 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 11/15] Change default emulation for mips64*-*-linux
Subject: [PATCH 10/15] Change default emulation for mips64*-*-linux
we change the default emulations to be N64 instead of N32
@@ -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 6391f35684..8a11c0680a 100644
index 0e1ddb659c..cc65547588 100644
--- a/bfd/config.bfd
+++ b/bfd/config.bfd
@@ -913,12 +913,12 @@ case "${targ}" in
@@ -919,12 +919,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 6391f35684..8a11c0680a 100644
mips*el-*-linux*)
targ_defvec=mips_elf32_trad_le_vec
diff --git a/ld/configure.tgt b/ld/configure.tgt
index fad8b2e5c8..7fb2168503 100644
index beba17ef51..917be6f8eb 100644
--- a/ld/configure.tgt
+++ b/ld/configure.tgt
@@ -464,11 +464,11 @@ mips*el-*-vxworks*) targ_emul=elf32elmipvxworks
@@ -468,11 +468,11 @@ mips*el-*-vxworks*) targ_emul=elf32elmipvxworks
mips*-*-vxworks*) targ_emul=elf32ebmipvxworks
targ_extra_emuls="elf32elmipvxworks" ;;
mips*-*-windiss) targ_emul=elf32mipswindiss ;;
@@ -55,5 +55,5 @@ index fad8b2e5c8..7fb2168503 100644
mips*el-*-linux-*) targ_emul=elf32ltsmip
targ_extra_emuls="elf32btsmip elf32ltsmipn32 elf64ltsmip elf32btsmipn32 elf64btsmip"
--
2.18.0
2.20.1

View File

@@ -1,7 +1,7 @@
From 96ff7570c29f792c466a933529fefda9b8e97994 Mon Sep 17 00:00:00 2001
From e4a0cd30c7e9334ed507c93014a8b2d1315ff937 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 12/15] Add support for Netlogic XLP
Subject: [PATCH 11/15] Add support for Netlogic XLP
Patch From: Nebu Philips <nphilips@netlogicmicro.com>
@@ -34,10 +34,10 @@ Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
14 files changed, 61 insertions(+), 21 deletions(-)
diff --git a/bfd/aoutx.h b/bfd/aoutx.h
index 023843b0be..46246fec2d 100644
index e5d8dcf390..2cc74a2d61 100644
--- a/bfd/aoutx.h
+++ b/bfd/aoutx.h
@@ -798,6 +798,7 @@ NAME (aout, machine_type) (enum bfd_architecture arch,
@@ -799,6 +799,7 @@ NAME (aout, machine_type) (enum bfd_architecture arch,
case bfd_mach_mipsisa64r6:
case bfd_mach_mips_sb1:
case bfd_mach_mips_xlr:
@@ -46,10 +46,10 @@ index 023843b0be..46246fec2d 100644
arch_flags = M_MIPS2;
break;
diff --git a/bfd/archures.c b/bfd/archures.c
index 282e983086..b38b05d132 100644
index 647cf0d8d4..7e1d0c810f 100644
--- a/bfd/archures.c
+++ b/bfd/archures.c
@@ -183,6 +183,7 @@ DESCRIPTION
@@ -185,6 +185,7 @@ DESCRIPTION
.#define bfd_mach_mips_octeon3 6503
.#define bfd_mach_mips_xlr 887682 {* decimal 'XLR'. *}
.#define bfd_mach_mips_interaptiv_mr2 736550 {* decimal 'IA2'. *}
@@ -58,10 +58,10 @@ index 282e983086..b38b05d132 100644
.#define bfd_mach_mipsisa32r2 33
.#define bfd_mach_mipsisa32r3 34
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index 93745bd3fd..326e9e49ed 100644
index e25da50aaf..e251d7e7aa 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -2054,6 +2054,7 @@ enum bfd_architecture
@@ -2084,6 +2084,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'. */
@@ -70,10 +70,10 @@ index 93745bd3fd..326e9e49ed 100644
#define bfd_mach_mipsisa32r2 33
#define bfd_mach_mipsisa32r3 34
diff --git a/bfd/config.bfd b/bfd/config.bfd
index 8a11c0680a..c882421343 100644
index cc65547588..3614ff79d4 100644
--- a/bfd/config.bfd
+++ b/bfd/config.bfd
@@ -896,6 +896,11 @@ case "${targ}" in
@@ -902,6 +902,11 @@ case "${targ}" in
targ_defvec=mips_elf32_le_vec
targ_selvecs="mips_elf32_be_vec mips_elf64_be_vec mips_elf64_le_vec"
;;
@@ -86,10 +86,10 @@ index 8a11c0680a..c882421343 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 cb50c64371..2b9d1d6ecf 100644
index b359491305..61a3e7aaca 100644
--- a/bfd/cpu-mips.c
+++ b/bfd/cpu-mips.c
@@ -105,7 +105,8 @@ enum
@@ -107,7 +107,8 @@ enum
I_mipsocteon3,
I_xlr,
I_interaptiv_mr2,
@@ -99,7 +99,7 @@ index cb50c64371..2b9d1d6ecf 100644
};
#define NN(index) (&arch_info_struct[(index) + 1])
@@ -158,7 +159,8 @@ static const bfd_arch_info_type arch_info_struct[] =
@@ -162,7 +163,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,
NN(I_interaptiv_mr2)),
@@ -110,10 +110,10 @@ index cb50c64371..2b9d1d6ecf 100644
/* 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 d91942301c..5d1bd3f0b1 100644
index 5998bc43a8..0d5795222b 100644
--- a/bfd/elfxx-mips.c
+++ b/bfd/elfxx-mips.c
@@ -6805,6 +6805,9 @@ _bfd_elf_mips_mach (flagword flags)
@@ -6919,6 +6919,9 @@ _bfd_elf_mips_mach (flagword flags)
case E_MIPS_MACH_IAMR2:
return bfd_mach_mips_interaptiv_mr2;
@@ -123,7 +123,7 @@ index d91942301c..5d1bd3f0b1 100644
default:
switch (flags & EF_MIPS_ARCH)
{
@@ -12003,6 +12006,10 @@ mips_set_isa_flags (bfd *abfd)
@@ -12199,6 +12202,10 @@ mips_set_isa_flags (bfd *abfd)
val = E_MIPS_ARCH_64R2 | E_MIPS_MACH_OCTEON2;
break;
@@ -134,19 +134,19 @@ index d91942301c..5d1bd3f0b1 100644
case bfd_mach_mipsisa32:
val = E_MIPS_ARCH_32;
break;
@@ -13992,6 +13999,7 @@ static const struct mips_mach_extension mips_mach_extensions[] =
{ bfd_mach_mips_octeonp, bfd_mach_mips_octeon },
{ bfd_mach_mips_octeon, bfd_mach_mipsisa64r2 },
{ bfd_mach_mips_loongson_3a, bfd_mach_mipsisa64r2 },
@@ -14214,6 +14221,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 },
+ { bfd_mach_mips_xlp, bfd_mach_mipsisa64r2 },
/* MIPS64 extensions. */
{ bfd_mach_mipsisa64r2, bfd_mach_mipsisa64 },
diff --git a/binutils/readelf.c b/binutils/readelf.c
index 2b78db219b..7a7178925f 100644
index b13eb6a43b..9df3742682 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -3403,6 +3403,7 @@ get_machine_flags (Filedata * filedata, unsigned e_flags, unsigned e_machine)
@@ -3412,6 +3412,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;
@@ -155,10 +155,10 @@ index 2b78db219b..7a7178925f 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 59df787155..48537226c0 100644
index ae55904229..d6882712f5 100644
--- a/gas/config/tc-mips.c
+++ b/gas/config/tc-mips.c
@@ -552,6 +552,7 @@ static int mips_32bitmode = 0;
@@ -554,6 +554,7 @@ static int mips_32bitmode = 0;
|| mips_opts.arch == CPU_RM7000 \
|| mips_opts.arch == CPU_VR5500 \
|| mips_opts.micromips \
@@ -166,7 +166,7 @@ index 59df787155..48537226c0 100644
)
/* Whether the processor uses hardware interlocks to protect reads
@@ -581,6 +582,7 @@ static int mips_32bitmode = 0;
@@ -583,6 +584,7 @@ static int mips_32bitmode = 0;
&& mips_opts.isa != ISA_MIPS3) \
|| mips_opts.arch == CPU_R4300 \
|| mips_opts.micromips \
@@ -174,7 +174,7 @@ index 59df787155..48537226c0 100644
)
/* Whether the processor uses hardware interlocks to protect reads
@@ -19778,7 +19780,7 @@ static const struct mips_cpu_info mips_cpu_info_table[] =
@@ -19867,7 +19869,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. */
@@ -184,10 +184,10 @@ index 59df787155..48537226c0 100644
/* MIPS 64 Release 6 */
{ "i6400", 0, ASE_MSA, ISA_MIPS64R6, CPU_MIPS64R6},
diff --git a/gas/configure b/gas/configure
index 134278fa25..2fdca147a1 100755
index a82fde7fa8..afc77c347a 100755
--- a/gas/configure
+++ b/gas/configure
@@ -13336,6 +13336,9 @@ _ACEOF
@@ -13364,6 +13364,9 @@ _ACEOF
mipsisa64r6 | mipsisa64r6el)
mips_cpu=mips64r6
;;
@@ -198,7 +198,7 @@ index 134278fa25..2fdca147a1 100755
mips_cpu=r3900
;;
diff --git a/include/elf/mips.h b/include/elf/mips.h
index 4e2cde3279..c329f38929 100644
index b76d450ae2..7cddb365ad 100644
--- a/include/elf/mips.h
+++ b/include/elf/mips.h
@@ -290,6 +290,7 @@ END_RELOC_NUMBERS (R_MIPS_maxext)
@@ -210,10 +210,10 @@ index 4e2cde3279..c329f38929 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 1ab1780567..74f457b579 100644
index abd52c8980..53b6752a1c 100644
--- a/include/opcode/mips.h
+++ b/include/opcode/mips.h
@@ -1262,6 +1262,8 @@ static const unsigned int mips_isa_table[] = {
@@ -1260,6 +1260,8 @@ static const unsigned int mips_isa_table[] = {
#define INSN_XLR 0x00000020
/* Imagination interAptiv MR2. */
#define INSN_INTERAPTIV_MR2 0x04000000
@@ -222,7 +222,7 @@ index 1ab1780567..74f457b579 100644
/* DSP ASE */
#define ASE_DSP 0x00000001
@@ -1373,6 +1375,7 @@ static const unsigned int mips_isa_table[] = {
@@ -1381,6 +1383,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' */
@@ -230,7 +230,7 @@ index 1ab1780567..74f457b579 100644
/* Return true if the given CPU is included in INSN_* mask MASK. */
@@ -1453,6 +1456,9 @@ cpu_is_member (int cpu, unsigned int mask)
@@ -1458,6 +1461,9 @@ cpu_is_member (int cpu, unsigned int mask)
return ((mask & INSN_ISA_MASK) == INSN_ISA32R6)
|| ((mask & INSN_ISA_MASK) == INSN_ISA64R6);
@@ -241,10 +241,10 @@ index 1ab1780567..74f457b579 100644
return FALSE;
}
diff --git a/ld/configure.tgt b/ld/configure.tgt
index 7fb2168503..a1db7adfe2 100644
index 917be6f8eb..347df6c3f6 100644
--- a/ld/configure.tgt
+++ b/ld/configure.tgt
@@ -450,6 +450,8 @@ mips*el-sde-elf* | mips*el-mti-elf* | mips*el-img-elf*)
@@ -454,6 +454,8 @@ mips*el-sde-elf* | mips*el-mti-elf* | mips*el-img-elf*)
mips*-sde-elf* | mips*-mti-elf* | mips*-img-elf*)
targ_emul=elf32btsmip
targ_extra_emuls="elf32ltsmip elf32btsmipn32 elf64btsmip elf32ltsmipn32 elf64ltsmip" ;;
@@ -254,10 +254,10 @@ index 7fb2168503..a1db7adfe2 100644
targ_extra_emuls="elf32lr5900"
targ_extra_libpath=$targ_extra_emuls ;;
diff --git a/opcodes/mips-dis.c b/opcodes/mips-dis.c
index bbf21328e8..38e487c16f 100644
index 0dd85e3779..1ea708dde7 100644
--- a/opcodes/mips-dis.c
+++ b/opcodes/mips-dis.c
@@ -656,13 +656,11 @@ const struct mips_arch_choice mips_arch_choices[] =
@@ -673,13 +673,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 },
@@ -277,10 +277,10 @@ index bbf21328e8..38e487c16f 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 1cbcbc6abc..e1fbdc89de 100644
index 837da6bd99..d3ea5b8877 100644
--- a/opcodes/mips-opc.c
+++ b/opcodes/mips-opc.c
@@ -329,6 +329,7 @@ decode_mips_operand (const char *p)
@@ -328,6 +328,7 @@ decode_mips_operand (const char *p)
#define IOCT3 INSN_OCTEON3
#define XLR INSN_XLR
#define IAMR2 INSN_INTERAPTIV_MR2
@@ -288,7 +288,7 @@ index 1cbcbc6abc..e1fbdc89de 100644
#define IVIRT ASE_VIRT
#define IVIRT64 ASE_VIRT64
@@ -974,6 +975,7 @@ const struct mips_opcode mips_builtin_opcodes[] =
@@ -989,6 +990,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 },
@@ -296,7 +296,7 @@ index 1cbcbc6abc..e1fbdc89de 100644
/* ctc0 is at the bottom of the table. */
{"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 },
@@ -1006,12 +1008,13 @@ const struct mips_opcode mips_builtin_opcodes[] =
@@ -1021,12 +1023,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 },
@@ -311,7 +311,7 @@ index 1cbcbc6abc..e1fbdc89de 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 },
@@ -1083,6 +1086,7 @@ const struct mips_opcode mips_builtin_opcodes[] =
@@ -1098,6 +1101,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 },
@@ -319,7 +319,7 @@ index 1cbcbc6abc..e1fbdc89de 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 },
@@ -1098,6 +1102,8 @@ const struct mips_opcode mips_builtin_opcodes[] =
@@ -1113,6 +1117,8 @@ const struct mips_opcode mips_builtin_opcodes[] =
/* dmfc3 is at the bottom of the table. */
/* dmtc3 is at the bottom of the table. */
{"dmuh", "d,s,t", 0x000000dc, 0xfc0007ff, WR_1|RD_2|RD_3, 0, I69, 0, 0 },
@@ -328,7 +328,7 @@ index 1cbcbc6abc..e1fbdc89de 100644
{"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 },
@@ -1251,9 +1257,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 },
@@ -341,7 +341,7 @@ index 1cbcbc6abc..e1fbdc89de 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 },
@@ -1418,7 +1424,7 @@ const struct mips_opcode mips_builtin_opcodes[] =
@@ -1433,7 +1439,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 },
@@ -350,7 +350,7 @@ index 1cbcbc6abc..e1fbdc89de 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 },
@@ -1463,10 +1469,13 @@ const struct mips_opcode mips_builtin_opcodes[] =
@@ -1478,10 +1484,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 },
@@ -366,7 +366,7 @@ index 1cbcbc6abc..e1fbdc89de 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 },
@@ -1516,7 +1525,7 @@ const struct mips_opcode mips_builtin_opcodes[] =
@@ -1531,7 +1540,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 },
@@ -375,7 +375,7 @@ index 1cbcbc6abc..e1fbdc89de 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 },
@@ -1953,9 +1962,9 @@ const struct mips_opcode mips_builtin_opcodes[] =
@@ -1968,9 +1977,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 },
@@ -389,5 +389,5 @@ index 1cbcbc6abc..e1fbdc89de 100644
{"swc0", "E,A(b)", 0, (int) M_SWC0_AB, INSN_MACRO, 0, I1, 0, IOCT|IOCTP|IOCT2|I37 },
{"swc1", "T,o(b)", 0xe4000000, 0xfc000000, RD_1|RD_3|SM|FP_S, 0, I1, 0, 0 },
--
2.18.0
2.20.1

View File

@@ -1,7 +1,7 @@
From d45455db35db5693c5efe0e1b384295e4c0db998 Mon Sep 17 00:00:00 2001
From e48767a0298e6ccf53d83fecc93bb6d26b595897 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 13/15] fix the incorrect assembling for ppc wait mnemonic
Subject: [PATCH 12/15] fix the incorrect assembling for ppc wait mnemonic
Signed-off-by: Zhenhua Luo <zhenhua.luo@nxp.com>
@@ -11,10 +11,10 @@ Upstream-Status: Pending
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/opcodes/ppc-opc.c b/opcodes/ppc-opc.c
index 4a0fca5f0a..49f72fc35c 100644
index 3032631d4e..142f096ef4 100644
--- a/opcodes/ppc-opc.c
+++ b/opcodes/ppc-opc.c
@@ -5351,7 +5351,6 @@ const struct powerpc_opcode powerpc_opcodes[] = {
@@ -5325,7 +5325,6 @@ const struct powerpc_opcode powerpc_opcodes[] = {
{"ldepx", X(31,29), X_MASK, E500MC|PPCA2, 0, {RT, RA0, RB}},
{"waitasec", X(31,30), XRTRARB_MASK, POWER8, POWER9, {0}},
@@ -22,7 +22,7 @@ index 4a0fca5f0a..49f72fc35c 100644
{"lwepx", X(31,31), X_MASK, E500MC|PPCA2, 0, {RT, RA0, RB}},
@@ -5405,7 +5404,7 @@ const struct powerpc_opcode powerpc_opcodes[] = {
@@ -5379,7 +5378,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}},
@@ -32,5 +32,5 @@ index 4a0fca5f0a..49f72fc35c 100644
{"dcbstep", XRT(31,63,0), XRT_MASK, E500MC|PPCA2, 0, {RA0, RB}},
--
2.18.0
2.20.1

View File

@@ -1,7 +1,7 @@
From 9af90cfc35ff1fe78755578861473039836c467a Mon Sep 17 00:00:00 2001
From 6587e7b8e7730dda20d8c47cabe9f7f8397efa3c 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 14/15] Detect 64-bit MIPS targets
Subject: [PATCH 13/15] Detect 64-bit MIPS targets
Add mips64 target triplets and default to N64
@@ -14,7 +14,7 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
1 file changed, 14 insertions(+)
diff --git a/gold/configure.tgt b/gold/configure.tgt
index 8aef22a318..7030026ffa 100644
index 3e066edaa8..caf130ceda 100644
--- a/gold/configure.tgt
+++ b/gold/configure.tgt
@@ -153,6 +153,13 @@ aarch64*-*)
@@ -46,5 +46,5 @@ index 8aef22a318..7030026ffa 100644
targ_obj=mips
targ_machine=EM_MIPS
--
2.18.0
2.20.1

View File

@@ -1,7 +1,7 @@
From f9e26bd29b5f017ea1307b51b5036063bff78600 Mon Sep 17 00:00:00 2001
From b7729343206fa196b9a11747a92b3cf563277056 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 15/15] sync with OE libtool changes
Subject: [PATCH 14/15] sync with OE libtool changes
Apply these patches from our libtool patches as not only are redundant RPATHs a
waste of space but they can cause incorrect linking when native packages are
@@ -85,5 +85,5 @@ index 11ee684ccc..3b19ac1532 100644
elif test -n "$runpath_var"; then
case "$finalize_perm_rpath " in
--
2.18.0
2.20.1

View File

@@ -1,4 +1,8 @@
binutils : enable x86_64-pep for producing EFI binaries on x86-64
From d5d783903e335302e562bac8da1a083338d75b25 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Thu, 29 Nov 2018 17:46:40 -0800
Subject: [PATCH 15/15] binutils : enable x86_64-pep for producing EFI binaries
on x86-64
Add x86_64-pep emulation support to the set enabled for x86_64 targets
to enable the linker to produce Portable Executables for EFI binaries.
@@ -6,15 +10,20 @@ to enable the linker to produce Portable Executables for EFI binaries.
Enables building the x86-64 EFI variant of the Xen hypervisor for
the OpenXT Project.
Signed-off-by: Christopher Clark <christopher.clark6@baesystems.com>
Upstream-Status: Inappropriate [OE configuration specific]
Signed-off-by: Christopher Clark <christopher.clark6@baesystems.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
bfd/config.bfd | 2 +-
ld/configure.tgt | 5 +++--
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/bfd/config.bfd b/bfd/config.bfd
index c882421..dc705b6 100644
index 3614ff79d4..aef144803a 100644
--- a/bfd/config.bfd
+++ b/bfd/config.bfd
@@ -688,7 +688,7 @@ case "${targ}" in
@@ -694,7 +694,7 @@ case "${targ}" in
;;
x86_64-*-linux-*)
targ_defvec=x86_64_elf64_vec
@@ -24,10 +33,10 @@ index c882421..dc705b6 100644
;;
x86_64-*-nacl*)
diff --git a/ld/configure.tgt b/ld/configure.tgt
index a1db7ad..65a984a 100644
index 347df6c3f6..1e37d747a9 100644
--- a/ld/configure.tgt
+++ b/ld/configure.tgt
@@ -253,8 +253,9 @@ x86_64-*-linux-gnux32) targ_emul=elf32_x86_64
@@ -257,8 +257,9 @@ x86_64-*-linux-gnux32) targ_emul=elf32_x86_64
tdir_elf_iamcu=`echo ${targ_alias} | sed -e 's/x86_64/i386/' -e 's/-linux-gnux32/-linux-gnu/'`
tdir_elf_i386=`echo ${targ_alias} | sed -e 's/x86_64/i386/' -e 's/-linux-gnux32/-linux-gnu/'` ;;
x86_64-*-linux-*) targ_emul=elf_x86_64
@@ -39,3 +48,6 @@ index a1db7ad..65a984a 100644
tdir_elf_i386=`echo ${targ_alias} | sed -e 's/x86_64/i386/'` ;;
i[3-7]86-*-redox*) targ_emul=elf_i386
targ_extra_emuls=elf_x86_64 ;;
--
2.20.1

View File

@@ -1,332 +0,0 @@
From bb9c8cc3c5f4ffd6019a8c53adead429954162e1 Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Tue, 27 Nov 2018 11:59:10 +0000
Subject: [PATCH 1/2] Handle ELF compressed header alignment correctly by
setting up the section alignment correctly for the Elf32_Chdr or Elf64_Chdr
type and respect the ch_addralign field when decompressing the section data.
PR binutils/23919
binutils* readelf.c (dump_sections_as_strings): Remove bogus addralign check.
(dump_sections_as_bytes): Likewise.
(load_specific_debug_sections): Likewise.
* testsuite/binutils-all/dw2-3.rS: Adjust alignment.
* testsuite/binutils-all/dw2-3.rt: Likewise.
bfd * bfd.c (bfd_update_compression_header): Explicitly set alignment.
(bfd_check_compression_header): Add uncompressed_alignment_power
argument. Check ch_addralign is a power of 2.
* bfd-in2.h: Regenerated.
* compress.c (bfd_compress_section_contents): Get and set
orig_uncompressed_alignment_pow if section is decompressed.
(bfd_is_section_compressed_with_header): Add and get
uncompressed_align_pow_p argument.
(bfd_is_section_compressed): Add uncompressed_align_power argument
to bfd_is_section_compressed_with_header call.
(bfd_init_section_decompress_status): Get and set
uncompressed_alignment_power.
* elf.c (_bfd_elf_make_section_from_shdr): Add
uncompressed_align_power argument to
bfd_is_section_compressed_with_header call.
---
bfd/bfd-in2.h | 6 ++--
bfd/bfd.c | 20 ++++++++++----
bfd/compress.c | 35 +++++++++++++++++-------
bfd/elf.c | 5 ++--
binutils/readelf.c | 18 ------------
binutils/testsuite/binutils-all/dw2-3.rS | 2 +-
binutils/testsuite/binutils-all/dw2-3.rt | 2 +-
7 files changed, 49 insertions(+), 39 deletions(-)
Upstream-Status: Backport [https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=4207142d6a5d2359170c5f9a140fc1a2351fbda9]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index f53dbb5e8c..d0c2190d0b 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -7279,7 +7279,8 @@ void bfd_update_compression_header
bfd_boolean bfd_check_compression_header
(bfd *abfd, bfd_byte *contents, asection *sec,
- bfd_size_type *uncompressed_size);
+ bfd_size_type *uncompressed_size,
+ unsigned int *uncompressed_alignment_power);
int bfd_get_compression_header_size (bfd *abfd, asection *sec);
@@ -7855,7 +7856,8 @@ void bfd_cache_section_contents
bfd_boolean bfd_is_section_compressed_with_header
(bfd *abfd, asection *section,
int *compression_header_size_p,
- bfd_size_type *uncompressed_size_p);
+ bfd_size_type *uncompressed_size_p,
+ unsigned int *uncompressed_alignment_power_p);
bfd_boolean bfd_is_section_compressed
(bfd *abfd, asection *section);
diff --git a/bfd/bfd.c b/bfd/bfd.c
index 851710401e..ea10d7b185 100644
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -2332,6 +2332,8 @@ bfd_update_compression_header (bfd *abfd, bfd_byte *contents,
bfd_put_32 (abfd, sec->size, &echdr->ch_size);
bfd_put_32 (abfd, 1 << sec->alignment_power,
&echdr->ch_addralign);
+ /* bfd_log2 (alignof (Elf32_Chdr)) */
+ bfd_set_section_alignment (abfd, sec, 2);
}
else
{
@@ -2342,6 +2344,8 @@ bfd_update_compression_header (bfd *abfd, bfd_byte *contents,
bfd_put_64 (abfd, sec->size, &echdr->ch_size);
bfd_put_64 (abfd, 1 << sec->alignment_power,
&echdr->ch_addralign);
+ /* bfd_log2 (alignof (Elf64_Chdr)) */
+ bfd_set_section_alignment (abfd, sec, 3);
}
}
else
@@ -2354,6 +2358,8 @@ bfd_update_compression_header (bfd *abfd, bfd_byte *contents,
order. */
memcpy (contents, "ZLIB", 4);
bfd_putb64 (sec->size, contents + 4);
+ /* No way to keep the original alignment, just use 1 always. */
+ bfd_set_section_alignment (abfd, sec, 0);
}
}
}
@@ -2368,12 +2374,14 @@ bfd_update_compression_header (bfd *abfd, bfd_byte *contents,
SYNOPSIS
bfd_boolean bfd_check_compression_header
(bfd *abfd, bfd_byte *contents, asection *sec,
- bfd_size_type *uncompressed_size);
+ bfd_size_type *uncompressed_size,
+ unsigned int *uncompressed_alignment_power);
DESCRIPTION
Check the compression header at CONTENTS of SEC in ABFD and
- store the uncompressed size in UNCOMPRESSED_SIZE if the
- compression header is valid.
+ store the uncompressed size in UNCOMPRESSED_SIZE and the
+ uncompressed data alignment in UNCOMPRESSED_ALIGNMENT_POWER
+ if the compression header is valid.
RETURNS
Return TRUE if the compression header is valid.
@@ -2382,7 +2390,8 @@ RETURNS
bfd_boolean
bfd_check_compression_header (bfd *abfd, bfd_byte *contents,
asection *sec,
- bfd_size_type *uncompressed_size)
+ bfd_size_type *uncompressed_size,
+ unsigned int *uncompressed_alignment_power)
{
if (bfd_get_flavour (abfd) == bfd_target_elf_flavour
&& (elf_section_flags (sec) & SHF_COMPRESSED) != 0)
@@ -2404,9 +2413,10 @@ bfd_check_compression_header (bfd *abfd, bfd_byte *contents,
chdr.ch_addralign = bfd_get_64 (abfd, &echdr->ch_addralign);
}
if (chdr.ch_type == ELFCOMPRESS_ZLIB
- && chdr.ch_addralign == 1U << sec->alignment_power)
+ && chdr.ch_addralign == (1U << bfd_log2 (chdr.ch_addralign)))
{
*uncompressed_size = chdr.ch_size;
+ *uncompressed_alignment_power = bfd_log2 (chdr.ch_addralign);
return TRUE;
}
}
diff --git a/bfd/compress.c b/bfd/compress.c
index 53e566e498..97ea624eb8 100644
--- a/bfd/compress.c
+++ b/bfd/compress.c
@@ -84,11 +84,13 @@ bfd_compress_section_contents (bfd *abfd, sec_ptr sec,
int zlib_size = 0;
int orig_compression_header_size;
bfd_size_type orig_uncompressed_size;
+ unsigned int orig_uncompressed_alignment_pow;
int header_size = bfd_get_compression_header_size (abfd, NULL);
bfd_boolean compressed
= bfd_is_section_compressed_with_header (abfd, sec,
&orig_compression_header_size,
- &orig_uncompressed_size);
+ &orig_uncompressed_size,
+ &orig_uncompressed_alignment_pow);
/* Either ELF compression header or the 12-byte, "ZLIB" + 8-byte size,
overhead in .zdebug* section. */
@@ -153,6 +155,9 @@ bfd_compress_section_contents (bfd *abfd, sec_ptr sec,
return 0;
}
free (uncompressed_buffer);
+ bfd_set_section_alignment (abfd, sec,
+ orig_uncompressed_alignment_pow);
+
sec->contents = buffer;
sec->compress_status = COMPRESS_SECTION_DONE;
return orig_uncompressed_size;
@@ -364,20 +369,24 @@ SYNOPSIS
bfd_boolean bfd_is_section_compressed_with_header
(bfd *abfd, asection *section,
int *compression_header_size_p,
- bfd_size_type *uncompressed_size_p);
+ bfd_size_type *uncompressed_size_p,
+ unsigned int *uncompressed_alignment_power_p);
DESCRIPTION
Return @code{TRUE} if @var{section} is compressed. Compression
- header size is returned in @var{compression_header_size_p} and
- uncompressed size is returned in @var{uncompressed_size_p}. If
- compression is unsupported, compression header size is returned
- with -1 and uncompressed size is returned with 0.
+ header size is returned in @var{compression_header_size_p},
+ uncompressed size is returned in @var{uncompressed_size_p}
+ and the uncompressed data alignement power is returned in
+ @var{uncompressed_align_pow_p}. If compression is
+ unsupported, compression header size is returned with -1
+ and uncompressed size is returned with 0.
*/
bfd_boolean
bfd_is_section_compressed_with_header (bfd *abfd, sec_ptr sec,
int *compression_header_size_p,
- bfd_size_type *uncompressed_size_p)
+ bfd_size_type *uncompressed_size_p,
+ unsigned int *uncompressed_align_pow_p)
{
bfd_byte header[MAX_COMPRESSION_HEADER_SIZE];
int compression_header_size;
@@ -412,7 +421,8 @@ bfd_is_section_compressed_with_header (bfd *abfd, sec_ptr sec,
if (compression_header_size != 0)
{
if (!bfd_check_compression_header (abfd, header, sec,
- uncompressed_size_p))
+ uncompressed_size_p,
+ uncompressed_align_pow_p))
compression_header_size = -1;
}
/* Check for the pathalogical case of a debug string section that
@@ -449,9 +459,11 @@ bfd_is_section_compressed (bfd *abfd, sec_ptr sec)
{
int compression_header_size;
bfd_size_type uncompressed_size;
+ unsigned int uncompressed_align_power;
return (bfd_is_section_compressed_with_header (abfd, sec,
&compression_header_size,
- &uncompressed_size)
+ &uncompressed_size,
+ &uncompressed_align_power)
&& compression_header_size >= 0
&& uncompressed_size > 0);
}
@@ -480,6 +492,7 @@ bfd_init_section_decompress_status (bfd *abfd, sec_ptr sec)
int compression_header_size;
int header_size;
bfd_size_type uncompressed_size;
+ unsigned int uncompressed_alignment_power = 0;
compression_header_size = bfd_get_compression_header_size (abfd, sec);
if (compression_header_size > MAX_COMPRESSION_HEADER_SIZE)
@@ -508,7 +521,8 @@ bfd_init_section_decompress_status (bfd *abfd, sec_ptr sec)
uncompressed_size = bfd_getb64 (header + 4);
}
else if (!bfd_check_compression_header (abfd, header, sec,
- &uncompressed_size))
+ &uncompressed_size,
+ &uncompressed_alignment_power))
{
bfd_set_error (bfd_error_wrong_format);
return FALSE;
@@ -516,6 +530,7 @@ bfd_init_section_decompress_status (bfd *abfd, sec_ptr sec)
sec->compressed_size = sec->size;
sec->size = uncompressed_size;
+ bfd_set_section_alignment (abfd, sec, uncompressed_alignment_power);
sec->compress_status = DECOMPRESS_SECTION_SIZED;
return TRUE;
diff --git a/bfd/elf.c b/bfd/elf.c
index 828241d48a..c4f131ddcf 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -1177,11 +1177,12 @@ _bfd_elf_make_section_from_shdr (bfd *abfd,
enum { nothing, compress, decompress } action = nothing;
int compression_header_size;
bfd_size_type uncompressed_size;
+ unsigned int uncompressed_align_power;
bfd_boolean compressed
= bfd_is_section_compressed_with_header (abfd, newsect,
&compression_header_size,
- &uncompressed_size);
-
+ &uncompressed_size,
+ &uncompressed_align_power);
if (compressed)
{
/* Compressed section. Check if we should decompress. */
diff --git a/binutils/readelf.c b/binutils/readelf.c
index f4df697a7d..4b0efa884f 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -13345,12 +13345,6 @@ dump_section_as_strings (Elf_Internal_Shdr * section, Filedata * filedata)
printable_section_name (filedata, section), chdr.ch_type);
return FALSE;
}
- else if (chdr.ch_addralign != section->sh_addralign)
- {
- warn (_("compressed section '%s' is corrupted\n"),
- printable_section_name (filedata, section));
- return FALSE;
- }
uncompressed_size = chdr.ch_size;
start += compression_header_size;
new_size -= compression_header_size;
@@ -13492,12 +13486,6 @@ dump_section_as_bytes (Elf_Internal_Shdr * section,
printable_section_name (filedata, section), chdr.ch_type);
return FALSE;
}
- else if (chdr.ch_addralign != section->sh_addralign)
- {
- warn (_("compressed section '%s' is corrupted\n"),
- printable_section_name (filedata, section));
- return FALSE;
- }
uncompressed_size = chdr.ch_size;
start += compression_header_size;
new_size -= compression_header_size;
@@ -13667,12 +13655,6 @@ load_specific_debug_section (enum dwarf_section_display_enum debug,
section->name, chdr.ch_type);
return FALSE;
}
- else if (chdr.ch_addralign != sec->sh_addralign)
- {
- warn (_("compressed section '%s' is corrupted\n"),
- section->name);
- return FALSE;
- }
uncompressed_size = chdr.ch_size;
start += compression_header_size;
size -= compression_header_size;
diff --git a/binutils/testsuite/binutils-all/dw2-3.rS b/binutils/testsuite/binutils-all/dw2-3.rS
index f1637e9149..86bc73d9a2 100644
--- a/binutils/testsuite/binutils-all/dw2-3.rS
+++ b/binutils/testsuite/binutils-all/dw2-3.rS
@@ -1,3 +1,3 @@
#...
- +\[[ 0-9]+\] .debug_info +(PROGBITS|MIPS_DWARF) +0+ +[0-9a-f]+ +[0-9a-f]+ [0-9a-f]+ +C +0 +0 +1
+ +\[[ 0-9]+\] .debug_info +(PROGBITS|MIPS_DWARF) +0+ +[0-9a-f]+ +[0-9a-f]+ [0-9a-f]+ +C +0 +0 +(4|8)
#pass
diff --git a/binutils/testsuite/binutils-all/dw2-3.rt b/binutils/testsuite/binutils-all/dw2-3.rt
index f59cbaa22b..74e7f8deca 100644
--- a/binutils/testsuite/binutils-all/dw2-3.rt
+++ b/binutils/testsuite/binutils-all/dw2-3.rt
@@ -1,6 +1,6 @@
#...
+\[[ 0-9]+\] .debug_info
- +(PROGBITS|MIPS_DWARF) +0+ +[0-9a-f]+ +[0-9a-f]+ +[0-9a-f]+ +0 +0 +1
+ +(PROGBITS|MIPS_DWARF) +0+ +[0-9a-f]+ +[0-9a-f]+ +[0-9a-f]+ +0 +0 +(4|8)
+\[0+800\]: COMPRESSED
+ZLIB, 0+9d, 1
#pass
--
2.20.1

View File

@@ -1,200 +0,0 @@
From 0261ec511ac07177fa488133e0bb3c03860977b3 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Sun, 2 Dec 2018 05:42:36 -0800
Subject: [PATCH 2/2] gold: Get alignment of uncompressed section from
ch_addralign
The ELF compression header has a field (ch_addralign) that is set to
the alignment of the uncompressed section. This way the section itself
can have a different alignment than the decompressed section. Update
decompress_input_section to get alignment of the decompressed section
and use it when merging decompressed strings.
PR binutils/23919
* merge.cc (Output_merge_string<Char_type>::do_add_input_section):
Get addralign from decompressed_section_contents.
* object.cc (build_compressed_section_map): Set info.addralign.
(Object::decompressed_section_contents): Add a palign
argument and store p->second.addralign in *palign if it isn't
NULL.
* object.h (Compressed_section_info): Add addralign.
(section_is_compressed): Add a palign argument, default it
to NULL, store p->second.addralign in *palign if it isn't NULL.
(Object::decompressed_section_contents): Likewise.
* output.cc (Output_section::add_input_section): Get addralign
from section_is_compressed.
---
gold/merge.cc | 8 +++++---
gold/object.cc | 11 +++++++++--
gold/object.h | 8 ++++++--
gold/output.cc | 11 ++++++-----
4 files changed, 26 insertions(+), 12 deletions(-)
Upstream-Status: Backport [https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=5f6c22aee74f17393b82934a5682d985672e011a]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
diff --git a/gold/merge.cc b/gold/merge.cc
index de00ee9ae9..d7de11789f 100644
--- a/gold/merge.cc
+++ b/gold/merge.cc
@@ -440,9 +440,11 @@ Output_merge_string<Char_type>::do_add_input_section(Relobj* object,
{
section_size_type sec_len;
bool is_new;
+ uint64_t addralign = this->addralign();
const unsigned char* pdata = object->decompressed_section_contents(shndx,
&sec_len,
- &is_new);
+ &is_new,
+ &addralign);
const Char_type* p = reinterpret_cast<const Char_type*>(pdata);
const Char_type* pend = p + sec_len / sizeof(Char_type);
@@ -494,7 +496,7 @@ Output_merge_string<Char_type>::do_add_input_section(Relobj* object,
// aligned, so each string within the section must retain the same
// modulo.
uintptr_t init_align_modulo = (reinterpret_cast<uintptr_t>(pdata)
- & (this->addralign() - 1));
+ & (addralign - 1));
bool has_misaligned_strings = false;
while (p < pend)
@@ -503,7 +505,7 @@ Output_merge_string<Char_type>::do_add_input_section(Relobj* object,
// Within merge input section each string must be aligned.
if (len != 0
- && ((reinterpret_cast<uintptr_t>(p) & (this->addralign() - 1))
+ && ((reinterpret_cast<uintptr_t>(p) & (addralign - 1))
!= init_align_modulo))
has_misaligned_strings = true;
diff --git a/gold/object.cc b/gold/object.cc
index 374340fa16..711793e5e4 100644
--- a/gold/object.cc
+++ b/gold/object.cc
@@ -751,11 +751,13 @@ build_compressed_section_map(
const unsigned char* contents =
obj->section_contents(i, &len, false);
uint64_t uncompressed_size;
+ Compressed_section_info info;
if (is_zcompressed)
{
// Skip over the ".zdebug" prefix.
name += 7;
uncompressed_size = get_uncompressed_size(contents, len);
+ info.addralign = shdr.get_sh_addralign();
}
else
{
@@ -763,8 +765,8 @@ build_compressed_section_map(
name += 6;
elfcpp::Chdr<size, big_endian> chdr(contents);
uncompressed_size = chdr.get_ch_size();
+ info.addralign = chdr.get_ch_addralign();
}
- Compressed_section_info info;
info.size = convert_to_section_size_type(uncompressed_size);
info.flag = shdr.get_sh_flags();
info.contents = NULL;
@@ -3060,7 +3062,8 @@ const unsigned char*
Object::decompressed_section_contents(
unsigned int shndx,
section_size_type* plen,
- bool* is_new)
+ bool* is_new,
+ uint64_t* palign)
{
section_size_type buffer_size;
const unsigned char* buffer = this->do_section_contents(shndx, &buffer_size,
@@ -3087,6 +3090,8 @@ Object::decompressed_section_contents(
{
*plen = uncompressed_size;
*is_new = false;
+ if (palign != NULL)
+ *palign = p->second.addralign;
return p->second.contents;
}
@@ -3108,6 +3113,8 @@ Object::decompressed_section_contents(
// once in this pass.
*plen = uncompressed_size;
*is_new = true;
+ if (palign != NULL)
+ *palign = p->second.addralign;
return uncompressed_data;
}
diff --git a/gold/object.h b/gold/object.h
index 0b786a5471..b99548463d 100644
--- a/gold/object.h
+++ b/gold/object.h
@@ -373,6 +373,7 @@ struct Compressed_section_info
{
section_size_type size;
elfcpp::Elf_Xword flag;
+ uint64_t addralign;
const unsigned char* contents;
};
typedef std::map<unsigned int, Compressed_section_info> Compressed_section_map;
@@ -808,7 +809,8 @@ class Object
bool
section_is_compressed(unsigned int shndx,
- section_size_type* uncompressed_size) const
+ section_size_type* uncompressed_size,
+ elfcpp::Elf_Xword* palign = NULL) const
{
if (this->compressed_sections_ == NULL)
return false;
@@ -818,6 +820,8 @@ class Object
{
if (uncompressed_size != NULL)
*uncompressed_size = p->second.size;
+ if (palign != NULL)
+ *palign = p->second.addralign;
return true;
}
return false;
@@ -828,7 +832,7 @@ class Object
// by the caller.
const unsigned char*
decompressed_section_contents(unsigned int shndx, section_size_type* plen,
- bool* is_cached);
+ bool* is_cached, uint64_t* palign = NULL);
// Discard any buffers of decompressed sections. This is done
// at the end of the Add_symbols task.
diff --git a/gold/output.cc b/gold/output.cc
index 1701db1c99..75ac3bcf97 100644
--- a/gold/output.cc
+++ b/gold/output.cc
@@ -2448,7 +2448,13 @@ Output_section::add_input_section(Layout* layout,
unsigned int reloc_shndx,
bool have_sections_script)
{
+ section_size_type input_section_size = shdr.get_sh_size();
+ section_size_type uncompressed_size;
elfcpp::Elf_Xword addralign = shdr.get_sh_addralign();
+ if (object->section_is_compressed(shndx, &uncompressed_size,
+ &addralign))
+ input_section_size = uncompressed_size;
+
if ((addralign & (addralign - 1)) != 0)
{
object->error(_("invalid alignment %lu for section \"%s\""),
@@ -2498,11 +2504,6 @@ Output_section::add_input_section(Layout* layout,
}
}
- section_size_type input_section_size = shdr.get_sh_size();
- section_size_type uncompressed_size;
- if (object->section_is_compressed(shndx, &uncompressed_size))
- input_section_size = uncompressed_size;
-
off_t offset_in_section;
if (this->has_fixed_layout())
--
2.20.1

View File

@@ -1,121 +0,0 @@
From 30838132997e6a3cfe3ec11c58b32b22f6f6b102 Mon Sep 17 00:00:00 2001
From: Alan Modra <amodra@gmail.com>
Date: Thu, 20 Sep 2018 15:29:17 +0930
Subject: [PATCH] Bug 23686, two segment faults in nm
Fixes the bugs exposed by the testcases in the PR, plus two more bugs
I noticed when looking at _bfd_stab_section_find_nearest_line.
PR 23686
* dwarf2.c (read_section): Error when attempting to malloc
"(bfd_size_type) -1".
* syms.c (_bfd_stab_section_find_nearest_line): Bounds check
function_name. Bounds check reloc address. Formatting. Ensure
.stabstr zero terminated.
CVE: CVE-2018-17358 and CVE-2018-17359
Upstream-Status: Backport
Signed-off-by: Zhixiong Chi <zhixiong.chi@windriver.com>
---
bfd/ChangeLog | 9 +++++++++
bfd/dwarf2.c | 9 ++++++++-
bfd/syms.c | 22 ++++++++++++++++------
3 files changed, 33 insertions(+), 7 deletions(-)
--- a/bfd/dwarf2.c
+++ b/bfd/dwarf2.c
@@ -527,6 +527,7 @@ read_section (bfd * abfd,
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)
@@ -549,7 +550,13 @@ read_section (bfd * abfd,
*section_size = msec->rawsize ? msec->rawsize : msec->size;
/* Paranoia - alloc one extra so that we can make sure a string
section is NUL terminated. */
- contents = (bfd_byte *) bfd_malloc (*section_size + 1);
+ amt = *section_size + 1;
+ if (amt == 0)
+ {
+ bfd_set_error (bfd_error_no_memory);
+ return FALSE;
+ }
+ contents = (bfd_byte *) bfd_malloc (amt);
if (contents == NULL)
return FALSE;
if (syms
--- a/bfd/syms.c
+++ b/bfd/syms.c
@@ -1035,6 +1035,10 @@ _bfd_stab_section_find_nearest_line (bfd
0, strsize))
return FALSE;
+ /* Stab strings ought to be nul terminated. Ensure the last one
+ is, to prevent running off the end of the buffer. */
+ info->strs[strsize - 1] = 0;
+
/* If this is a relocatable object file, we have to relocate
the entries in .stab. This should always be simple 32 bit
relocations against symbols defined in this object file, so
@@ -1073,7 +1077,8 @@ _bfd_stab_section_find_nearest_line (bfd
|| r->howto->bitsize != 32
|| r->howto->pc_relative
|| r->howto->bitpos != 0
- || r->howto->dst_mask != 0xffffffff)
+ || r->howto->dst_mask != 0xffffffff
+ || r->address * bfd_octets_per_byte (abfd) + 4 > stabsize)
{
_bfd_error_handler
(_("unsupported .stab relocation"));
@@ -1195,7 +1200,8 @@ _bfd_stab_section_find_nearest_line (bfd
{
nul_fun = stab;
nul_str = str;
- if (file_name >= (char *) info->strs + strsize || file_name < (char *) str)
+ if (file_name >= (char *) info->strs + strsize
+ || file_name < (char *) str)
file_name = NULL;
if (stab + STABSIZE + TYPEOFF < info->stabs + stabsize
&& *(stab + STABSIZE + TYPEOFF) == (bfd_byte) N_SO)
@@ -1206,7 +1212,8 @@ _bfd_stab_section_find_nearest_line (bfd
directory_name = file_name;
file_name = ((char *) str
+ bfd_get_32 (abfd, stab + STRDXOFF));
- if (file_name >= (char *) info->strs + strsize || file_name < (char *) str)
+ if (file_name >= (char *) info->strs + strsize
+ || file_name < (char *) str)
file_name = NULL;
}
}
@@ -1217,7 +1224,8 @@ _bfd_stab_section_find_nearest_line (bfd
file_name = (char *) str + bfd_get_32 (abfd, stab + STRDXOFF);
/* PR 17512: file: 0c680a1f. */
/* PR 17512: file: 5da8aec4. */
- if (file_name >= (char *) info->strs + strsize || file_name < (char *) str)
+ if (file_name >= (char *) info->strs + strsize
+ || file_name < (char *) str)
file_name = NULL;
break;
@@ -1226,7 +1234,8 @@ _bfd_stab_section_find_nearest_line (bfd
function_name = (char *) str + bfd_get_32 (abfd, stab + STRDXOFF);
if (function_name == (char *) str)
continue;
- if (function_name >= (char *) info->strs + strsize)
+ if (function_name >= (char *) info->strs + strsize
+ || function_name < (char *) str)
function_name = NULL;
nul_fun = NULL;
@@ -1335,7 +1344,8 @@ _bfd_stab_section_find_nearest_line (bfd
if (val <= offset)
{
file_name = (char *) str + bfd_get_32 (abfd, stab + STRDXOFF);
- if (file_name >= (char *) info->strs + strsize || file_name < (char *) str)
+ if (file_name >= (char *) info->strs + strsize
+ || file_name < (char *) str)
file_name = NULL;
*pline = 0;
}

View File

@@ -1,45 +0,0 @@
From cf93e9c2cf8f8b2566f8fc86e961592b51b5980d Mon Sep 17 00:00:00 2001
From: Alan Modra <amodra@gmail.com>
Date: Thu, 20 Sep 2018 18:23:17 +0930
Subject: [PATCH] PR23685, buffer overflow
PR 23685
* peXXigen.c (pe_print_edata): Correct export address table
overflow checks. Check dataoff against section size too.
CVE: CVE-2018-17360
Upstream-Status: Backport
Signed-off-by: Zhixiong Chi <zhixiong.chi@windriver.com>
---
bfd/ChangeLog | 6 ++++++
bfd/peXXigen.c | 11 ++++++-----
2 files changed, 12 insertions(+), 5 deletions(-)
--- a/bfd/peXXigen.c
+++ b/bfd/peXXigen.c
@@ -1661,7 +1661,8 @@ pe_print_edata (bfd * abfd, void * vfile
dataoff = addr - section->vma;
datasize = extra->DataDirectory[PE_EXPORT_TABLE].Size;
- if (datasize > section->size - dataoff)
+ if (dataoff > section->size
+ || datasize > section->size - dataoff)
{
fprintf (file,
_("\nThere is an export table in %s, but it does not fit into that section\n"),
@@ -1778,11 +1779,11 @@ pe_print_edata (bfd * abfd, void * vfile
edt.base);
/* PR 17512: Handle corrupt PE binaries. */
- if (edt.eat_addr + (edt.num_functions * 4) - adj >= datasize
+ /* PR 17512 file: 140-165018-0.004. */
+ if (edt.eat_addr - adj >= datasize
/* PR 17512: file: 092b1829 */
- || (edt.num_functions * 4) < edt.num_functions
- /* PR 17512 file: 140-165018-0.004. */
- || data + edt.eat_addr - adj < data)
+ || (edt.num_functions + 1) * 4 < edt.num_functions
+ || edt.eat_addr - adj + (edt.num_functions + 1) * 4 > datasize)
fprintf (file, _("\tInvalid Export Address Table rva (0x%lx) or entry count (0x%lx)\n"),
(long) edt.eat_addr,
(long) edt.num_functions);

View File

@@ -1,251 +0,0 @@
From 0930cb3021b8078b34cf216e79eb8608d017864f Mon Sep 17 00:00:00 2001
From: Alan Modra <amodra@gmail.com>
Date: Sat, 13 Oct 2018 22:03:02 +1030
Subject: [PATCH] _bfd_clear_contents bounds checking
This PR shows a fuzzed binary triggering a segfault via a bad
relocation in .debug_line. It turns out that unlike normal
relocations applied to a section, the linker applies those with
symbols from discarded sections via _bfd_clear_contents without
checking that the relocation is within the section bounds. The same
thing now happens when reading debug sections since commit
a4cd947aca23, the PR23425 fix.
PR 23770
PR 23425
* reloc.c (_bfd_clear_contents): Replace "location" param with
"buf" and "off". Bounds check "off". Return status.
* cofflink.c (_bfd_coff_generic_relocate_section): Update
_bfd_clear_contents call.
* elf-bfd.h (RELOC_AGAINST_DISCARDED_SECTION): Likewise.
* elf32-arc.c (elf_arc_relocate_section): Likewise.
* elf32-i386.c (elf_i386_relocate_section): Likewise.
* elf32-metag.c (metag_final_link_relocate): Likewise.
* elf32-nds32.c (nds32_elf_get_relocated_section_contents): Likewise.
* elf32-ppc.c (ppc_elf_relocate_section): Likewise.
* elf32-visium.c (visium_elf_relocate_section): Likewise.
* elf64-ppc.c (ppc64_elf_relocate_section): Likewise.
* elf64-x86-64.c *(elf_x86_64_relocate_section): Likewise.
* libbfd-in.h (_bfd_clear_contents): Update prototype.
* libbfd.h: Regenerate.
Upstream-Status: Backport
CVE: CVE-2018-18605
Signed-off-by: Zhixiong Chi <zhixiong.chi@windriver.com>
---
bfd/ChangeLog | 20 ++++++++++++++++++++
bfd/cofflink.c | 2 +-
bfd/elf-bfd.h | 2 +-
bfd/elf32-arc.c | 2 +-
bfd/elf32-i386.c | 2 +-
bfd/elf32-metag.c | 2 +-
bfd/elf32-nds32.c | 8 ++++----
bfd/elf32-ppc.c | 2 +-
bfd/elf32-visium.c | 2 +-
bfd/elf64-ppc.c | 2 +-
bfd/elf64-x86-64.c | 2 +-
bfd/libbfd-in.h | 4 ++--
bfd/libbfd.h | 4 ++--
bfd/reloc.c | 19 +++++++++++++------
14 files changed, 50 insertions(+), 23 deletions(-)
--- a/bfd/cofflink.c
+++ b/bfd/cofflink.c
@@ -3080,7 +3080,7 @@ _bfd_coff_generic_relocate_section (bfd
if (sec != NULL && discarded_section (sec))
{
_bfd_clear_contents (howto, input_bfd, input_section,
- contents + (rel->r_vaddr - input_section->vma));
+ contents, rel->r_vaddr - input_section->vma);
continue;
}
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -2811,7 +2811,7 @@ extern asection _bfd_elf_large_com_secti
{ \
int i_; \
_bfd_clear_contents (howto, input_bfd, input_section, \
- contents + rel[index].r_offset); \
+ contents, rel[index].r_offset); \
\
if (bfd_link_relocatable (info) \
&& (input_section->flags & SEC_DEBUGGING)) \
--- a/bfd/elf32-arc.c
+++ b/bfd/elf32-arc.c
@@ -1552,7 +1552,7 @@ elf_arc_relocate_section (bfd * outp
if (sec != NULL && discarded_section (sec))
{
_bfd_clear_contents (howto, input_bfd, input_section,
- contents + rel->r_offset);
+ contents, rel->r_offset);
rel->r_info = 0;
rel->r_addend = 0;
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -2197,7 +2197,7 @@ elf_i386_relocate_section (bfd *output_b
if (sec != NULL && discarded_section (sec))
{
_bfd_clear_contents (howto, input_bfd, input_section,
- contents + rel->r_offset);
+ contents, rel->r_offset);
wrel->r_offset = rel->r_offset;
wrel->r_info = 0;
wrel->r_addend = 0;
--- a/bfd/elf32-metag.c
+++ b/bfd/elf32-metag.c
@@ -1396,7 +1396,7 @@ metag_final_link_relocate (reloc_howto_t
rel, relend, howto, contents) \
{ \
_bfd_clear_contents (howto, input_bfd, input_section, \
- contents + rel->r_offset); \
+ contents, rel->r_offset); \
\
if (bfd_link_relocatable (info) \
&& (input_section->flags & SEC_DEBUGGING)) \
--- a/bfd/elf32-nds32.c
+++ b/bfd/elf32-nds32.c
@@ -12582,14 +12582,14 @@ nds32_elf_get_relocated_section_contents
symbol = *(*parent)->sym_ptr_ptr;
if (symbol->section && discarded_section (symbol->section))
{
- bfd_byte *p;
+ bfd_vma off;
static reloc_howto_type none_howto
= HOWTO (0, 0, 0, 0, FALSE, 0, complain_overflow_dont, NULL,
"unused", FALSE, 0, 0, FALSE);
- p = data + (*parent)->address * bfd_octets_per_byte (input_bfd);
- _bfd_clear_contents ((*parent)->howto, input_bfd, input_section,
- p);
+ off = (*parent)->address * bfd_octets_per_byte (input_bfd);
+ _bfd_clear_contents ((*parent)->howto, input_bfd,
+ input_section, data, off);
(*parent)->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
(*parent)->addend = 0;
(*parent)->howto = &none_howto;
--- a/bfd/elf32-ppc.c
+++ b/bfd/elf32-ppc.c
@@ -8232,7 +8232,7 @@ ppc_elf_relocate_section (bfd *output_bf
howto = ppc_elf_howto_table[r_type];
_bfd_clear_contents (howto, input_bfd, input_section,
- contents + rel->r_offset);
+ contents, rel->r_offset);
wrel->r_offset = rel->r_offset;
wrel->r_info = 0;
wrel->r_addend = 0;
--- a/bfd/elf32-visium.c
+++ b/bfd/elf32-visium.c
@@ -621,7 +621,7 @@ visium_elf_relocate_section (bfd *output
or sections discarded by a linker script, we just want the
section contents zeroed. Avoid any special processing. */
_bfd_clear_contents (howto, input_bfd, input_section,
- contents + rel->r_offset);
+ contents, rel->r_offset);
rel->r_info = 0;
rel->r_addend = 0;
--- a/bfd/elf64-ppc.c
+++ b/bfd/elf64-ppc.c
@@ -14074,7 +14074,7 @@ ppc64_elf_relocate_section (bfd *output_
{
_bfd_clear_contents (ppc64_elf_howto_table[r_type],
input_bfd, input_section,
- contents + rel->r_offset);
+ contents, rel->r_offset);
wrel->r_offset = rel->r_offset;
wrel->r_info = 0;
wrel->r_addend = 0;
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -2490,7 +2490,7 @@ elf_x86_64_relocate_section (bfd *output
if (sec != NULL && discarded_section (sec))
{
_bfd_clear_contents (howto, input_bfd, input_section,
- contents + rel->r_offset);
+ contents, rel->r_offset);
wrel->r_offset = rel->r_offset;
wrel->r_info = 0;
wrel->r_addend = 0;
--- a/bfd/libbfd-in.h
+++ b/bfd/libbfd-in.h
@@ -696,8 +696,8 @@ extern bfd_reloc_status_type _bfd_reloca
(reloc_howto_type *, bfd *, bfd_vma, bfd_byte *) ATTRIBUTE_HIDDEN;
/* Clear a given location using a given howto. */
-extern void _bfd_clear_contents
- (reloc_howto_type *, bfd *, asection *, bfd_byte *) ATTRIBUTE_HIDDEN;
+extern bfd_reloc_status_type _bfd_clear_contents
+ (reloc_howto_type *, bfd *, asection *, bfd_byte *, bfd_vma) ATTRIBUTE_HIDDEN;
/* Link stabs in sections in the first pass. */
--- a/bfd/libbfd.h
+++ b/bfd/libbfd.h
@@ -701,8 +701,8 @@ extern bfd_reloc_status_type _bfd_reloca
(reloc_howto_type *, bfd *, bfd_vma, bfd_byte *) ATTRIBUTE_HIDDEN;
/* Clear a given location using a given howto. */
-extern void _bfd_clear_contents
- (reloc_howto_type *, bfd *, asection *, bfd_byte *) ATTRIBUTE_HIDDEN;
+extern bfd_reloc_status_type _bfd_clear_contents
+ (reloc_howto_type *, bfd *, asection *, bfd_byte *, bfd_vma) ATTRIBUTE_HIDDEN;
/* Link stabs in sections in the first pass. */
--- a/bfd/reloc.c
+++ b/bfd/reloc.c
@@ -1613,16 +1613,22 @@ _bfd_relocate_contents (reloc_howto_type
relocations against discarded symbols, to make ignorable debug or unwind
information more obvious. */
-void
+bfd_reloc_status_type
_bfd_clear_contents (reloc_howto_type *howto,
bfd *input_bfd,
asection *input_section,
- bfd_byte *location)
+ bfd_byte *buf,
+ bfd_vma off)
{
int size;
bfd_vma x = 0;
+ bfd_byte *location;
+
+ if (!bfd_reloc_offset_in_range (howto, input_bfd, input_section, off))
+ return bfd_reloc_outofrange;
/* Get the value we are going to relocate. */
+ location = buf + off;
size = bfd_get_reloc_size (howto);
switch (size)
{
@@ -1681,6 +1687,7 @@ _bfd_clear_contents (reloc_howto_type *h
#endif
break;
}
+ return bfd_reloc_ok;
}
/*
@@ -8268,14 +8275,14 @@ bfd_generic_get_relocated_section_conten
if (symbol->section && discarded_section (symbol->section))
{
- bfd_byte *p;
+ bfd_vma off;
static reloc_howto_type none_howto
= HOWTO (0, 0, 0, 0, FALSE, 0, complain_overflow_dont, NULL,
"unused", FALSE, 0, 0, FALSE);
- p = data + (*parent)->address * bfd_octets_per_byte (input_bfd);
- _bfd_clear_contents ((*parent)->howto, input_bfd, input_section,
- p);
+ off = (*parent)->address * bfd_octets_per_byte (input_bfd);
+ _bfd_clear_contents ((*parent)->howto, input_bfd,
+ input_section, data, off);
(*parent)->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
(*parent)->addend = 0;
(*parent)->howto = &none_howto;

View File

@@ -1,29 +0,0 @@
From ab419ddbb2cdd17ca83618990f2cacf904ce1d61 Mon Sep 17 00:00:00 2001
From: Alan Modra <amodra@gmail.com>
Date: Tue, 23 Oct 2018 18:29:24 +1030
Subject: [PATCH] PR23804, buffer overflow in sec_merge_hash_lookup
PR 23804
* merge.c (_bfd_add_merge_section): Don't attempt to merge
sections where size is not a multiple of entsize.
Upstream-Status: Backport
CVE: CVE-2018-18605
Signed-off-by: Zhixiong Chi <zhixiong.chi@windriver.com>
---
bfd/ChangeLog | 6 ++++++
bfd/merge.c | 3 +++
2 files changed, 9 insertions(+)
--- a/bfd/merge.c
+++ b/bfd/merge.c
@@ -376,6 +376,9 @@ _bfd_add_merge_section (bfd *abfd, void
|| sec->entsize == 0)
return TRUE;
+ if (sec->size % sec->entsize != 0)
+ return TRUE;
+
if ((sec->flags & SEC_RELOC) != 0)
{
/* We aren't prepared to handle relocations in merged sections. */

View File

@@ -1,50 +0,0 @@
From 45a0eaf77022963d639d6d19871dbab7b79703fc Mon Sep 17 00:00:00 2001
From: Alan Modra <amodra@gmail.com>
Date: Tue, 23 Oct 2018 19:02:06 +1030
Subject: [PATCH] PR23806, NULL pointer dereference in merge_strings
PR 23806
* merge.c (_bfd_add_merge_section): Don't attempt to merge
sections with ridiculously large alignments.
Upstream-Status: Backport
CVE: CVE-2018-18606
Signed-off-by: Zhixiong Chi <zhixiong.chi@windriver.com>
---
bfd/ChangeLog | 6 ++++++
bfd/merge.c | 15 +++++++++++----
2 files changed, 17 insertions(+), 4 deletions(-)
--- a/bfd/merge.c
+++ b/bfd/merge.c
@@ -24,6 +24,7 @@
as used in ELF SHF_MERGE. */
#include "sysdep.h"
+#include <limits.h>
#include "bfd.h"
#include "elf-bfd.h"
#include "libbfd.h"
@@ -385,12 +386,18 @@ _bfd_add_merge_section (bfd *abfd, void
return TRUE;
}
- align = sec->alignment_power;
- if ((sec->entsize < (unsigned) 1 << align
+#ifndef CHAR_BIT
+#define CHAR_BIT 8
+#endif
+ if (sec->alignment_power >= sizeof (align) * CHAR_BIT)
+ return TRUE;
+
+ align = 1u << sec->alignment_power;
+ if ((sec->entsize < align
&& ((sec->entsize & (sec->entsize - 1))
|| !(sec->flags & SEC_STRINGS)))
- || (sec->entsize > (unsigned) 1 << align
- && (sec->entsize & (((unsigned) 1 << align) - 1))))
+ || (sec->entsize > align
+ && (sec->entsize & (align - 1))))
{
/* Sanity check. If string character size is smaller than
alignment, then we require character size to be a power

View File

@@ -1,56 +0,0 @@
From 102def4da826b3d9e169741421e5e67e8731909a Mon Sep 17 00:00:00 2001
From: Alan Modra <amodra@gmail.com>
Date: Tue, 23 Oct 2018 18:30:22 +1030
Subject: [PATCH] PR23805, NULL pointer dereference in elf_link_input_bfd
PR 23805
* elflink.c (elf_link_input_bfd): Don't segfault on finding
STT_TLS symbols without any TLS sections. Instead, change the
symbol type to STT_NOTYPE.
Upstream-Status: Backport
CVE: CVE-2018-18606
Signed-off-by: Zhixiong Chi <zhixiong.chi@windriver.com>
---
bfd/ChangeLog | 7 +++++++
bfd/elflink.c | 20 ++++++++++++++------
2 files changed, 21 insertions(+), 6 deletions(-)
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -10496,8 +10496,11 @@ elf_link_input_bfd (struct elf_final_lin
if (ELF_ST_TYPE (osym.st_info) == STT_TLS)
{
/* STT_TLS symbols are relative to PT_TLS segment base. */
- BFD_ASSERT (elf_hash_table (flinfo->info)->tls_sec != NULL);
- osym.st_value -= elf_hash_table (flinfo->info)->tls_sec->vma;
+ if (elf_hash_table (flinfo->info)->tls_sec != NULL)
+ osym.st_value -= elf_hash_table (flinfo->info)->tls_sec->vma;
+ else
+ osym.st_info = ELF_ST_INFO (ELF_ST_BIND (osym.st_info),
+ STT_NOTYPE);
}
}
@@ -11053,12 +11056,17 @@ elf_link_input_bfd (struct elf_final_lin
sym.st_value += osec->vma;
if (ELF_ST_TYPE (sym.st_info) == STT_TLS)
{
+ struct elf_link_hash_table *htab
+ = elf_hash_table (flinfo->info);
+
/* STT_TLS symbols are relative to PT_TLS
segment base. */
- BFD_ASSERT (elf_hash_table (flinfo->info)
- ->tls_sec != NULL);
- sym.st_value -= (elf_hash_table (flinfo->info)
- ->tls_sec->vma);
+ if (htab->tls_sec != NULL)
+ sym.st_value -= htab->tls_sec->vma;
+ else
+ sym.st_info
+ = ELF_ST_INFO (ELF_ST_BIND (sym.st_info),
+ STT_NOTYPE);
}
}

View File

@@ -1,30 +0,0 @@
Fix compiler error seen with clang, The return value of this
function is not checked anywhere so in a way its useless but
still technically correct to return a value here
Fixes
../../bfd/reloc.c:1638:7: error: non-void function '_bfd_clear_contents' should return a value [-Wreturn-type]
return;
^
1 error generated.
It has been fixed in master along with a larger cleanup and fix for relocations
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=1dc9e2d63e37839ff1768346b2e3f52e338baba5
Upstream-Status: Backport [Fixes differently]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
--- a/bfd/reloc.c
+++ b/bfd/reloc.c
@@ -1629,7 +1629,7 @@ _bfd_clear_contents (reloc_howto_type *h
default:
abort ();
case 0:
- return;
+ return 0;
case 1:
x = bfd_get_8 (input_bfd, location);
break;