Initial commit
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
LIC_FILES_CHKSUM="\
|
||||
file://COPYING;md5=59530bdf33659b29e73d4adb9f9f6552\
|
||||
file://COPYING.LIB;md5=9f604d8a4f8e74f4f5140845a21b6674\
|
||||
file://COPYING3;md5=d32239bcb673463ab874e80d47fae504\
|
||||
file://COPYING3.LIB;md5=6a6a8e020838b23406c81b19c1d46df6\
|
||||
file://gas/COPYING;md5=d32239bcb673463ab874e80d47fae504\
|
||||
file://include/COPYING;md5=59530bdf33659b29e73d4adb9f9f6552\
|
||||
file://include/COPYING3;md5=d32239bcb673463ab874e80d47fae504\
|
||||
file://libiberty/COPYING.LIB;md5=a916467b91076e631dd8edb7424769c7\
|
||||
file://bfd/COPYING;md5=d32239bcb673463ab874e80d47fae504\
|
||||
"
|
||||
|
||||
# When upgrading to 2.41, please make sure there is no trailing .0, so
|
||||
# that upstream version check can work correctly.
|
||||
PV = "2.40"
|
||||
CVE_VERSION = "2.40"
|
||||
SRCBRANCH ?= "binutils-2_40-branch"
|
||||
|
||||
UPSTREAM_CHECK_GITTAGREGEX = "binutils-(?P<pver>\d+_(\d_?)*)"
|
||||
|
||||
SRCREV ?= "4671be001eb5a899ecac3e2686a92934000f8262"
|
||||
BINUTILS_GIT_URI ?= "git://sourceware.org/git/binutils-gdb.git;branch=${SRCBRANCH};protocol=https"
|
||||
SRC_URI = "\
|
||||
${BINUTILS_GIT_URI} \
|
||||
file://0004-Point-scripts-location-to-libdir.patch \
|
||||
file://0005-don-t-let-the-distro-compiler-point-to-the-wrong-ins.patch \
|
||||
file://0006-warn-for-uses-of-system-directories-when-cross-linki.patch \
|
||||
file://0007-fix-the-incorrect-assembling-for-ppc-wait-mnemonic.patch \
|
||||
file://0008-Use-libtool-2.4.patch \
|
||||
file://0009-Fix-rpath-in-libtool-when-sysroot-is-enabled.patch \
|
||||
file://0010-sync-with-OE-libtool-changes.patch \
|
||||
file://0011-Check-for-clang-before-checking-gcc-version.patch \
|
||||
file://0012-Only-generate-an-RPATH-entry-if-LD_RUN_PATH-is-not-e.patch \
|
||||
file://0013-Define-alignof-using-_Alignof-when-using-C11-or-newe.patch \
|
||||
file://0015-Remove-duplicate-pe-dll.o-entry-deom-targ_extra_ofil.patch \
|
||||
file://0016-CVE-2023-25586.patch \
|
||||
file://fix-time64.patch \
|
||||
file://0001-Fix-an-illegal-memory-access-when-an-accessing-a-zer.patch \
|
||||
"
|
||||
S = "${WORKDIR}/git"
|
||||
@@ -0,0 +1,32 @@
|
||||
inherit cross-canadian
|
||||
|
||||
SUMMARY = "GNU binary utilities (cross-canadian for ${TARGET_ARCH} target)"
|
||||
PN = "binutils-cross-canadian-${TRANSLATED_TARGET_ARCH}"
|
||||
BPN = "binutils"
|
||||
|
||||
DEPENDS = "flex-native bison-native virtual/${HOST_PREFIX}gcc virtual/nativesdk-libc nativesdk-zlib nativesdk-gettext nativesdk-flex"
|
||||
EXTRA_OECONF += "--with-sysroot=${SDKPATH}/sysroots/${TUNE_PKGARCH}${TARGET_VENDOR}-${TARGET_OS} \
|
||||
--enable-poison-system-directories \
|
||||
"
|
||||
|
||||
# We have to point binutils at a sysroot but we don't need to rebuild if this changes
|
||||
# e.g. we switch between different machines with different tunes.
|
||||
EXTRA_OECONF[vardepsexclude] = "TUNE_PKGARCH"
|
||||
|
||||
do_install () {
|
||||
autotools_do_install
|
||||
|
||||
# We're not interested in the libs or headers, these would come from the
|
||||
# nativesdk or target version of the binutils recipe
|
||||
rm -rf ${D}${prefix}/${TARGET_SYS}
|
||||
rm -f ${D}${libdir}/libbfd*
|
||||
rm -f ${D}${libdir}/libiberty*
|
||||
rm -f ${D}${libdir}/libopcodes*
|
||||
rm -f ${D}${includedir}/*.h
|
||||
rm -f ${D}${sysconfdir}/gprofng.rc
|
||||
rmdir ${D}${sysconfdir} || :
|
||||
|
||||
cross_canadian_bindirlinks
|
||||
}
|
||||
|
||||
BBCLASSEXTEND = ""
|
||||
@@ -0,0 +1,3 @@
|
||||
require binutils.inc
|
||||
require binutils-${PV}.inc
|
||||
require binutils-cross-canadian.inc
|
||||
@@ -0,0 +1,81 @@
|
||||
require binutils.inc
|
||||
require binutils-${PV}.inc
|
||||
|
||||
BPN = "binutils"
|
||||
|
||||
DEPENDS += "dejagnu-native expect-native"
|
||||
DEPENDS += "binutils-native"
|
||||
|
||||
deltask do_compile
|
||||
deltask do_install
|
||||
|
||||
inherit nopackages
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
# target depends
|
||||
DEPENDS += "virtual/${TARGET_PREFIX}binutils"
|
||||
DEPENDS += "virtual/${TARGET_PREFIX}gcc"
|
||||
DEPENDS += "virtual/${MLPREFIX}${TARGET_PREFIX}compilerlibs"
|
||||
DEPENDS += "virtual/${MLPREFIX}libc"
|
||||
|
||||
python check_prepare() {
|
||||
def suffix_sys(sys):
|
||||
if sys.endswith("-linux"):
|
||||
return sys + "-gnu"
|
||||
return sys
|
||||
|
||||
def generate_site_exp(d, suite):
|
||||
content = []
|
||||
content.append('set srcdir "{0}/{1}"'.format(d.getVar("S"), suite))
|
||||
content.append('set objdir "{0}/{1}"'.format(d.getVar("B"), suite))
|
||||
content.append('set build_alias "{0}"'.format(d.getVar("BUILD_SYS")))
|
||||
content.append('set build_triplet {0}'.format(d.getVar("BUILD_SYS")))
|
||||
# use BUILD here since HOST=TARGET
|
||||
content.append('set host_alias "{0}"'.format(d.getVar("BUILD_SYS")))
|
||||
content.append('set host_triplet {0}'.format(d.getVar("BUILD_SYS")))
|
||||
content.append('set target_alias "{0}"'.format(d.getVar("TARGET_SYS")))
|
||||
content.append('set target_triplet {0}'.format(suffix_sys(d.getVar("TARGET_SYS"))))
|
||||
content.append("set development true")
|
||||
content.append("set experimental false")
|
||||
|
||||
content.append(d.expand('set CXXFILT "${TARGET_PREFIX}c++filt"'))
|
||||
content.append(d.expand('set CC "${TARGET_PREFIX}gcc --sysroot=${STAGING_DIR_TARGET} ${TUNE_CCARGS}"'))
|
||||
content.append(d.expand('set CXX "${TARGET_PREFIX}g++ --sysroot=${STAGING_DIR_TARGET} ${TUNE_CCARGS}"'))
|
||||
content.append(d.expand('set CFLAGS_FOR_TARGET "--sysroot=${STAGING_DIR_TARGET} ${TUNE_CCARGS}"'))
|
||||
|
||||
if suite == "ld" and d.getVar("TUNE_ARCH") == "mips64":
|
||||
# oe patches binutils to have the default mips64 abi as 64bit, but
|
||||
# skips gas causing issues with the ld test suite (which uses gas)
|
||||
content.append('set ASFLAGS "-64"')
|
||||
|
||||
return "\n".join(content)
|
||||
|
||||
for i in ["binutils", "gas", "ld"]:
|
||||
builddir = os.path.join(d.getVar("B"), i)
|
||||
if not os.path.isdir(builddir):
|
||||
os.makedirs(builddir)
|
||||
with open(os.path.join(builddir, "site.exp"), "w") as f:
|
||||
f.write(generate_site_exp(d, i))
|
||||
}
|
||||
|
||||
CHECK_TARGETS ??= "binutils gas ld"
|
||||
|
||||
do_check[dirs] = "${B} ${B}/binutils ${B}/gas ${B}/ld"
|
||||
do_check[prefuncs] += "check_prepare"
|
||||
do_check[nostamp] = "1"
|
||||
do_check() {
|
||||
export LC_ALL=C
|
||||
for i in ${CHECK_TARGETS}; do
|
||||
(cd ${B}/$i; runtest \
|
||||
--tool $i \
|
||||
--srcdir ${S}/$i/testsuite \
|
||||
--ignore 'plugin.exp' \
|
||||
|| true)
|
||||
done
|
||||
}
|
||||
addtask check after do_configure
|
||||
@@ -0,0 +1,39 @@
|
||||
inherit cross
|
||||
PROVIDES = "virtual/${TARGET_PREFIX}binutils"
|
||||
|
||||
PN = "binutils-cross-${TARGET_ARCH}"
|
||||
BPN = "binutils"
|
||||
|
||||
# Ignore how TARGET_ARCH is computed.
|
||||
TARGET_ARCH[vardepvalue] = "${TARGET_ARCH}"
|
||||
|
||||
INHIBIT_DEFAULT_DEPS = "1"
|
||||
INHIBIT_AUTOTOOLS_DEPS = "1"
|
||||
|
||||
SRC_URI += "file://0002-binutils-cross-Do-not-generate-linker-script-directo.patch"
|
||||
|
||||
# Specify lib-path else we use a load of search dirs which we don't use
|
||||
# and mean the linker scripts have to be relocated.
|
||||
EXTRA_OECONF += "--with-sysroot=${STAGING_DIR_TARGET} \
|
||||
--disable-install-libbfd \
|
||||
--disable-gprofng \
|
||||
--enable-poison-system-directories \
|
||||
--with-lib-path==${target_base_libdir}:=${target_libdir} \
|
||||
"
|
||||
do_install () {
|
||||
oe_runmake 'DESTDIR=${D}' install
|
||||
|
||||
# We don't really need these, so we'll remove them...
|
||||
rm -rf ${D}${STAGING_DIR_NATIVE}${libdir_native}/libiberty.a
|
||||
rm -rf ${D}${STAGING_DIR_NATIVE}${prefix_native}/${TARGET_SYS}
|
||||
rm -rf ${D}${STAGING_DIR_NATIVE}${prefix_native}/lib/ldscripts
|
||||
rm -rf ${D}${STAGING_DIR_NATIVE}${prefix_native}/share/info
|
||||
rm -rf ${D}${STAGING_DIR_NATIVE}${prefix_native}/share/locale
|
||||
rm -rf ${D}${STAGING_DIR_NATIVE}${prefix_native}/share/man
|
||||
rmdir ${D}${STAGING_DIR_NATIVE}${prefix_native}/share || :
|
||||
rmdir ${D}${STAGING_DIR_NATIVE}${prefix_native}/${libdir}/gcc-lib || :
|
||||
rmdir ${D}${STAGING_DIR_NATIVE}${prefix_native}/${libdir}64/gcc-lib || :
|
||||
rmdir ${D}${STAGING_DIR_NATIVE}${prefix_native}/${libdir} || :
|
||||
rmdir ${D}${STAGING_DIR_NATIVE}${prefix_native}/${libdir}64 || :
|
||||
rmdir ${D}${STAGING_DIR_NATIVE}${prefix_native}/${prefix} || :
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
require binutils.inc
|
||||
require binutils-${PV}.inc
|
||||
require binutils-cross.inc
|
||||
@@ -0,0 +1,11 @@
|
||||
require binutils-cross_${PV}.bb
|
||||
|
||||
inherit crosssdk
|
||||
|
||||
PN = "binutils-crosssdk-${SDK_SYS}"
|
||||
|
||||
SRC_URI += "file://0001-binutils-crosssdk-Generate-relocatable-SDKs.patch"
|
||||
|
||||
do_configure:prepend () {
|
||||
sed -i 's#/usr/local/lib /lib /usr/lib#${SDKPATHNATIVE}/lib ${SDKPATHNATIVE}/usr/lib /usr/local/lib /lib /usr/lib#' ${S}/ld/configure.tgt
|
||||
}
|
||||
@@ -0,0 +1,207 @@
|
||||
SUMMARY = "GNU binary utilities"
|
||||
DESCRIPTION = "The GNU Binutils are a collection of binary tools. \
|
||||
The main ones are ld (GNU Linker), and as (GNU Assembler). This \
|
||||
package also includes addition tools such as addr2line (Converts \
|
||||
addresses into filenames and line numbers), ar (utility for creating, \
|
||||
modifying and extracting archives), nm (list symbols in object \
|
||||
files), objcopy (copy and translate object files), objdump (Display \
|
||||
object information), and other tools and related libraries."
|
||||
HOMEPAGE = "http://www.gnu.org/software/binutils/"
|
||||
BUGTRACKER = "http://sourceware.org/bugzilla/"
|
||||
SECTION = "devel"
|
||||
LICENSE = "GPL-3.0-only"
|
||||
|
||||
DEPENDS = "flex-native bison-native zlib-native gnu-config-native autoconf-native"
|
||||
|
||||
inherit autotools gettext multilib_header pkgconfig texinfo
|
||||
|
||||
FILES:${PN} = " \
|
||||
${bindir}/${TARGET_PREFIX}* \
|
||||
${libdir}/lib*.so.* \
|
||||
${libdir}/bfd-plugins/lib*.so \
|
||||
${libdir}/lib*-${PV}*.so \
|
||||
${prefix}/${TARGET_SYS}/bin/* \
|
||||
${bindir}/embedspu"
|
||||
|
||||
RPROVIDES:${PN} += "${PN}-symlinks"
|
||||
|
||||
FILES:${PN}-dev = " \
|
||||
${includedir} \
|
||||
${libdir}/*.la \
|
||||
${libdir}/libbfd.so \
|
||||
${libdir}/libctf.so \
|
||||
${libdir}/libctf-nobfd.so \
|
||||
${libdir}/libopcodes.so"
|
||||
|
||||
FILES:${PN}-staticdev += "${libdir}/gprofng/*.a"
|
||||
|
||||
# Rather than duplicating multiple entries for these, make one
|
||||
# list and reuse it.
|
||||
|
||||
GPROFNGS = " \
|
||||
gp-archive \
|
||||
gp-collect-app \
|
||||
gp-display-html \
|
||||
gp-display-src \
|
||||
gp-display-text \
|
||||
gprofng \
|
||||
"
|
||||
|
||||
# it disables gprofng for clang and musl in the bb file
|
||||
GPROFNGS:toolchain-clang = ""
|
||||
GPROFNGS:libc-musl = ""
|
||||
|
||||
GPROFNG_ALTS ?= ""
|
||||
GPROFNG_ALTS:x86 = "${GPROFNGS}"
|
||||
GPROFNG_ALTS:x86-64 = "${GPROFNGS}"
|
||||
GPROFNG_ALTS:aarch64 = "${GPROFNGS}"
|
||||
|
||||
LDGOLD_ALTS ?= "ld.gold dwp"
|
||||
LDGOLD_ALTS:riscv64 = ""
|
||||
LDGOLD_ALTS:riscv32 = ""
|
||||
LDGOLD_ALTS:loongarch64 = ""
|
||||
LDGOLD_ALTS:libc-glibc:mipsarch = ""
|
||||
|
||||
USE_ALTERNATIVES_FOR = " \
|
||||
addr2line \
|
||||
ar \
|
||||
as \
|
||||
c++filt \
|
||||
elfedit \
|
||||
gprof \
|
||||
${GPROFNG_ALTS} \
|
||||
ld \
|
||||
ld.bfd \
|
||||
${LDGOLD_ALTS} \
|
||||
nm \
|
||||
objcopy \
|
||||
objdump \
|
||||
ranlib \
|
||||
readelf \
|
||||
size \
|
||||
strings \
|
||||
strip \
|
||||
"
|
||||
|
||||
python do_package:prepend() {
|
||||
make_alts = d.getVar("USE_ALTERNATIVES_FOR") or ""
|
||||
prefix = d.getVar("TARGET_PREFIX")
|
||||
bindir = d.getVar("bindir")
|
||||
for alt in make_alts.split():
|
||||
d.setVarFlag('ALTERNATIVE_TARGET', alt, bindir + "/" + prefix + alt)
|
||||
d.setVarFlag('ALTERNATIVE_LINK_NAME', alt, bindir + "/" + alt)
|
||||
}
|
||||
|
||||
B = "${S}/build.${HOST_SYS}.${TARGET_SYS}"
|
||||
|
||||
EXTRA_OECONF = "--program-prefix=${TARGET_PREFIX} \
|
||||
--disable-werror \
|
||||
--enable-deterministic-archives \
|
||||
--enable-plugins \
|
||||
--enable-new-dtags \
|
||||
--disable-gdb \
|
||||
--disable-gdbserver \
|
||||
--disable-libdecnumber \
|
||||
--disable-readline \
|
||||
--disable-sim \
|
||||
${LDGOLD} \
|
||||
${EXTRA_TARGETS} \
|
||||
${@bb.utils.contains('DISTRO_FEATURES', 'multiarch', '--enable-64-bit-bfd', '', d)}"
|
||||
|
||||
EXTRA_TARGETS = ""
|
||||
EXTRA_TARGETS:x86-64 = " --enable-targets=x86_64-pe,x86_64-pep "
|
||||
EXTRA_TARGETS:class-native = ""
|
||||
|
||||
LDGOLD:class-native = ""
|
||||
LDGOLD:class-crosssdk = ""
|
||||
LDGOLD:libc-glibc:mipsarch = ""
|
||||
LDGOLD ?= "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', '--enable-gold=default --enable-threads', '--enable-gold --enable-ld=default --enable-threads', d)}"
|
||||
|
||||
|
||||
# This is necessary due to a bug in the binutils Makefiles
|
||||
# EXTRA_OEMAKE = "configure-build-libiberty all"
|
||||
|
||||
export AR = "${HOST_PREFIX}ar"
|
||||
export AS = "${HOST_PREFIX}as"
|
||||
export LD = "${HOST_PREFIX}ld"
|
||||
export NM = "${HOST_PREFIX}nm"
|
||||
export RANLIB = "${HOST_PREFIX}ranlib"
|
||||
export OBJCOPY = "${HOST_PREFIX}objcopy"
|
||||
export OBJDUMP = "${HOST_PREFIX}objdump"
|
||||
|
||||
export AR_FOR_TARGET = "${TARGET_PREFIX}ar"
|
||||
export AS_FOR_TARGET = "${TARGET_PREFIX}as"
|
||||
export LD_FOR_TARGET = "${TARGET_PREFIX}ld"
|
||||
export NM_FOR_TARGET = "${TARGET_PREFIX}nm"
|
||||
export RANLIB_FOR_TARGET = "${TARGET_PREFIX}ranlib"
|
||||
|
||||
export CC_FOR_HOST = "${CCACHE}${HOST_PREFIX}gcc ${HOST_CC_ARCH}"
|
||||
export CXX_FOR_HOST = "${CCACHE}${HOST_PREFIX}gcc ${HOST_CC_ARCH}"
|
||||
|
||||
# autotools.bbclass sets the _FOR_BUILD variables, but for some reason we need
|
||||
# to unset LD_LIBRARY_PATH.
|
||||
export CC_FOR_BUILD = "LD_LIBRARY_PATH= ${BUILD_CC}"
|
||||
|
||||
MULTIARCH := "${@bb.utils.contains("DISTRO_FEATURES", "multiarch", "yes", "no", d)}"
|
||||
do_configure[vardeps] += "MULTIARCH"
|
||||
do_configure () {
|
||||
(cd ${S} && gnu-configize)
|
||||
|
||||
oe_runconf
|
||||
#
|
||||
# must prime config.cache to ensure the build of libiberty
|
||||
#
|
||||
mkdir -p ${B}/build-${BUILD_SYS}
|
||||
for i in ${CONFIG_SITE}; do
|
||||
cat $i >> ${B}/build-${BUILD_SYS}/config.cache || true
|
||||
done
|
||||
}
|
||||
|
||||
do_install () {
|
||||
autotools_do_install
|
||||
|
||||
# We don't really need these, so we'll remove them...
|
||||
rm -rf ${D}${libdir}/ldscripts
|
||||
|
||||
bindir_rel=${@os.path.relpath('${bindir}', '${prefix}/${TARGET_SYS}/bin')}
|
||||
|
||||
# Fix the /usr/${TARGET_SYS}/bin/* links
|
||||
for l in ${D}${prefix}/${TARGET_SYS}/bin/*; do
|
||||
rm -f $l
|
||||
ln -sf $bindir_rel/${TARGET_PREFIX}`basename $l` $l
|
||||
done
|
||||
|
||||
# Install the libiberty header
|
||||
install -d ${D}${includedir}
|
||||
install -m 644 ${S}/include/ansidecl.h ${D}${includedir}
|
||||
install -m 644 ${S}/include/libiberty.h ${D}${includedir}
|
||||
|
||||
# insall pic version of libiberty if available
|
||||
if [ -e ${B}/libiberty/pic/libiberty.a ]; then
|
||||
install -Dm 0644 ${B}/libiberty/pic/libiberty.a ${D}${libdir}/libiberty.a
|
||||
fi
|
||||
|
||||
cd ${D}${bindir}
|
||||
|
||||
# Symlinks for ease of running these on the native target
|
||||
for p in ${TARGET_PREFIX}* ; do
|
||||
ln -sf $p `echo $p | sed -e s,${TARGET_PREFIX},,`
|
||||
done
|
||||
|
||||
for alt in ${USE_ALTERNATIVES_FOR}; do
|
||||
rm -f ${D}${bindir}/$alt
|
||||
done
|
||||
|
||||
oe_multilib_header bfd.h
|
||||
}
|
||||
|
||||
inherit update-alternatives
|
||||
|
||||
ALTERNATIVE_PRIORITY = "100"
|
||||
|
||||
ALTERNATIVE:${PN}:class-target = "${USE_ALTERNATIVES_FOR}"
|
||||
|
||||
python () {
|
||||
if bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', True, False, d) and bb.utils.contains_any('TARGET_ARCH', 'riscv32 riscv64 loongarch64', True, False, d):
|
||||
bb.fatal("Gold linker does not _yet_ support RISC-V and LoongArch architecture please remove ld-is-gold from DISTRO_FEATURES")
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
From c22d38baefc5a7a1e1f5cdc9dbb556b1f0ec5c57 Mon Sep 17 00:00:00 2001
|
||||
From: Nick Clifton <nickc@redhat.com>
|
||||
Date: Thu, 30 Mar 2023 10:10:09 +0100
|
||||
Subject: [PATCH] Fix an illegal memory access when an accessing a
|
||||
zer0-lengthverdef table.
|
||||
|
||||
PR 30285
|
||||
* elf.c (_bfd_elf_slurp_version_tables): Fail if no version definitions are allocated.
|
||||
|
||||
CVE: CVE-2023-1972
|
||||
Upstream-Status: Backport
|
||||
Signed-off-by: Ross Burton <ross.burton@arm.com>
|
||||
---
|
||||
bfd/ChangeLog | 6 ++++++
|
||||
bfd/elf.c | 5 +++++
|
||||
2 files changed, 11 insertions(+)
|
||||
|
||||
diff --git a/bfd/elf.c b/bfd/elf.c
|
||||
index 027d0143735..185028cbd97 100644
|
||||
--- a/bfd/elf.c
|
||||
+++ b/bfd/elf.c
|
||||
@@ -9030,6 +9030,9 @@ _bfd_elf_slurp_version_tables (bfd *abfd, bool default_imported_symver)
|
||||
bfd_set_error (bfd_error_file_too_big);
|
||||
goto error_return_verdef;
|
||||
}
|
||||
+
|
||||
+ if (amt == 0)
|
||||
+ goto error_return_verdef;
|
||||
elf_tdata (abfd)->verdef = (Elf_Internal_Verdef *) bfd_zalloc (abfd, amt);
|
||||
if (elf_tdata (abfd)->verdef == NULL)
|
||||
goto error_return_verdef;
|
||||
@@ -9133,6 +9136,8 @@ _bfd_elf_slurp_version_tables (bfd *abfd, bool default_imported_symver)
|
||||
bfd_set_error (bfd_error_file_too_big);
|
||||
goto error_return;
|
||||
}
|
||||
+ if (amt == 0)
|
||||
+ goto error_return;
|
||||
elf_tdata (abfd)->verdef = (Elf_Internal_Verdef *) bfd_zalloc (abfd, amt);
|
||||
if (elf_tdata (abfd)->verdef == NULL)
|
||||
goto error_return;
|
||||
--
|
||||
2.34.1
|
||||
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
From 4bdab425bdd7dc52c95bfd62e035c1b9abe9595e 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
|
||||
|
||||
This patch will modify the ELF linker scripts so that the crosssdk
|
||||
linker will generate binaries with a 4096 bytes PT_INTERP section. When the binaries
|
||||
will be relocated, at SDK install time, the interpreter path can be easily
|
||||
changed by the relocating script.
|
||||
|
||||
generate larger .interp section for gold linker as well
|
||||
|
||||
Upstream-Status: Inappropriate [SDK specific]
|
||||
|
||||
Signed-off-by: Laurentiu Palcu <laurentiu.palcu@intel.com>
|
||||
Signed-off-by: Khem Raj <raj.khem@gmail.com>
|
||||
---
|
||||
gold/layout.cc | 2 +-
|
||||
ld/genscripts.sh | 3 +++
|
||||
ld/scripttempl/elf.sc | 4 ++--
|
||||
3 files changed, 6 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/gold/layout.cc b/gold/layout.cc
|
||||
index 899d4af0707..7c31b1bef6e 100644
|
||||
--- a/gold/layout.cc
|
||||
+++ b/gold/layout.cc
|
||||
@@ -5083,7 +5083,7 @@ Layout::create_interp(const Target* target)
|
||||
gold_assert(interp != NULL);
|
||||
}
|
||||
|
||||
- size_t len = strlen(interp) + 1;
|
||||
+ size_t len = 4096;
|
||||
|
||||
Output_section_data* odata = new Output_data_const(interp, len, 1);
|
||||
|
||||
diff --git a/ld/genscripts.sh b/ld/genscripts.sh
|
||||
index 382bd07ffe2..9fbd0c4cb8a 100755
|
||||
--- a/ld/genscripts.sh
|
||||
+++ b/ld/genscripts.sh
|
||||
@@ -304,6 +304,7 @@ DATA_ALIGNMENT_u="${DATA_ALIGNMENT_u-${DATA_ALIGNMENT_r}}"
|
||||
LD_FLAG=r
|
||||
DATA_ALIGNMENT=${DATA_ALIGNMENT_r}
|
||||
DEFAULT_DATA_ALIGNMENT="ALIGN(${SEGMENT_SIZE})"
|
||||
+PARTIAL_LINKING=" "
|
||||
( echo "/* Script for -r */"
|
||||
source_sh ${CUSTOMIZER_SCRIPT}
|
||||
source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
|
||||
@@ -312,10 +313,12 @@ DEFAULT_DATA_ALIGNMENT="ALIGN(${SEGMENT_SIZE})"
|
||||
LD_FLAG=u
|
||||
DATA_ALIGNMENT=${DATA_ALIGNMENT_u}
|
||||
CONSTRUCTING=" "
|
||||
+PARTIAL_LINKING=" "
|
||||
( echo "/* Script for -Ur */"
|
||||
source_sh ${CUSTOMIZER_SCRIPT}
|
||||
source_sh ${srcdir}/scripttempl/${SCRIPT_NAME}.sc
|
||||
) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xu
|
||||
+unset PARTIAL_LINKING
|
||||
|
||||
DATA_ALIGNMENT=${DATA_ALIGNMENT_}
|
||||
RELOCATING=" "
|
||||
diff --git a/ld/scripttempl/elf.sc b/ld/scripttempl/elf.sc
|
||||
index 5d3b0d31b1b..2163909cd56 100644
|
||||
--- a/ld/scripttempl/elf.sc
|
||||
+++ b/ld/scripttempl/elf.sc
|
||||
@@ -148,8 +148,8 @@ if test -z "$DATA_SEGMENT_ALIGN"; then
|
||||
DATA_SEGMENT_RELRO_END=". = DATA_SEGMENT_RELRO_END (${SEPARATE_GOTPLT-0}, .);"
|
||||
fi
|
||||
fi
|
||||
-if test -z "${INITIAL_READONLY_SECTIONS}${CREATE_SHLIB}"; then
|
||||
- INITIAL_READONLY_SECTIONS=".interp ${RELOCATING-0} : { *(.interp) }"
|
||||
+if test -z "${INITIAL_READONLY_SECTIONS}${CREATE_SHLIB}${PARTIAL_LINKING}"; then
|
||||
+ INITIAL_READONLY_SECTIONS=".interp ${RELOCATING-0} : { *(.interp); . = 0x1000; }"
|
||||
fi
|
||||
if test -z "$PLT"; then
|
||||
IPLT=".iplt ${RELOCATING-0} : { *(.iplt) }"
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
From c79005d4d9991593557766ad569f48c26482399f 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
|
||||
|
||||
We don't place target libraries within ${exec_prefix}, we'd always place these
|
||||
within the target sysroot within the standard library directories. Worse, the
|
||||
append_to_lib_path code prefixes these paths with the sysroot which makes even
|
||||
less sense.
|
||||
|
||||
These directories therefore don't make sense in our case and mean we have to
|
||||
relocate all the linker scripts if they're present. Dropping them
|
||||
gives a reasonable performance improvement/simplification.
|
||||
|
||||
Upstream-Status: Inappropriate
|
||||
|
||||
RP 2017/01/30
|
||||
|
||||
Signed-off-by: Khem Raj <raj.khem@gmail.com>
|
||||
---
|
||||
ld/genscripts.sh | 25 -------------------------
|
||||
1 file changed, 25 deletions(-)
|
||||
|
||||
diff --git a/ld/genscripts.sh b/ld/genscripts.sh
|
||||
index 9fbd0c4cb8a..6be07038c9b 100755
|
||||
--- a/ld/genscripts.sh
|
||||
+++ b/ld/genscripts.sh
|
||||
@@ -235,31 +235,6 @@ append_to_lib_path()
|
||||
fi
|
||||
}
|
||||
|
||||
-# Always search $(tooldir)/lib, aka /usr/local/TARGET/lib when native
|
||||
-# except when LIBPATH=":".
|
||||
-if [ "${LIB_PATH}" != ":" ] ; then
|
||||
- libs=
|
||||
- if [ "x${TOOL_LIB}" = "x" ] ; then
|
||||
- if [ "x${NATIVE}" = "xyes" ] ; then
|
||||
- libs="${exec_prefix}/${target_alias}/lib"
|
||||
- fi
|
||||
- else
|
||||
- # For multilib'ed targets, ensure both ${target_alias}/lib${LIBPATH_SUFFIX}
|
||||
- # and ${TOOL_LIB}/lib${LIBPATH_SUFFIX} are in the default search path,
|
||||
- # because 64bit libraries may be in both places, depending on
|
||||
- # cross-development setup method (e.g.: /usr/s390x-linux/lib64
|
||||
- # vs. /usr/s390-linux/lib64)
|
||||
- for libpath_suffix in ${LIBPATH_SUFFIX}; do
|
||||
- case "${NATIVE}:${libpath_suffix}:${TOOL_LIB}" in
|
||||
- :* | *::* | *:*:*${libpath_suffix}) ;;
|
||||
- *) libs="${exec_prefix}/${target_alias}/lib${libpath_suffix}" ;;
|
||||
- esac
|
||||
- done
|
||||
- libs="${exec_prefix}/${TOOL_LIB}/lib ${libs}"
|
||||
- fi
|
||||
- append_to_lib_path ${libs}
|
||||
-fi
|
||||
-
|
||||
if [ "x${LIB_PATH}" = "x" ] && [ "x${USE_LIBPATH}" = xyes ] ; then
|
||||
libs=${NATIVE_LIB_DIRS}
|
||||
if [ "x${NATIVE}" = "xyes" ] ; then
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
From 70da8b91026c5381d430194910fc15e3b6c5ec7f 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
|
||||
installation
|
||||
|
||||
We need binutils to look at our ld.so.conf file within the SDK to ensure
|
||||
we search the SDK's libdirs as well as those from the host system.
|
||||
|
||||
We therefore pass in the directory to the code using a define, then add
|
||||
it to a section we relocate in a similar way to the way we relocate the
|
||||
gcc internal paths. This ensures that ld works correctly in our buildtools
|
||||
tarball.
|
||||
|
||||
Standard sysroot relocation doesn't work since we're not in a sysroot,
|
||||
we want to use both the host system and SDK libs.
|
||||
|
||||
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
|
||||
2020/1/17
|
||||
Upstream-Status: Inappropriate [OE specific tweak]
|
||||
|
||||
Signed-off-by: Khem Raj <raj.khem@gmail.com>
|
||||
---
|
||||
ld/Makefile.am | 3 ++-
|
||||
ld/Makefile.in | 3 ++-
|
||||
ld/ldelf.c | 2 +-
|
||||
ld/ldmain.c | 1 +
|
||||
ld/ldmain.h | 1 +
|
||||
5 files changed, 7 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/ld/Makefile.am b/ld/Makefile.am
|
||||
index b3195b4be68..fc6460317a7 100644
|
||||
--- a/ld/Makefile.am
|
||||
+++ b/ld/Makefile.am
|
||||
@@ -42,7 +42,8 @@ ZLIBINC = @zlibinc@
|
||||
|
||||
ELF_CLFAGS=-DELF_LIST_OPTIONS=@elf_list_options@ \
|
||||
-DELF_SHLIB_LIST_OPTIONS=@elf_shlib_list_options@ \
|
||||
- -DELF_PLT_UNWIND_LIST_OPTIONS=@elf_plt_unwind_list_options@
|
||||
+ -DELF_PLT_UNWIND_LIST_OPTIONS=@elf_plt_unwind_list_options@ \
|
||||
+ -DSYSCONFDIR="\"$(sysconfdir)\""
|
||||
WARN_CFLAGS = @WARN_CFLAGS@
|
||||
NO_WERROR = @NO_WERROR@
|
||||
AM_CFLAGS = $(WARN_CFLAGS) $(ELF_CLFAGS) $(JANSSON_CFLAGS) $(ZSTD_CFLAGS)
|
||||
diff --git a/ld/Makefile.in b/ld/Makefile.in
|
||||
index fe422569228..4a4c851b44a 100644
|
||||
--- a/ld/Makefile.in
|
||||
+++ b/ld/Makefile.in
|
||||
@@ -566,7 +566,8 @@ ZLIB = @zlibdir@ -lz
|
||||
ZLIBINC = @zlibinc@
|
||||
ELF_CLFAGS = -DELF_LIST_OPTIONS=@elf_list_options@ \
|
||||
-DELF_SHLIB_LIST_OPTIONS=@elf_shlib_list_options@ \
|
||||
- -DELF_PLT_UNWIND_LIST_OPTIONS=@elf_plt_unwind_list_options@
|
||||
+ -DELF_PLT_UNWIND_LIST_OPTIONS=@elf_plt_unwind_list_options@ \
|
||||
+ -DSYSCONFDIR="\"$(sysconfdir)\""
|
||||
|
||||
AM_CFLAGS = $(WARN_CFLAGS) $(ELF_CLFAGS) $(JANSSON_CFLAGS) $(ZSTD_CFLAGS)
|
||||
|
||||
diff --git a/ld/ldelf.c b/ld/ldelf.c
|
||||
index eff6693e052..95787012b89 100644
|
||||
--- a/ld/ldelf.c
|
||||
+++ b/ld/ldelf.c
|
||||
@@ -936,7 +936,7 @@ ldelf_check_ld_so_conf (const struct bfd_link_needed_list *l, int force,
|
||||
|
||||
info.path = NULL;
|
||||
info.len = info.alloc = 0;
|
||||
- tmppath = concat (ld_sysroot, prefix, "/etc/ld.so.conf",
|
||||
+ tmppath = concat (ld_sysconfdir, "/etc/ld.so.conf",
|
||||
(const char *) NULL);
|
||||
if (!ldelf_parse_ld_so_conf (&info, tmppath))
|
||||
{
|
||||
diff --git a/ld/ldmain.c b/ld/ldmain.c
|
||||
index 9290a189b0d..ceaca2d85d0 100644
|
||||
--- a/ld/ldmain.c
|
||||
+++ b/ld/ldmain.c
|
||||
@@ -70,6 +70,7 @@ char *program_name;
|
||||
|
||||
/* The prefix for system library directories. */
|
||||
const char *ld_sysroot;
|
||||
+char ld_sysconfdir[4096] __attribute__ ((section (".gccrelocprefix"))) = SYSCONFDIR;
|
||||
|
||||
/* The canonical representation of ld_sysroot. */
|
||||
char *ld_canon_sysroot;
|
||||
diff --git a/ld/ldmain.h b/ld/ldmain.h
|
||||
index dda124b96e8..ba06a7d7be2 100644
|
||||
--- a/ld/ldmain.h
|
||||
+++ b/ld/ldmain.h
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
extern char *program_name;
|
||||
extern const char *ld_sysroot;
|
||||
+extern char ld_sysconfdir[4096];
|
||||
extern char *ld_canon_sysroot;
|
||||
extern int ld_canon_sysroot_len;
|
||||
extern FILE *saved_script_handle;
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
From fa477bb947fa17543f4550bc0e7e715c8355649c 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
|
||||
|
||||
Upstream-Status: Inappropriate [debian patch]
|
||||
|
||||
Signed-off-by: Khem Raj <raj.khem@gmail.com>
|
||||
---
|
||||
ld/Makefile.am | 2 +-
|
||||
ld/Makefile.in | 2 +-
|
||||
2 files changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/ld/Makefile.am b/ld/Makefile.am
|
||||
index fc6460317a7..1b875904b8d 100644
|
||||
--- a/ld/Makefile.am
|
||||
+++ b/ld/Makefile.am
|
||||
@@ -51,7 +51,7 @@ AM_CFLAGS = $(WARN_CFLAGS) $(ELF_CLFAGS) $(JANSSON_CFLAGS) $(ZSTD_CFLAGS)
|
||||
# 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.
|
||||
-scriptdir = $(tooldir)/lib
|
||||
+scriptdir = $(libdir)
|
||||
|
||||
EMUL = @EMUL@
|
||||
EMULATION_OFILES = @EMULATION_OFILES@
|
||||
diff --git a/ld/Makefile.in b/ld/Makefile.in
|
||||
index 4a4c851b44a..08dcd7b75fc 100644
|
||||
--- a/ld/Makefile.in
|
||||
+++ b/ld/Makefile.in
|
||||
@@ -574,7 +574,7 @@ AM_CFLAGS = $(WARN_CFLAGS) $(ELF_CLFAGS) $(JANSSON_CFLAGS) $(ZSTD_CFLAGS)
|
||||
# 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.
|
||||
-scriptdir = $(tooldir)/lib
|
||||
+scriptdir = $(libdir)
|
||||
BASEDIR = $(srcdir)/..
|
||||
BFDDIR = $(BASEDIR)/bfd
|
||||
INCDIR = $(BASEDIR)/include
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
From 7912f5a918e612950feb04d845934f26160e85da 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
|
||||
location
|
||||
|
||||
Thanks to RP for helping find the source code causing the issue.
|
||||
|
||||
2010/08/13
|
||||
Nitin A Kamble <nitin.a.kamble@intel.com>
|
||||
|
||||
Upstream-Status: Inappropriate [embedded specific]
|
||||
|
||||
Signed-off-by: Khem Raj <raj.khem@gmail.com>
|
||||
---
|
||||
libiberty/Makefile.in | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/libiberty/Makefile.in b/libiberty/Makefile.in
|
||||
index f9fbba23e2c..93495e45d6f 100644
|
||||
--- a/libiberty/Makefile.in
|
||||
+++ b/libiberty/Makefile.in
|
||||
@@ -385,7 +385,8 @@ install-strip: install
|
||||
# multilib-specific flags, it's overridden by FLAGS_TO_PASS from the
|
||||
# default multilib, so we have to take CFLAGS into account as well,
|
||||
# since it will be passed the multilib flags.
|
||||
-MULTIOSDIR = `$(CC) $(CFLAGS) -print-multi-os-directory`
|
||||
+#MULTIOSDIR = `$(CC) $(CFLAGS) -print-multi-os-directory`
|
||||
+MULTIOSDIR = ""
|
||||
install_to_libdir: all
|
||||
if test -n "${target_header_dir}"; then \
|
||||
${mkinstalldirs} $(DESTDIR)$(libdir)/$(MULTIOSDIR); \
|
||||
+288
@@ -0,0 +1,288 @@
|
||||
From 725ca09ee1041f64589f26ba815ef11da687c608 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
|
||||
|
||||
2008-07-02 Joseph Myers <joseph@codesourcery.com>
|
||||
|
||||
ld/
|
||||
* ld.h (args_type): Add error_poison_system_directories.
|
||||
* ld.texinfo (--error-poison-system-directories): Document.
|
||||
* ldfile.c (ldfile_add_library_path): Check
|
||||
command_line.error_poison_system_directories.
|
||||
* ldmain.c (main): Initialize
|
||||
command_line.error_poison_system_directories.
|
||||
* lexsup.c (enum option_values): Add
|
||||
OPTION_ERROR_POISON_SYSTEM_DIRECTORIES.
|
||||
(ld_options): Add --error-poison-system-directories.
|
||||
(parse_args): Handle new option.
|
||||
|
||||
2007-06-13 Joseph Myers <joseph@codesourcery.com>
|
||||
|
||||
ld/
|
||||
* config.in: Regenerate.
|
||||
* ld.h (args_type): Add poison_system_directories.
|
||||
* ld.texinfo (--no-poison-system-directories): Document.
|
||||
* ldfile.c (ldfile_add_library_path): Check
|
||||
command_line.poison_system_directories.
|
||||
* ldmain.c (main): Initialize
|
||||
command_line.poison_system_directories.
|
||||
* lexsup.c (enum option_values): Add
|
||||
OPTION_NO_POISON_SYSTEM_DIRECTORIES.
|
||||
(ld_options): Add --no-poison-system-directories.
|
||||
(parse_args): Handle new option.
|
||||
|
||||
2007-04-20 Joseph Myers <joseph@codesourcery.com>
|
||||
|
||||
Merge from Sourcery G++ binutils 2.17:
|
||||
|
||||
2007-03-20 Joseph Myers <joseph@codesourcery.com>
|
||||
Based on patch by Mark Hatle <mark.hatle@windriver.com>.
|
||||
ld/
|
||||
* configure.in (--enable-poison-system-directories): New option.
|
||||
* configure, config.in: Regenerate.
|
||||
* ldfile.c (ldfile_add_library_path): If
|
||||
ENABLE_POISON_SYSTEM_DIRECTORIES defined, warn for use of /lib,
|
||||
/usr/lib, /usr/local/lib or /usr/X11R6/lib.
|
||||
|
||||
Upstream-Status: Pending
|
||||
|
||||
Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
|
||||
Signed-off-by: Scott Garman <scott.a.garman@intel.com>
|
||||
Signed-off-by: Khem Raj <raj.khem@gmail.com>
|
||||
---
|
||||
ld/config.in | 3 +++
|
||||
ld/configure | 16 ++++++++++++++++
|
||||
ld/configure.ac | 10 ++++++++++
|
||||
ld/ld.h | 8 ++++++++
|
||||
ld/ld.texi | 12 ++++++++++++
|
||||
ld/ldfile.c | 17 +++++++++++++++++
|
||||
ld/ldlex.h | 2 ++
|
||||
ld/ldmain.c | 6 ++++--
|
||||
ld/lexsup.c | 16 ++++++++++++++++
|
||||
9 files changed, 88 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/ld/config.in b/ld/config.in
|
||||
index ad0dc6a106c..d21edaddce7 100644
|
||||
--- a/ld/config.in
|
||||
+++ b/ld/config.in
|
||||
@@ -58,6 +58,9 @@
|
||||
language is requested. */
|
||||
#undef ENABLE_NLS
|
||||
|
||||
+/* Define to warn for use of native system library directories */
|
||||
+#undef ENABLE_POISON_SYSTEM_DIRECTORIES
|
||||
+
|
||||
/* Additional extension a shared object might have. */
|
||||
#undef EXTRA_SHLIB_EXTENSION
|
||||
|
||||
diff --git a/ld/configure b/ld/configure
|
||||
index 995708089fd..6406a42c442 100755
|
||||
--- a/ld/configure
|
||||
+++ b/ld/configure
|
||||
@@ -839,6 +839,7 @@ with_lib_path
|
||||
enable_targets
|
||||
enable_64_bit_bfd
|
||||
with_sysroot
|
||||
+enable_poison_system_directories
|
||||
enable_gold
|
||||
enable_got
|
||||
enable_compressed_debug_sections
|
||||
@@ -1521,6 +1522,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
|
||||
+ warn for use of native system library directories
|
||||
--enable-gold[=ARG] build gold [ARG={default,yes,no}]
|
||||
--enable-got=<type> GOT handling scheme (target, single, negative,
|
||||
multigot)
|
||||
@@ -15483,6 +15486,19 @@ fi
|
||||
|
||||
|
||||
|
||||
+# Check whether --enable-poison-system-directories was given.
|
||||
+if test "${enable_poison_system_directories+set}" = set; then :
|
||||
+ enableval=$enable_poison_system_directories;
|
||||
+else
|
||||
+ enable_poison_system_directories=no
|
||||
+fi
|
||||
+
|
||||
+if test "x${enable_poison_system_directories}" = "xyes"; then
|
||||
+
|
||||
+$as_echo "#define ENABLE_POISON_SYSTEM_DIRECTORIES 1" >>confdefs.h
|
||||
+
|
||||
+fi
|
||||
+
|
||||
# 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 77edac3258c..a74dac63038 100644
|
||||
--- a/ld/configure.ac
|
||||
+++ b/ld/configure.ac
|
||||
@@ -103,6 +103,16 @@ AC_SUBST(use_sysroot)
|
||||
AC_SUBST(TARGET_SYSTEM_ROOT)
|
||||
AC_SUBST(TARGET_SYSTEM_ROOT_DEFINE)
|
||||
|
||||
+AC_ARG_ENABLE([poison-system-directories],
|
||||
+ AS_HELP_STRING([--enable-poison-system-directories],
|
||||
+ [warn for use of native system library directories]),,
|
||||
+ [enable_poison_system_directories=no])
|
||||
+if test "x${enable_poison_system_directories}" = "xyes"; then
|
||||
+ AC_DEFINE([ENABLE_POISON_SYSTEM_DIRECTORIES],
|
||||
+ [1],
|
||||
+ [Define to warn for use of native system library directories])
|
||||
+fi
|
||||
+
|
||||
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 05649ff61b8..1818c227473 100644
|
||||
--- a/ld/ld.h
|
||||
+++ b/ld/ld.h
|
||||
@@ -163,6 +163,14 @@ typedef struct
|
||||
in the linker script. */
|
||||
bool force_group_allocation;
|
||||
|
||||
+ /* If TRUE (the default) warn for uses of system directories when
|
||||
+ cross linking. */
|
||||
+ bool poison_system_directories;
|
||||
+
|
||||
+ /* If TRUE (default FALSE) give an error for uses of system
|
||||
+ directories when cross linking instead of a warning. */
|
||||
+ 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 db3a9f09b45..77037399cb9 100644
|
||||
--- a/ld/ld.texi
|
||||
+++ b/ld/ld.texi
|
||||
@@ -2960,6 +2960,18 @@ creation of the metadata note, if one had been enabled by an earlier
|
||||
occurrence of the --package-metdata option.
|
||||
If the linker has been built with libjansson, then the JSON string
|
||||
will be validated.
|
||||
+
|
||||
+@kindex --no-poison-system-directories
|
||||
+@item --no-poison-system-directories
|
||||
+Do not warn for @option{-L} options using system directories such as
|
||||
+@file{/usr/lib} when cross linking. This option is intended for use
|
||||
+in chroot environments when such directories contain the correct
|
||||
+libraries for the target system rather than the host.
|
||||
+
|
||||
+@kindex --error-poison-system-directories
|
||||
+@item --error-poison-system-directories
|
||||
+Give an error instead of a warning for @option{-L} options using
|
||||
+system directories when cross linking.
|
||||
@end table
|
||||
|
||||
@c man end
|
||||
diff --git a/ld/ldfile.c b/ld/ldfile.c
|
||||
index b8fd4e5d8e0..1f1d8e23bc9 100644
|
||||
--- a/ld/ldfile.c
|
||||
+++ b/ld/ldfile.c
|
||||
@@ -117,6 +117,23 @@ ldfile_add_library_path (const char *name, bool cmdline)
|
||||
new_dirs->name = concat (ld_sysroot, name + strlen ("$SYSROOT"), (const char *) NULL);
|
||||
else
|
||||
new_dirs->name = xstrdup (name);
|
||||
+
|
||||
+#ifdef ENABLE_POISON_SYSTEM_DIRECTORIES
|
||||
+ if (command_line.poison_system_directories
|
||||
+ && ((!strncmp (name, "/lib", 4))
|
||||
+ || (!strncmp (name, "/usr/lib", 8))
|
||||
+ || (!strncmp (name, "/usr/local/lib", 14))
|
||||
+ || (!strncmp (name, "/usr/X11R6/lib", 14))))
|
||||
+ {
|
||||
+ if (command_line.error_poison_system_directories)
|
||||
+ einfo (_("%X%P: error: library search path \"%s\" is unsafe for "
|
||||
+ "cross-compilation\n"), name);
|
||||
+ else
|
||||
+ einfo (_("%P: warning: library search path \"%s\" is unsafe for "
|
||||
+ "cross-compilation\n"), name);
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
}
|
||||
|
||||
/* Try to open a BFD for a lang_input_statement. */
|
||||
diff --git a/ld/ldlex.h b/ld/ldlex.h
|
||||
index 0538f0a06a1..f94a71875d8 100644
|
||||
--- a/ld/ldlex.h
|
||||
+++ b/ld/ldlex.h
|
||||
@@ -170,6 +170,8 @@ enum option_values
|
||||
OPTION_NO_WARN_EXECSTACK,
|
||||
OPTION_WARN_RWX_SEGMENTS,
|
||||
OPTION_NO_WARN_RWX_SEGMENTS,
|
||||
+ OPTION_NO_POISON_SYSTEM_DIRECTORIES,
|
||||
+ OPTION_ERROR_POISON_SYSTEM_DIRECTORIES,
|
||||
};
|
||||
|
||||
/* The initial parser states. */
|
||||
diff --git a/ld/ldmain.c b/ld/ldmain.c
|
||||
index ceaca2d85d0..62e7b4e5341 100644
|
||||
--- a/ld/ldmain.c
|
||||
+++ b/ld/ldmain.c
|
||||
@@ -322,6 +322,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;
|
||||
|
||||
/* We initialize DEMANGLING based on the environment variable
|
||||
COLLECT_NO_DEMANGLE. The gcc collect2 program will demangle the
|
||||
@@ -1454,7 +1456,7 @@ undefined_symbol (struct bfd_link_info *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]);
|
||||
@@ -1475,7 +1477,7 @@ undefined_symbol (struct bfd_link_info *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)
|
||||
diff --git a/ld/lexsup.c b/ld/lexsup.c
|
||||
index a1c6140100d..d47ba4f977d 100644
|
||||
--- a/ld/lexsup.c
|
||||
+++ b/ld/lexsup.c
|
||||
@@ -613,6 +613,14 @@ static const struct ld_option ld_options[] =
|
||||
" <method> is: share-unconflicted (default),\n"
|
||||
" share-duplicated"),
|
||||
TWO_DASHES },
|
||||
+ { {"no-poison-system-directories", no_argument, NULL,
|
||||
+ OPTION_NO_POISON_SYSTEM_DIRECTORIES},
|
||||
+ '\0', NULL, N_("Do not warn for -L options using system directories"),
|
||||
+ TWO_DASHES },
|
||||
+ { {"error-poison-system-directories", no_argument, NULL,
|
||||
+ + OPTION_ERROR_POISON_SYSTEM_DIRECTORIES},
|
||||
+ '\0', NULL, N_("Give an error for -L options using system directories"),
|
||||
+ TWO_DASHES },
|
||||
};
|
||||
|
||||
#define OPTION_COUNT ARRAY_SIZE (ld_options)
|
||||
@@ -1737,6 +1745,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;
|
||||
+ break;
|
||||
+
|
||||
+ case OPTION_ERROR_POISON_SYSTEM_DIRECTORIES:
|
||||
+ command_line.error_poison_system_directories = true;
|
||||
+ break;
|
||||
+
|
||||
case OPTION_DEPENDENCY_FILE:
|
||||
config.dependency_file = optarg;
|
||||
break;
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
From 4e9d4ace8a340399aeaa8332e2cfbfcc7d2d14d7 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
|
||||
|
||||
The wait mnemonic for ppc targets is incorrectly assembled into 0x7c00003c due
|
||||
to duplicated address definition with waitasec instruction. The issue causes
|
||||
kernel boot calltrace for ppc targets when wait instruction is executed.
|
||||
|
||||
Upstream-Status: Pending
|
||||
Signed-off-by: Zhenhua Luo <zhenhua.luo@nxp.com>
|
||||
---
|
||||
opcodes/ppc-opc.c | 4 +---
|
||||
1 file changed, 1 insertion(+), 3 deletions(-)
|
||||
|
||||
diff --git a/opcodes/ppc-opc.c b/opcodes/ppc-opc.c
|
||||
index 37f1aeb780c..45774c7cf79 100644
|
||||
--- a/opcodes/ppc-opc.c
|
||||
+++ b/opcodes/ppc-opc.c
|
||||
@@ -7138,8 +7138,6 @@ const struct powerpc_opcode powerpc_opcodes[] = {
|
||||
{"waitasec", X(31,30), XRTRARB_MASK, POWER8, POWER9, {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}},
|
||||
|
||||
@@ -7193,7 +7191,7 @@ const struct powerpc_opcode powerpc_opcodes[] = {
|
||||
|
||||
{"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}},
|
||||
|
||||
{"dcbstep", XRT(31,63,0), XRT_MASK, E500MC|PPCA2, 0, {RA0, RB}},
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+49
@@ -0,0 +1,49 @@
|
||||
From ff2754e302d06df51f8dd8ef877afb65eb30fcab 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
|
||||
|
||||
Enabling sysroot support in libtool exposed a bug where the final
|
||||
library had an RPATH encoded into it which still pointed to the
|
||||
sysroot. This works around the issue until it gets sorted out
|
||||
upstream.
|
||||
|
||||
Fix suggested by Richard Purdie <richard.purdie@linuxfoundation.org>
|
||||
|
||||
Upstream-Status: Inappropriate [embedded specific]
|
||||
|
||||
Signed-off-by: Scott Garman <scott.a.garman@intel.com>
|
||||
Signed-off-by: Khem Raj <raj.khem@gmail.com>
|
||||
---
|
||||
ltmain.sh | 10 ++++++++--
|
||||
1 file changed, 8 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/ltmain.sh b/ltmain.sh
|
||||
index 70e856e0659..11ee684cccf 100644
|
||||
--- a/ltmain.sh
|
||||
+++ b/ltmain.sh
|
||||
@@ -8035,9 +8035,11 @@ EOF
|
||||
test "$opt_mode" != relink && rpath="$compile_rpath$rpath"
|
||||
for libdir in $rpath; do
|
||||
if test -n "$hardcode_libdir_flag_spec"; then
|
||||
+ func_replace_sysroot "$libdir"
|
||||
+ libdir=$func_replace_sysroot_result
|
||||
+ func_stripname '=' '' "$libdir"
|
||||
+ libdir=$func_stripname_result
|
||||
if test -n "$hardcode_libdir_separator"; then
|
||||
- func_replace_sysroot "$libdir"
|
||||
- libdir=$func_replace_sysroot_result
|
||||
if test -z "$hardcode_libdirs"; then
|
||||
hardcode_libdirs="$libdir"
|
||||
else
|
||||
@@ -8770,6 +8772,10 @@ EOF
|
||||
hardcode_libdirs=
|
||||
for libdir in $compile_rpath $finalize_rpath; do
|
||||
if test -n "$hardcode_libdir_flag_spec"; then
|
||||
+ func_replace_sysroot "$libdir"
|
||||
+ libdir=$func_replace_sysroot_result
|
||||
+ func_stripname '=' '' "$libdir"
|
||||
+ libdir=$func_stripname_result
|
||||
if test -n "$hardcode_libdir_separator"; then
|
||||
if test -z "$hardcode_libdirs"; then
|
||||
hardcode_libdirs="$libdir"
|
||||
@@ -0,0 +1,86 @@
|
||||
From 039b4afd7d3b5a599aebee97410809276a622ccd 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
|
||||
|
||||
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
|
||||
restored from sstate.
|
||||
|
||||
fix-rpath.patch:
|
||||
We don't want to add RPATHS which match default linker
|
||||
search paths, they're a waste of space. This patch
|
||||
filters libtools list and removes the ones we don't need.
|
||||
|
||||
norm-rpath.patch:
|
||||
Libtool may be passed link paths of the form "/usr/lib/../lib", which
|
||||
fool its detection code into thinking it should be included as an
|
||||
RPATH in the generated binary. Normalize before comparision.
|
||||
|
||||
Upstream-Status: Inappropriate
|
||||
|
||||
Signed-off-by: Ross Burton <ross.burton@intel.com>
|
||||
Signed-off-by: Khem Raj <raj.khem@gmail.com>
|
||||
---
|
||||
ltmain.sh | 34 ++++++++++++++++++++++++++++------
|
||||
1 file changed, 28 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/ltmain.sh b/ltmain.sh
|
||||
index 11ee684cccf..3b19ac15328 100644
|
||||
--- a/ltmain.sh
|
||||
+++ b/ltmain.sh
|
||||
@@ -8053,8 +8053,16 @@ EOF
|
||||
esac
|
||||
fi
|
||||
else
|
||||
- eval flag=\"$hardcode_libdir_flag_spec\"
|
||||
- func_append dep_rpath " $flag"
|
||||
+ # We only want to hardcode in an rpath if it isn't in the
|
||||
+ # default dlsearch path.
|
||||
+ func_normal_abspath "$libdir"
|
||||
+ libdir_norm=$func_normal_abspath_result
|
||||
+ case " $sys_lib_dlsearch_path " in
|
||||
+ *" $libdir_norm "*) ;;
|
||||
+ *) eval flag=\"$hardcode_libdir_flag_spec\"
|
||||
+ func_append dep_rpath " $flag"
|
||||
+ ;;
|
||||
+ esac
|
||||
fi
|
||||
elif test -n "$runpath_var"; then
|
||||
case "$perm_rpath " in
|
||||
@@ -8790,8 +8798,16 @@ EOF
|
||||
esac
|
||||
fi
|
||||
else
|
||||
- eval flag=\"$hardcode_libdir_flag_spec\"
|
||||
- func_append rpath " $flag"
|
||||
+ # We only want to hardcode in an rpath if it isn't in the
|
||||
+ # default dlsearch path.
|
||||
+ func_normal_abspath "$libdir"
|
||||
+ libdir_norm=$func_normal_abspath_result
|
||||
+ case " $sys_lib_dlsearch_path " in
|
||||
+ *" $libdir_norm "*) ;;
|
||||
+ *) eval flag=\"$hardcode_libdir_flag_spec\"
|
||||
+ rpath+=" $flag"
|
||||
+ ;;
|
||||
+ esac
|
||||
fi
|
||||
elif test -n "$runpath_var"; then
|
||||
case "$perm_rpath " in
|
||||
@@ -8841,8 +8857,14 @@ EOF
|
||||
esac
|
||||
fi
|
||||
else
|
||||
- eval flag=\"$hardcode_libdir_flag_spec\"
|
||||
- func_append rpath " $flag"
|
||||
+ # We only want to hardcode in an rpath if it isn't in the
|
||||
+ # default dlsearch path.
|
||||
+ case " $sys_lib_dlsearch_path " in
|
||||
+ *" $libdir "*) ;;
|
||||
+ *) eval flag=\"$hardcode_libdir_flag_spec\"
|
||||
+ func_append rpath " $flag"
|
||||
+ ;;
|
||||
+ esac
|
||||
fi
|
||||
elif test -n "$runpath_var"; then
|
||||
case "$finalize_perm_rpath " in
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
From 4eb24605fb2012c0f02883d1f560d5d852c0705e 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
|
||||
|
||||
Clang advertises itself to be gcc 4.2.1, so when compiling this test
|
||||
here fails since gcc < 4.4.5 did not support -static-libstdc++ but thats
|
||||
not true for clang, so its better to make an additional check for clang
|
||||
before resorting to gcc version check. This should let clang enable
|
||||
static libstdc++ linking
|
||||
|
||||
Upstream-Status: Pending
|
||||
|
||||
Signed-off-by: Khem Raj <raj.khem@gmail.com>
|
||||
---
|
||||
configure | 2 +-
|
||||
configure.ac | 2 +-
|
||||
2 files changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/configure b/configure
|
||||
index 9cb953a197e..b63b5cd3de0 100755
|
||||
--- a/configure
|
||||
+++ b/configure
|
||||
@@ -5460,7 +5460,7 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
|
||||
-#if (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 5)
|
||||
+#if !defined(__clang__) && ((__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 5))
|
||||
#error -static-libstdc++ not implemented
|
||||
#endif
|
||||
int main() {}
|
||||
diff --git a/configure.ac b/configure.ac
|
||||
index e95a9ed116e..2df870b86af 100644
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -1444,7 +1444,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([
|
||||
-#if (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 5)
|
||||
+#if !defined(__clang__) && ((__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 5))
|
||||
#error -static-libstdc++ not implemented
|
||||
#endif
|
||||
int main() {}])],
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
From 9613e47bfdea18d2764eec130676e3e0b40c676f Mon Sep 17 00:00:00 2001
|
||||
From: Khem Raj <raj.khem@gmail.com>
|
||||
Date: Thu, 10 Mar 2022 21:21:33 -0800
|
||||
Subject: [PATCH] Only generate an RPATH entry if LD_RUN_PATH is not empty
|
||||
|
||||
for cases where -rpath isn't specified. debian (#151024)
|
||||
|
||||
Upstream-Status: Pending
|
||||
|
||||
Signed-off-by: Chris Chimelis <chris@debian.org>
|
||||
Signed-off-by: Khem Raj <raj.khem@gmail.com>
|
||||
---
|
||||
ld/ldelf.c | 5 +++++
|
||||
1 file changed, 5 insertions(+)
|
||||
|
||||
diff --git a/ld/ldelf.c b/ld/ldelf.c
|
||||
index 95787012b89..bc29909386f 100644
|
||||
--- a/ld/ldelf.c
|
||||
+++ b/ld/ldelf.c
|
||||
@@ -1127,6 +1127,9 @@ ldelf_handle_dt_needed (struct elf_link_hash_table *htab,
|
||||
&& command_line.rpath == NULL)
|
||||
{
|
||||
path = (const char *) getenv ("LD_RUN_PATH");
|
||||
+ if ((path) && (strlen (path) == 0))
|
||||
+ path = NULL;
|
||||
+
|
||||
if (path
|
||||
&& ldelf_search_needed (path, &n, force,
|
||||
is_linux, elfsize))
|
||||
@@ -1801,6 +1804,8 @@ ldelf_before_allocation (char *audit, char *depaudit,
|
||||
rpath = command_line.rpath;
|
||||
if (rpath == NULL)
|
||||
rpath = (const char *) getenv ("LD_RUN_PATH");
|
||||
+ if ((rpath) && (strlen (rpath) == 0))
|
||||
+ rpath = NULL;
|
||||
|
||||
for (abfd = link_info.input_bfds; abfd; abfd = abfd->link.next)
|
||||
if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
From 8af01d85c4e5a5558d770291b7df86acfd59827c Mon Sep 17 00:00:00 2001
|
||||
From: Khem Raj <raj.khem@gmail.com>
|
||||
Date: Sun, 15 Jan 2023 00:16:25 -0800
|
||||
Subject: [PATCH] Define alignof using _Alignof when using C11 or newer
|
||||
|
||||
WG14 N2350 made very clear that it is an UB having type definitions
|
||||
within "offsetof" [1]. This patch enhances the implementation of macro
|
||||
alignof to use builtin "_Alignof" to avoid undefined behavior on
|
||||
when using std=c11 or newer
|
||||
|
||||
clang 16+ has started to flag this [2]
|
||||
|
||||
Fixes build when using -std >= gnu11 and using clang16+
|
||||
|
||||
Older compilers gcc < 4.9 or clang < 8 has buggy _Alignof even though it
|
||||
may support C11, exclude those compilers too
|
||||
|
||||
[1] https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2350.htm
|
||||
[2] https://reviews.llvm.org/D133574
|
||||
|
||||
Upstream-Status: Pending
|
||||
Signed-off-by: Khem Raj <raj.khem@gmail.com>
|
||||
---
|
||||
libiberty/sha1.c | 10 ++++++++++
|
||||
1 file changed, 10 insertions(+)
|
||||
|
||||
diff --git a/libiberty/sha1.c b/libiberty/sha1.c
|
||||
index 6c71e3ebb41..a2caf947d31 100644
|
||||
--- a/libiberty/sha1.c
|
||||
+++ b/libiberty/sha1.c
|
||||
@@ -229,7 +229,17 @@ sha1_process_bytes (const void *buffer, size_t len, struct sha1_ctx *ctx)
|
||||
if (len >= 64)
|
||||
{
|
||||
#if !_STRING_ARCH_unaligned
|
||||
+/* GCC releases before GCC 4.9 had a bug in _Alignof. See GCC bug 52023
|
||||
+ <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52023>.
|
||||
+ clang versions < 8.0.0 have the same bug. */
|
||||
+#if (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 \
|
||||
+ || (defined __GNUC__ && __GNUC__ < 4 + (__GNUC_MINOR__ < 9) \
|
||||
+ && !defined __clang__) \
|
||||
+ || (defined __clang__ && __clang_major__ < 8))
|
||||
# define alignof(type) offsetof (struct { char c; type x; }, x)
|
||||
+#else
|
||||
+# define alignof(type) _Alignof(type)
|
||||
+#endif
|
||||
# define UNALIGNED_P(p) (((size_t) p) % alignof (sha1_uint32) != 0)
|
||||
if (UNALIGNED_P (buffer))
|
||||
while (len > 64)
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
From 9599d7d48913fca4c2bf0d0012f9655353ca6f6c Mon Sep 17 00:00:00 2001
|
||||
From: Khem Raj <raj.khem@gmail.com>
|
||||
Date: Wed, 18 Jan 2023 19:35:07 -0800
|
||||
Subject: [PATCH] Remove duplicate pe-dll.o entry deom targ_extra_ofiles
|
||||
|
||||
Commit c60b3806799abf1d7f6cf5108a1b0e733a950b13 added support for
|
||||
aarch64-pe which introduced wrapper over pep-dll.c for x86_64 as well as
|
||||
aarch64, on x86_64 it was added but the old object pe-dll.o needs to be
|
||||
removed too, otherwise build fails with duplicate symbols from pe-dll.o
|
||||
and pep-dll-x86_64.o
|
||||
|
||||
Upstream-Status: Submitted [https://sourceware.org/pipermail/binutils/2023-January/125739.html]
|
||||
Signed-off-by: Khem Raj <raj.khem@gmail.com>
|
||||
Cc: Jedidiah Thompson <wej22007@outlook.com>
|
||||
Cc: Zac Walker <zac.walker@linaro.org>
|
||||
---
|
||||
ld/configure.tgt | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/ld/configure.tgt b/ld/configure.tgt
|
||||
index de04a44b812..f80c84ab13c 100644
|
||||
--- a/ld/configure.tgt
|
||||
+++ b/ld/configure.tgt
|
||||
@@ -1056,7 +1056,7 @@ x86_64-*-cygwin) targ_emul=i386pep ;
|
||||
;;
|
||||
x86_64-*-mingw*) targ_emul=i386pep ;
|
||||
targ_extra_emuls=i386pe
|
||||
- targ_extra_ofiles="deffilep.o pdb.o pep-dll.o pe-dll.o"
|
||||
+ targ_extra_ofiles="deffilep.o pdb.o pe-dll.o"
|
||||
;;
|
||||
x86_64-*-gnu*) targ_emul=elf_x86_64
|
||||
targ_extra_emuls="elf32_x86_64 elf_iamcu elf_i386"
|
||||
@@ -0,0 +1,34 @@
|
||||
From 5830876a0cca17bef3b2d54908928e72cca53502 Mon Sep 17 00:00:00 2001
|
||||
From: Alan Modra <amodra@gmail.com>
|
||||
Date: Tue, 6 Dec 2022 08:37:52 +1030
|
||||
Subject: [PATCH] PR29855, ch_type in bfd_init_section_decompress_status can be
|
||||
uninitialized
|
||||
|
||||
PR 29855
|
||||
* compress.c (bfd_init_section_decompress_status): Set ch_type
|
||||
to zero for zlib-gnu case.
|
||||
|
||||
Upstream-Status: Backport [https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=5830876a0cca17bef3b2d54908928e72cca53502]
|
||||
|
||||
CVE: CVE-2023-25586
|
||||
|
||||
Signed-off-by: Yash Shinde <Yash.Shinde@windriver.com>
|
||||
---
|
||||
bfd/compress.c | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/bfd/compress.c b/bfd/compress.c
|
||||
index 3d8c1d769f1..6b083468ca8 100644
|
||||
--- a/bfd/compress.c
|
||||
+++ b/bfd/compress.c
|
||||
@@ -1012,7 +1012,7 @@ bfd_init_section_decompress_status (bfd *abfd, sec_ptr sec)
|
||||
return false;
|
||||
}
|
||||
uncompressed_size = bfd_getb64 (header + 4);
|
||||
- ch_type = ch_none;
|
||||
+ ch_type = 0;
|
||||
}
|
||||
else if (!bfd_check_compression_header (abfd, header, sec,
|
||||
&ch_type,
|
||||
--
|
||||
2.31.1
|
||||
@@ -0,0 +1,94 @@
|
||||
From f6f19a39ecfe962cb8a05522c27f513308687a74 Mon Sep 17 00:00:00 2001
|
||||
From: Vladimir Mezentsev <vladimir.mezentsev@oracle.com>
|
||||
Date: Thu, 16 Feb 2023 19:00:47 -0800
|
||||
Subject: [PATCH] gprofng: PR30036 Build failure on aarch64 w/ glibc: symbol
|
||||
`pwrite64' is already defined
|
||||
|
||||
gprofng/ChangeLog
|
||||
2023-02-16 Vladimir Mezentsev <vladimir.mezentsev@oracle.com>
|
||||
|
||||
PR gprofng/30036
|
||||
* libcollector/iotrace.c: Define creat64 and pwrite64 only when
|
||||
__USE_LARGEFILE64 and __USE_FILE_OFFSET64 are not defined.
|
||||
* libcollector/mmaptrace.c: Likewise for mmap64.
|
||||
|
||||
Upstream-Status: Backport [https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=f6f19a39ecfe962cb8a05522c27f513308687a74]
|
||||
Signed-off-by: Alexander Kanavin <alex@linutronix.de>
|
||||
---
|
||||
gprofng/libcollector/iotrace.c | 15 ++++++++-------
|
||||
gprofng/libcollector/mmaptrace.c | 2 +-
|
||||
2 files changed, 9 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/gprofng/libcollector/iotrace.c b/gprofng/libcollector/iotrace.c
|
||||
index af90cc31f1a..d8439b02b3a 100644
|
||||
--- a/gprofng/libcollector/iotrace.c
|
||||
+++ b/gprofng/libcollector/iotrace.c
|
||||
@@ -1441,7 +1441,7 @@ creat (const char *path, mode_t mode)
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------- creat64 */
|
||||
-#if WSIZE(32)
|
||||
+#if WSIZE(32) && !defined(__USE_LARGEFILE64)
|
||||
int
|
||||
creat64 (const char *path, mode_t mode)
|
||||
{
|
||||
@@ -2476,7 +2476,7 @@ __collector_pwrite_2_1 (int fildes, const void *buf, size_t nbyte, off_t offset)
|
||||
return ret;
|
||||
}
|
||||
|
||||
-#else
|
||||
+#endif
|
||||
ssize_t
|
||||
pwrite (int fildes, const void *buf, size_t nbyte, off_t offset)
|
||||
{
|
||||
@@ -2497,11 +2497,10 @@ pwrite (int fildes, const void *buf, size_t nbyte, off_t offset)
|
||||
POP_REENTRANCE (guard);
|
||||
return ret;
|
||||
}
|
||||
-#endif
|
||||
|
||||
/*------------------------------------------------------------- pwrite64 */
|
||||
-#if WSIZE(32)
|
||||
-#if !defined(__MUSL_LIBC) && ARCH(Intel)
|
||||
+#if WSIZE(32) && ARCH(Intel)
|
||||
+#if !defined(__MUSL_LIBC)
|
||||
// map interposed symbol versions
|
||||
|
||||
SYMVER_ATTRIBUTE (__collector_pwrite64_2_2, pwrite64@GLIBC_2.2)
|
||||
@@ -2547,8 +2546,9 @@ __collector_pwrite64_2_1 (int fildes, const void *buf, size_t nbyte, off64_t off
|
||||
POP_REENTRANCE (guard);
|
||||
return ret;
|
||||
}
|
||||
+#endif
|
||||
|
||||
-#else
|
||||
+#if !defined(__USE_FILE_OFFSET64)
|
||||
ssize_t
|
||||
pwrite64 (int fildes, const void *buf, size_t nbyte, off64_t offset)
|
||||
{
|
||||
@@ -2570,7 +2570,8 @@ pwrite64 (int fildes, const void *buf, size_t nbyte, off64_t offset)
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
-#endif /* SIZE(32) */
|
||||
+
|
||||
+#endif /* SIZE(32) && ARCH(Intel) */
|
||||
|
||||
/*------------------------------------------------------------- fgets */
|
||||
char*
|
||||
diff --git a/gprofng/libcollector/mmaptrace.c b/gprofng/libcollector/mmaptrace.c
|
||||
index 61613c21560..221b4e2d176 100644
|
||||
--- a/gprofng/libcollector/mmaptrace.c
|
||||
+++ b/gprofng/libcollector/mmaptrace.c
|
||||
@@ -1494,7 +1494,7 @@ mmap (void *start, size_t length, int prot, int flags, int fd, off_t offset)
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------- mmap64 */
|
||||
-#if WSIZE(32) /* mmap64 only defined for non-64-bit */
|
||||
+#if WSIZE(32) && !defined(__USE_FILE_OFFSET64)
|
||||
|
||||
void *
|
||||
mmap64 (void *start, size_t length, int prot, int flags, int fd, off64_t offset)
|
||||
--
|
||||
2.31.1
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
require binutils.inc
|
||||
require binutils-${PV}.inc
|
||||
|
||||
DEPENDS += "zlib"
|
||||
|
||||
EXTRA_OECONF += "--with-sysroot=/ \
|
||||
--enable-install-libbfd \
|
||||
--enable-install-libiberty \
|
||||
--enable-shared \
|
||||
--with-system-zlib \
|
||||
"
|
||||
|
||||
EXTRA_OEMAKE:append:libc-musl = "\
|
||||
gt_cv_func_gnugettext1_libc=yes \
|
||||
gt_cv_func_gnugettext2_libc=yes \
|
||||
"
|
||||
# libcollector/collector.c:547:15: error: no member named '__fprintf_chk' in 'struct CollectorUtilFuncs'
|
||||
EXTRA_OECONF:append:toolchain-clang = " --disable-gprofng"
|
||||
# | ../../../gprofng/libcollector/../src/collector_module.h:78:13: error: duplicate member 'pwrite'
|
||||
# | ../../../gprofng/libcollector/dispatcher.c:578:8: error: 'struct sigevent' has no member named '_sigev_un'
|
||||
EXTRA_OECONF:append:libc-musl = " --disable-gprofng"
|
||||
|
||||
EXTRA_OECONF:class-native = "--enable-targets=all \
|
||||
--enable-64-bit-bfd \
|
||||
--enable-install-libiberty \
|
||||
--enable-install-libbfd \
|
||||
--disable-gdb \
|
||||
--disable-gdbserver \
|
||||
--disable-libdecnumber \
|
||||
--disable-readline \
|
||||
--disable-sim \
|
||||
--disable-werror"
|
||||
|
||||
PACKAGECONFIG ??= "${@bb.utils.filter('DISTRO_FEATURES', 'debuginfod', d)}"
|
||||
PACKAGECONFIG[debuginfod] = "--with-debuginfod, --without-debuginfod, elfutils"
|
||||
|
||||
do_install:class-native () {
|
||||
autotools_do_install
|
||||
|
||||
# Install the libiberty header
|
||||
install -d ${D}${includedir}
|
||||
install -m 644 ${S}/include/ansidecl.h ${D}${includedir}
|
||||
install -m 644 ${S}/include/libiberty.h ${D}${includedir}
|
||||
|
||||
# We only want libiberty, libbfd and libopcodes
|
||||
rm -rf ${D}${bindir}
|
||||
rm -rf ${D}${prefix}/${TARGET_SYS}
|
||||
rm -rf ${D}${prefix}/lib/ldscripts
|
||||
rm -rf ${D}${prefix}/share/info
|
||||
rm -rf ${D}${prefix}/share/locale
|
||||
rm -rf ${D}${prefix}/share/man
|
||||
rmdir ${D}${prefix}/share || :
|
||||
rmdir ${D}/${libdir}/gcc-lib || :
|
||||
rmdir ${D}/${libdir}64/gcc-lib || :
|
||||
rmdir ${D}/${libdir} || :
|
||||
rmdir ${D}/${libdir}64 || :
|
||||
}
|
||||
|
||||
# libctf races with libbfd
|
||||
PARALLEL_MAKEINST:class-target = ""
|
||||
PARALLEL_MAKEINST:class-nativesdk = ""
|
||||
|
||||
# Split out libbfd-*.so and libopcodes-*.so so including perf doesn't include
|
||||
# extra stuff
|
||||
PACKAGE_BEFORE_PN += "libbfd libopcodes gprofng"
|
||||
FILES:libbfd = "${libdir}/libbfd-*.so.* ${libdir}/libbfd-*.so"
|
||||
FILES:libopcodes = "${libdir}/libopcodes-*.so.* ${libdir}/libopcodes-*.so"
|
||||
FILES:gprofng = "${sysconfdir}/gprofng.rc ${libdir}/gprofng/libgp-*.so ${libdir}/gprofng/libgprofng.so.* ${bindir}/gp-* ${bindir}/gprofng"
|
||||
FILES:${PN}-dev += "${libdir}/libgprofng.so ${libdir}/libsframe.so"
|
||||
SRC_URI:append:class-nativesdk = " file://0003-binutils-nativesdk-Search-for-alternative-ld.so.conf.patch "
|
||||
|
||||
USE_ALTERNATIVES_FOR:class-nativesdk = ""
|
||||
FILES:${PN}:append:class-nativesdk = " ${bindir}"
|
||||
|
||||
BBCLASSEXTEND = "native nativesdk"
|
||||
Reference in New Issue
Block a user