diff options
Diffstat (limited to 'system/binutils')
34 files changed, 589 insertions, 1212 deletions
diff --git a/system/binutils/APKBUILD b/system/binutils/APKBUILD index 8304e5c7d..06f7c4cb6 100644 --- a/system/binutils/APKBUILD +++ b/system/binutils/APKBUILD @@ -1,38 +1,40 @@ # Maintainer: Adelie Platform Group <adelie-devel@lists.adelielinux.org> pkgname=binutils -pkgver=2.32 -pkgrel=3 +pkgver=2.42 +pkgrel=0 pkgdesc="Tools necessary to build programs" url="https://www.gnu.org/software/binutils/" +arch="all" +license="GPL-2.0+ AND GPL-3.0+ AND LGPL-2.0+ AND LGPL-2.1+ AND LGPL-3.0+ AND BSD-3-Clause" depends="" makedepends_build="byacc flex texinfo" makedepends_host="zlib-dev" makedepends="$makedepends_build $makedepends_host" checkdepends="dejagnu" -arch="all" -license="GPL-2.0+ AND GPL-3.0+ AND LGPL-2.0+ AND LGPL-2.1+ AND LGPL-3.0+ AND BSD-3-Clause" subpackages="$pkgname-dev $pkgname-doc $pkgname-lang $pkgname-libs" -# non-PIC is unsupported by musl/ppc -[ "${CARCH}" != "ppc" ] || options='!check' source="https://ftp.gnu.org/gnu/$pkgname/$pkgname-$pkgver.tar.xz + ar-deterministic-tests.patch binutils-ld-fix-static-linking.patch - disable-gnu-mbind.patch disable-ifunc-tests.patch + disable-mbind2b.patch + disable-pr26580-test.patch disable-preinit-array-tests.patch + disable-relr-glibc-tests.patch + disable-sframe-tests.patch + libctf-32bit-test.patch + musl-preinit-array.patch + musl-versioned-syms.patch + pr25749-test-size.patch remove-pr2404-tests.patch remove-pr19719-test.patch remove-pr19553c-test.patch - srec.patch - CVE-2019-9070-and-9071.patch - CVE-2019-9073.patch - CVE-2019-9074.patch - CVE-2019-9075.patch - CVE-2019-9077.patch - CVE-2019-12972.patch - CVE-2019-14250.patch - CVE-2019-14444.patch + visibility-musl.patch + vsb-hammer.patch + x86_64-mark-plt.patch + x86_64-missing-test.patch BTS-170.patch BTS-196.patch + fix-deprecated-egrep-usage.patch " if [ "$CHOST" != "$CTARGET" ]; then @@ -62,11 +64,14 @@ fi # - CVE-2019-14250 # 2.32-r3: # - CVE-2019-14444 +# 2.32-r5: +# - CVE-2019-17450 +# - CVE-2019-17451 build() { - local _sysroot=/ - local _cross_configure="--enable-install-libiberty" - local _arch_configure="" + _sysroot=/ + _cross_configure="--enable-install-libiberty" + _arch_configure="" if [ "$CHOST" != "$CTARGET" ]; then _sysroot="$CBUILDROOT" @@ -84,7 +89,6 @@ build() { *) _hash_style_configure="--enable-default-hash-style=gnu" ;; esac - cd "$builddir" ./configure \ --build=$CBUILD \ --host=$CHOST \ @@ -100,6 +104,7 @@ build() { --enable-64-bit-bfd \ --enable-plugins \ --enable-relro \ + --enable-gprofng=no \ --disable-gold \ --enable-deterministic-archives \ $_cross_configure \ @@ -111,8 +116,11 @@ build() { make } +check() { + make check +} + package() { - cd "$builddir" make install DESTDIR="$pkgdir" if [ -d "$pkgdir"/usr/lib64 ]; then die "Something really bad happened." @@ -127,11 +135,6 @@ package() { fi } -check() { - cd "$builddir" - make check -} - libs() { pkgdesc="Runtime libraries from binutils" @@ -139,22 +142,26 @@ libs() { mv "$pkgdir"/usr/lib/lib*.so "$subpkgdir"/usr/lib/ } -sha512sums="d326408f12a03d9a61a9de56584c2af12f81c2e50d2d7e835d51565df8314df01575724afa1e43bd0db45cfc9916b41519b67dfce03232aa4978704492a6994a binutils-2.32.tar.xz -ecee33b0e435aa704af1c334e560f201638ff79e199aa11ed78a72f7c9b46f85fbb227af5748e735fd681d1965fcc42ac81b0c8824e540430ce0c706c81e8b49 binutils-ld-fix-static-linking.patch -d378fdf1964f8f2bd0b1e62827ac5884bdf943aa435ec89c29fc84bb045d406b733fffaff8fdd8bd1cba8ddea7701c4cf6ccf3ed76a8a3df9c72b447737575a6 disable-gnu-mbind.patch -474ab24097bbb5b24433620549e5234fe65c547824c1342f693c718ffbc81e2d968259cce2d650b55200dd1ec89da207ea2db10c551cd9941285c4600b4297b2 disable-ifunc-tests.patch -3537752e63cef0b5ef136d003ff7e814ba66b12624d817430112d0f291a792e8960fa69a78036f526af835441b3ee483d6a53d55c7b3dd8ee96f0399682dbcbe disable-preinit-array-tests.patch -32ab4215669c728648179c124632467573a3d4675e79f0f0d221c22eb2ec1ca5488b79910bd09142f90a1e0d0b81d99ca4846297f4f9561f158db63745facb66 remove-pr2404-tests.patch -a193d1fa7f42d91915960460a15e4d24e0df529d81e23014bcf45d283fae76bb7b300fdcb0d0a9d521cdb9137322efa1dc357112596d6ae7a7fd05988ac359b9 remove-pr19719-test.patch -39ef9c76dd5db6b15f11ffa8061f7ca844fb79c3fb9879c3b1466eef332a28b833597c87003ab9f260b1b85023fae264659088aee27cad7e5aa77b2d58b9a3f6 remove-pr19553c-test.patch -f720b3356b88e366c52941da056e543e4b42bc77f012e5b0290f79e15b0a31d855989ad01920680507a9df0544e5b8e26d0cf8d6f22fbdeb874af31cff4c16d3 srec.patch -f52d21f194c2d7dbdc56e93636d3228034ee1718b457e5a5ce289bba2454155846d1ff6ea8530d11a901a85c9af945360bc17cda9e7370c36362aa6c762154c7 CVE-2019-9070-and-9071.patch -032fed723b610fe06e210e2ebee8d24962ecad1dc69d98d38e95f768c9ed64cb991158758ef71e684d6d762a30e9a852287836be2bb8a2aba27fe31d2792c0a0 CVE-2019-9073.patch -16b4cc094a6846399e47271da6fe8d8bd8b70246e12e872fcafb85f11809b5699eddba723fbac664c062c02f9b5658ea9770e14c522e151cdea1d39e69c851dd CVE-2019-9074.patch -a46b9211608e2f35219b95363a5ba90506742dcb9e4bd4a43915af6c0b3e74bd8339a8318dc2923c0952ef579112412cb1cf619a5f090066769a852587b27d03 CVE-2019-9075.patch -c0f50f1a843480f29b3895c8814df9801b9f90260edbaff1831aa5738fedd07a9e6b7a79f5b6f9be34df4954dbf02feb5232ebbecc596277fc2fe63673ed347c CVE-2019-9077.patch -9109a6ff9c55f310f86a1561fe6b404534928d402672490059bbe358f77c0c2a7f73c8b67f0a4450f00ba1776452858b63fa60cf2ec0744104a6b077e8fa3e42 CVE-2019-12972.patch -c277202272d9883741c2530a94c6d50d55dd9d0a9efaa43a1f8c9fc7529bd45e635255c0d90035dfc5920d5387010a4259612a4d711260a95d7b3d9fa6500e4f CVE-2019-14250.patch -0942cc1a4c5ec03e931c6ebd15c5d60eae6be48cd0a3d9b7f6356f97361226bb6d53dbdcb01b20efcca0ccaf23764730d9bbad2c1bbe2ea6ca320e43b43b311b CVE-2019-14444.patch -d4543d2f77808d317d17a5f0eb9af21540ef8543fceaed4e3524213e31e058333321f3ba3b495199e3b57bfd0c4164929cf679369470389e26871b8895cb0110 BTS-170.patch -9cc17d9fe3fc1351d1f6b4fc1c916254529f3304c95db6f4698b867eeb623210b914dc798fb837eafbad2b287b78b31c4ed5482b3151a2992864da04e1dd5fac BTS-196.patch" +sha512sums="155f3ba14cd220102f4f29a4f1e5cfee3c48aa03b74603460d05afb73c70d6657a9d87eee6eb88bf13203fe6f31177a5c9addc04384e956e7da8069c8ecd20a6 binutils-2.42.tar.xz +07a9a47c5955a1911cab5387134cfacfff82f5521066bb61f671c7e0d07ce64c31c4162a57234604b470d24f27093cb23202ad05bebc34479957c6fe64dbc8fb ar-deterministic-tests.patch +3736ea519eab417bc05f9851954e644a4d1b44f4641fb5685ff2238bd2da775f20611edfdcd3a72eb1f2a31ba2a98e3fd97fe9d57714b7d9846553eb881a3435 binutils-ld-fix-static-linking.patch +5eef9c29066f906fc133736efdfb9c94a897f08650bb741dc0ea8b5614563166d2afa9018c045569c853ae7cabe08ef5ec3539eb7b53df55b39b8c659a8c8b72 disable-ifunc-tests.patch +b9f5c09aec2e6423f31fae48a26b8138f65569e63f28dc2190cb73abc2493832cc33362443ec0f24e7833bf2eb0f14ce78045d82fd8ebb4097eafd1f1a34a3fe disable-mbind2b.patch +086f97e52c536e68b082716d054d32be50b0947cab9c62d87b1959efbf8f99423b6dc52f79da4a6dedc588a577132cb062a071928cd2b85449a107b89c3771de disable-pr26580-test.patch +6568983766b0b9e947c21fc12f29d41b79a2a0c0c162e0d2c00120713da76bec7b6369333dbdca9d53dd0c81e2cd438c20e30076893742bfb8e14dbc89301c57 disable-preinit-array-tests.patch +4b0089f72c676fadbbcffbd87d2715ca010a4a87392d677b0887b86ce5c2ba446fb45e079bcd4492c47d1479b91b4a2c5b2466746166081e04f4b24191239625 disable-relr-glibc-tests.patch +e8ebb984e9b13b75114c8092d1ad2d0c1b3bb59bf10e66ca250151e79844125a23f74b8c4142210c8e574785c35e0ee1df0499e0cfd6ef59e8e80d58121963e1 disable-sframe-tests.patch +4948b963906a72075873f2988289294f6c1eb60297ac2bdee5d8646ad8a23f8f16d98b3e4f048fb625d347be28028a87247241a8dca030b4847450951b7aca32 libctf-32bit-test.patch +1f22d31b4bc1ed96d9aa1fc49c4328c6516cbb196c0d86db3f68665b948a4950911bb23d53c6f3b82703cddf9380f706355177842f12aa7fc11dd0124feadd3e musl-preinit-array.patch +ad38c37ae67f60cf3091bf5012dbdaba0982a3e4eac5f3be400d989fb3f7400a4be2db0b8658357ec1e8be71eaddf012e9608ae8540f28fe9fa3af3d87e90fa3 musl-versioned-syms.patch +c76733b76daf5d4af17464777cb753c68063fdc6040d943962c78182ca65f46a2744d4437f6cc3b8ff5f09ff8c0f582690b7dc89eaaf4da48f9300a81b8b3803 pr25749-test-size.patch +c54fa146dd6838c7b55441943b2ca0e344d851615574a46464e253d3f4a9ef3594ef9cf2bc69b584032a8206bf891d0aae62fb38b32873dc60c9d51874ead2ae remove-pr2404-tests.patch +b4bd7b5d2ad3705c7db0924c73bd91d5f8ef07e73f146c250af7d794387ab219b02254b1b61060a524f2c27c04e14a401e4ce7ed50367f424f8c03874318c2c1 remove-pr19719-test.patch +06f9df891a4ae0e9f6f8b3282d3691ede7cc0f08d63bf722f942f3c94dd4d7f3907b7bb5a8087e63639569e61aed6c39b5f5da7ad6566e7ef278524aa32ada63 remove-pr19553c-test.patch +075565f9bc85c0fc4bd36c7a848f6b876b71fbbe0f572b5c21961687ab4e2cd00c784fba09fe92b214c4b1df871ebd6409e6c93dde5a0a6c1ef6e41a30b24520 visibility-musl.patch +55bdb08f93563449b170ba8623cd7d4409c8f22abb15fca23bc87f23cc43cd580fa149e68271e65fdf2c29ddb0a15cd78d6f0de1a50332fdc026ea1b7d0ec7b8 vsb-hammer.patch +fcd71dc0e664bce0d1066b6adec9b8eebb85eb589061ad7e88934dbda4d5f8849ff6db97299a8026840515e44a73de5e131e3209052be45e807706e79ef8a045 x86_64-mark-plt.patch +f524acb49e7ce14133a11b237858aaadc84f4c3290b6e59335ec293fc6cc0e65c9bdd47c2b68bf75bb3a39ebe2e61df4f7bf941acec69d79968aa68915ade4d5 x86_64-missing-test.patch +c62365110dd0a550e55f1445b197f1f968849b1079439cda0d44778772964779b4ab1142ccc662ba75ebb040e09ef4b4bfc253f4632db24ed783155be2f5f3b1 BTS-170.patch +ab7d0c1fa74862bf9364d5e2228200054a2c5c4351c979dc7a9850f630d74034edffba740b468e009c5419a3cec110322364303f8af28dcdbfbe672c3c16f450 BTS-196.patch +95f2063ecb902148e53603211452ca21d4dec215c32a07c2eebc5881dbdc7cba34a7a49177fedf4db1d7d8542708af673a31930fd7d49a6a2eb00b47dbe6eeb9 fix-deprecated-egrep-usage.patch" diff --git a/system/binutils/BTS-170.patch b/system/binutils/BTS-170.patch index daca64319..c0c02dbc9 100644 --- a/system/binutils/BTS-170.patch +++ b/system/binutils/BTS-170.patch @@ -4,9 +4,9 @@ lea is being emitted instead of mov. https://bts.adelielinux.org/show_bug.cgi?id=170 https://bts.adelielinux.org/show_bug.cgi?id=196 ---- binutils-2.32/ld/testsuite/ld-x86-64/no-plt.exp 2019-01-19 10:01:34.000000000 -0600 -+++ binutils-2.32/ld/testsuite/ld-x86-64/no-plt.exp 2019-09-11 17:21:27.232257151 -0500 -@@ -100,15 +100,6 @@ run_cc_link_tests [list \ +--- binutils-2.41/ld/testsuite/ld-x86-64/no-plt.exp 2019-01-19 10:01:34.000000000 -0600 ++++ binutils-2.41/ld/testsuite/ld-x86-64/no-plt.exp 2019-09-11 17:21:27.232257151 -0500 +@@ -97,15 +97,6 @@ run_cc_link_tests [list \ "no-plt-1c" \ ] \ [list \ @@ -22,9 +22,9 @@ https://bts.adelielinux.org/show_bug.cgi?id=196 "No PLT (PIE 1e)" \ "-pie tmpdir/no-plt-check1.o tmpdir/no-plt-main1.o \ tmpdir/no-plt-func1.o tmpdir/no-plt-extern1.o" \ ---- binutils-2.32/ld/testsuite/ld-i386/no-plt.exp 2019-01-19 10:01:33.000000000 -0600 -+++ binutils-2.32/ld/testsuite/ld-i386/no-plt.exp 2019-09-11 18:03:48.012302603 -0500 -@@ -102,15 +102,6 @@ run_cc_link_tests [list \ +--- binutils-2.41/ld/testsuite/ld-i386/no-plt.exp 2019-01-19 10:01:33.000000000 -0600 ++++ binutils-2.41/ld/testsuite/ld-i386/no-plt.exp 2019-09-11 18:03:48.012302603 -0500 +@@ -99,15 +99,6 @@ run_cc_link_tests [list \ "no-plt-1c" \ ] \ [list \ diff --git a/system/binutils/BTS-196.patch b/system/binutils/BTS-196.patch index 08316d279..d442f5921 100644 --- a/system/binutils/BTS-196.patch +++ b/system/binutils/BTS-196.patch @@ -1,75 +1,8 @@ https://bts.adelielinux.org/show_bug.cgi?id=196 ---- binutils-2.32/ld/testsuite/ld-i386/i386.exp 2019-01-19 10:01:33.000000000 -0600 -+++ binutils-2.32/ld/testsuite/ld-i386/i386.exp 2019-09-17 13:47:29.921108280 -0500 -@@ -1035,23 +1035,6 @@ if { [isnative] - "pr18900.out" \ - ] \ - [list \ -- "Run pr19031" \ -- "$NOPIE_LDFLAGS tmpdir/pr19031.so" \ -- "-Wa,-mx86-used-note=yes" \ -- { pr19031b.S pr19031c.c } \ -- "pr19031" \ -- "pr19031.out" \ -- "$NOPIE_CFLAGS" \ -- ] \ -- [list \ -- "Run got1" \ -- "$NOPIE_LDFLAGS tmpdir/got1d.so" \ -- "-Wa,-mx86-used-note=yes" \ -- { got1a.S got1b.c got1c.c } \ -- "got1" \ -- "got1.out" \ -- ] \ -- [list \ - "Run property 1" \ - "" \ - "-Wa,-mx86-used-note=yes" \ -@@ -1159,8 +1142,6 @@ if { [isnative] - ] - - undefined_weak "$NOPIE_CFLAGS" "$NOPIE_LDFLAGS" -- undefined_weak "-fPIE" "$NOPIE_LDFLAGS" -- undefined_weak "-fPIE" "-pie" - undefined_weak "-fPIE" "-z nodynamic-undefined-weak $NOPIE_LDFLAGS" - undefined_weak "-fPIE" "-pie -z nodynamic-undefined-weak" - } -@@ -1327,15 +1308,6 @@ if { [isnative] - "$NOPIE_CFLAGS" \ - ] \ - [list \ -- "Run pr22001-1" \ -- "$NOPIE_LDFLAGS -Wl,-z,nocopyreloc,--no-as-needed tmpdir/pr22001-1.so" \ -- "-Wa,-mx86-used-note=yes" \ -- { pr22001-1b.c } \ -- "pr22001-1" \ -- "pass.out" \ -- "$NOPIE_CFLAGS" \ -- ] \ -- [list \ - "Run pr22001-1 (PIE 1)" \ - "$NOPIE_LDFLAGS -Wl,-z,nocopyreloc,--no-as-needed tmpdir/pr22001-1.so" \ - "-Wa,-mx86-used-note=yes" \ -@@ -1370,15 +1342,6 @@ if { [isnative] - "-fPIC" \ - ] \ - [list \ -- "Run pr21997-1" \ -- "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr21997-1.so" \ -- "-Wa,-mx86-used-note=yes" \ -- { pr21997-1b.c } \ -- "pr21997-1" \ -- "pass.out" \ -- "$NOPIE_CFLAGS" \ -- ] \ -- [list \ - "Run pr21997-1 (PIC 1)" \ - "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr21997-1.so" \ - "-Wa,-mx86-used-note=yes" \ ---- binutils-2.32/ld/testsuite/ld-i386/no-plt.exp 2019-09-17 13:51:35.771111471 -0500 -+++ binutils-2.32/ld/testsuite/ld-i386/no-plt.exp 2019-09-17 14:00:48.581118647 -0500 -@@ -66,69 +66,6 @@ run_cc_link_tests [list \ +--- binutils-2.41/ld/testsuite/ld-i386/no-plt.exp 2019-09-17 13:51:35.771111471 -0500 ++++ binutils-2.41/ld/testsuite/ld-i386/no-plt.exp 2019-09-17 14:00:48.581118647 -0500 +@@ -63,69 +63,6 @@ run_cc_link_tests [list \ "libno-plt-1a.so" \ ] \ [list \ @@ -139,7 +72,7 @@ https://bts.adelielinux.org/show_bug.cgi?id=196 "No PLT (dynamic 1h)" \ "$NOPIE_LDFLAGS tmpdir/no-plt-check1b.o tmpdir/no-plt-main1.o \ tmpdir/no-plt-func1.o tmpdir/no-plt-extern1b.o" \ -@@ -146,15 +83,6 @@ run_cc_link_tests [list \ +@@ -143,15 +80,6 @@ run_cc_link_tests [list \ {{readelf -Wr no-plt-1i.rd} {objdump -dwrj.text no-plt-1i.dd}} \ "no-plt-1i" \ ] \ @@ -155,7 +88,7 @@ https://bts.adelielinux.org/show_bug.cgi?id=196 ] run_ld_link_exec_tests [list \ -@@ -168,24 +96,6 @@ run_ld_link_exec_tests [list \ +@@ -165,24 +93,6 @@ run_ld_link_exec_tests [list \ "pass.out" \ ] \ [list \ @@ -180,7 +113,7 @@ https://bts.adelielinux.org/show_bug.cgi?id=196 "No PLT (static 1d)" \ "-static tmpdir/no-plt-check1a.o tmpdir/no-plt-main1.o \ tmpdir/no-plt-func1.o tmpdir/no-plt-extern1a.o" \ -@@ -204,24 +114,6 @@ run_ld_link_exec_tests [list \ +@@ -201,24 +111,6 @@ run_ld_link_exec_tests [list \ "pass.out" \ ] \ [list \ @@ -205,7 +138,7 @@ https://bts.adelielinux.org/show_bug.cgi?id=196 "No PLT (dynamic 1h)" \ "$NOPIE_LDFLAGS tmpdir/no-plt-check1b.o tmpdir/no-plt-main1.o \ tmpdir/no-plt-func1.o tmpdir/no-plt-extern1b.o" \ -@@ -239,15 +131,6 @@ run_ld_link_exec_tests [list \ +@@ -236,15 +128,6 @@ run_ld_link_exec_tests [list \ "no-plt-1i" \ "pass.out" \ ] \ diff --git a/system/binutils/CVE-2019-12972.patch b/system/binutils/CVE-2019-12972.patch deleted file mode 100644 index 82b41c014..000000000 --- a/system/binutils/CVE-2019-12972.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 890f750a3b053532a4b839a2dd6243076de12031 Mon Sep 17 00:00:00 2001 -From: Alan Modra <amodra@gmail.com> -Date: Fri, 21 Jun 2019 11:51:38 +0930 -Subject: [PATCH] PR24689, string table corruption - -The testcase in the PR had a e_shstrndx section of type SHT_GROUP. -hdr->contents were initialized by setup_group rather than being read -from the file, thus last byte was not zero and string dereference ran -off the end of the buffer. - - PR 24689 - * elfcode.h (elf_object_p): Check type of e_shstrndx section. ---- - bfd/elfcode.h | 3 ++- - 2 files changed, 7 insertions(+), 1 deletion(-) - -diff --git a/bfd/elfcode.h b/bfd/elfcode.h -index a0487b0..5180f79 100644 ---- a/bfd/elfcode.h -+++ b/bfd/elfcode.h -@@ -754,7 +754,8 @@ elf_object_p (bfd *abfd) - /* A further sanity check. */ - if (i_ehdrp->e_shnum != 0) - { -- if (i_ehdrp->e_shstrndx >= elf_numsections (abfd)) -+ if (i_ehdrp->e_shstrndx >= elf_numsections (abfd) -+ || i_shdrp[i_ehdrp->e_shstrndx].sh_type != SHT_STRTAB) - { - /* PR 2257: - We used to just goto got_wrong_format_error here --- -2.9.3 - diff --git a/system/binutils/CVE-2019-14250.patch b/system/binutils/CVE-2019-14250.patch deleted file mode 100644 index fedc4fa7f..000000000 --- a/system/binutils/CVE-2019-14250.patch +++ /dev/null @@ -1,25 +0,0 @@ -Author: marxin -Date: Tue Jul 23 07:33:32 2019 UTC -https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=273718 - -libiberty: Check zero value shstrndx in simple-object-elf.c - ---- trunk/libiberty/simple-object-elf.c 2019/07/23 07:31:50 273717 -+++ trunk/libiberty/simple-object-elf.c 2019/07/23 07:33:32 273718 -@@ -548,7 +548,15 @@ - XDELETE (eor); - return NULL; - } -- -+ -+ if (eor->shstrndx == 0) -+ { -+ *errmsg = "invalid ELF shstrndx == 0"; -+ *err = 0; -+ XDELETE (eor); -+ return NULL; -+ } -+ - return (void *) eor; - } - diff --git a/system/binutils/CVE-2019-14444.patch b/system/binutils/CVE-2019-14444.patch deleted file mode 100644 index 43d4e2a91..000000000 --- a/system/binutils/CVE-2019-14444.patch +++ /dev/null @@ -1,28 +0,0 @@ -From e17869db99195849826eaaf5d2d0eb2cfdd7a2a7 Mon Sep 17 00:00:00 2001 -From: Nick Clifton <nickc@redhat.com> -Date: Mon, 5 Aug 2019 10:40:35 +0100 -Subject: [PATCH] Catch potential integer overflow in readelf when processing - corrupt binaries. - - PR 24829 - * readelf.c (apply_relocations): Catch potential integer overflow - whilst checking reloc location against section size. ---- - binutils/readelf.c | 2 +- - -diff --git a/binutils/readelf.c b/binutils/readelf.c -index b896ad9..e785fde 100644 ---- a/binutils/readelf.c -+++ b/binutils/readelf.c -@@ -13366,7 +13366,7 @@ apply_relocations (Filedata * filedata, - } - - rloc = start + rp->r_offset; -- if ((rloc + reloc_size) > end || (rloc < start)) -+ if (rloc >= end || (rloc + reloc_size) > end || (rloc < start)) - { - warn (_("skipping invalid relocation offset 0x%lx in section %s\n"), - (unsigned long) rp->r_offset, --- -2.9.3 - diff --git a/system/binutils/CVE-2019-9070-and-9071.patch b/system/binutils/CVE-2019-9070-and-9071.patch deleted file mode 100644 index 5f401d147..000000000 --- a/system/binutils/CVE-2019-9070-and-9071.patch +++ /dev/null @@ -1,128 +0,0 @@ -Author: nickc -Date: Wed Apr 10 14:44:47 2019 UTC -https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=270258 - -Fix a stack exhaustion bug in libiberty's demangler when decoding a -pathalogically constructed mangled name. - -PR 89394 -* cp-demangle.c (cplus_demangle_fill_name): Reject negative -lengths. -(d_count_templates_scopes): Replace num_templates and num_scopes -parameters with a struct d_print_info pointer parameter. Adjust -body of the function accordingly. Add recursion counter and check -that the recursion limit is not reached. -(d_print_init): Pass dpi parameter to d_count_templates_scopes. -Reset recursion counter afterwards, unless the recursion limit was -reached. - ---- trunk/libiberty/cp-demangle.c 2019/04/10 14:39:59 270257 -+++ trunk/libiberty/cp-demangle.c 2019/04/10 14:44:47 270258 -@@ -861,7 +861,7 @@ - int - cplus_demangle_fill_name (struct demangle_component *p, const char *s, int len) - { -- if (p == NULL || s == NULL || len == 0) -+ if (p == NULL || s == NULL || len <= 0) - return 0; - p->d_printing = 0; - p->type = DEMANGLE_COMPONENT_NAME; -@@ -4061,7 +4061,7 @@ - are larger than the actual numbers encountered. */ - - static void --d_count_templates_scopes (int *num_templates, int *num_scopes, -+d_count_templates_scopes (struct d_print_info *dpi, - const struct demangle_component *dc) - { - if (dc == NULL) -@@ -4081,13 +4081,13 @@ - break; - - case DEMANGLE_COMPONENT_TEMPLATE: -- (*num_templates)++; -+ dpi->num_copy_templates++; - goto recurse_left_right; - - case DEMANGLE_COMPONENT_REFERENCE: - case DEMANGLE_COMPONENT_RVALUE_REFERENCE: - if (d_left (dc)->type == DEMANGLE_COMPONENT_TEMPLATE_PARAM) -- (*num_scopes)++; -+ dpi->num_saved_scopes++; - goto recurse_left_right; - - case DEMANGLE_COMPONENT_QUAL_NAME: -@@ -4152,42 +4152,42 @@ - case DEMANGLE_COMPONENT_TAGGED_NAME: - case DEMANGLE_COMPONENT_CLONE: - recurse_left_right: -- d_count_templates_scopes (num_templates, num_scopes, -- d_left (dc)); -- d_count_templates_scopes (num_templates, num_scopes, -- d_right (dc)); -+ /* PR 89394 - Check for too much recursion. */ -+ if (dpi->recursion > DEMANGLE_RECURSION_LIMIT) -+ /* FIXME: There ought to be a way to report to the -+ user that the recursion limit has been reached. */ -+ return; -+ -+ ++ dpi->recursion; -+ d_count_templates_scopes (dpi, d_left (dc)); -+ d_count_templates_scopes (dpi, d_right (dc)); -+ -- dpi->recursion; - break; - - case DEMANGLE_COMPONENT_CTOR: -- d_count_templates_scopes (num_templates, num_scopes, -- dc->u.s_ctor.name); -+ d_count_templates_scopes (dpi, dc->u.s_ctor.name); - break; - - case DEMANGLE_COMPONENT_DTOR: -- d_count_templates_scopes (num_templates, num_scopes, -- dc->u.s_dtor.name); -+ d_count_templates_scopes (dpi, dc->u.s_dtor.name); - break; - - case DEMANGLE_COMPONENT_EXTENDED_OPERATOR: -- d_count_templates_scopes (num_templates, num_scopes, -- dc->u.s_extended_operator.name); -+ d_count_templates_scopes (dpi, dc->u.s_extended_operator.name); - break; - - case DEMANGLE_COMPONENT_FIXED_TYPE: -- d_count_templates_scopes (num_templates, num_scopes, -- dc->u.s_fixed.length); -+ d_count_templates_scopes (dpi, dc->u.s_fixed.length); - break; - - case DEMANGLE_COMPONENT_GLOBAL_CONSTRUCTORS: - case DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS: -- d_count_templates_scopes (num_templates, num_scopes, -- d_left (dc)); -+ d_count_templates_scopes (dpi, d_left (dc)); - break; - - case DEMANGLE_COMPONENT_LAMBDA: - case DEMANGLE_COMPONENT_DEFAULT_ARG: -- d_count_templates_scopes (num_templates, num_scopes, -- dc->u.s_unary_num.sub); -+ d_count_templates_scopes (dpi, dc->u.s_unary_num.sub); - break; - } - } -@@ -4222,8 +4222,12 @@ - dpi->next_copy_template = 0; - dpi->num_copy_templates = 0; - -- d_count_templates_scopes (&dpi->num_copy_templates, -- &dpi->num_saved_scopes, dc); -+ d_count_templates_scopes (dpi, dc); -+ /* If we did not reach the recursion limit, then reset the -+ current recursion value back to 0, so that we can print -+ the templates. */ -+ if (dpi->recursion < DEMANGLE_RECURSION_LIMIT) -+ dpi->recursion = 0; - dpi->num_copy_templates *= dpi->num_saved_scopes; - - dpi->current_template = NULL; diff --git a/system/binutils/CVE-2019-9073.patch b/system/binutils/CVE-2019-9073.patch deleted file mode 100644 index 9ea45707b..000000000 --- a/system/binutils/CVE-2019-9073.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 7d272a55caebfc26ab2e15d1e9439bac978b9bb7 Mon Sep 17 00:00:00 2001 -From: Alan Modra <amodra@gmail.com> -Date: Wed, 20 Feb 2019 12:06:31 +1030 -Subject: [PATCH] PR24233, Out of memory - - PR 24233 - * objdump.c (dump_bfd_private_header): Print warning if - bfd_print_private_bfd_data returns false. ---- - binutils/ChangeLog | 6 ++++++ - binutils/objdump.c | 4 +++- - 2 files changed, 9 insertions(+), 1 deletion(-) - -diff --git a/binutils/objdump.c b/binutils/objdump.c -index 8725390..7d0c6a4 100644 ---- a/binutils/objdump.c -+++ b/binutils/objdump.c -@@ -3178,7 +3178,9 @@ dump_bfd_header (bfd *abfd) - static void - dump_bfd_private_header (bfd *abfd) - { -- bfd_print_private_bfd_data (abfd, stdout); -+ if (!bfd_print_private_bfd_data (abfd, stdout)) -+ non_fatal (_("warning: private headers incomplete: %s"), -+ bfd_errmsg (bfd_get_error ())); - } - - static void --- -2.9.3 - diff --git a/system/binutils/CVE-2019-9074.patch b/system/binutils/CVE-2019-9074.patch deleted file mode 100644 index 74b6c2040..000000000 --- a/system/binutils/CVE-2019-9074.patch +++ /dev/null @@ -1,49 +0,0 @@ -From 179f2db0d9c397d7dd8a59907b84208b79f7f48c Mon Sep 17 00:00:00 2001 -From: Alan Modra <amodra@gmail.com> -Date: Tue, 19 Feb 2019 22:48:44 +1030 -Subject: [PATCH] PR24235, Read memory violation in pei-x86_64.c - - PR 24235 - * pei-x86_64.c (pex64_bfd_print_pdata_section): Correct checks - attempting to prevent read past end of section. ---- - bfd/pei-x86_64.c | 9 ++++----- - 2 files changed, 10 insertions(+), 5 deletions(-) - -diff --git a/bfd/pei-x86_64.c b/bfd/pei-x86_64.c -index ff1093c..7e75104 100644 ---- a/bfd/pei-x86_64.c -+++ b/bfd/pei-x86_64.c -@@ -541,7 +541,7 @@ pex64_bfd_print_pdata_section (bfd *abfd, void *vfile, asection *pdata_section) - /* virt_size might be zero for objects. */ - if (stop == 0 && strcmp (abfd->xvec->name, "pe-x86-64") == 0) - { -- stop = (datasize / onaline) * onaline; -+ stop = datasize; - virt_size_is_zero = TRUE; - } - else if (datasize < stop) -@@ -551,8 +551,8 @@ pex64_bfd_print_pdata_section (bfd *abfd, void *vfile, asection *pdata_section) - _("Warning: %s section size (%ld) is smaller than virtual size (%ld)\n"), - pdata_section->name, (unsigned long) datasize, - (unsigned long) stop); -- /* Be sure not to read passed datasize. */ -- stop = datasize / onaline; -+ /* Be sure not to read past datasize. */ -+ stop = datasize; - } - - /* Display functions table. */ -@@ -724,8 +724,7 @@ pex64_bfd_print_pdata_section (bfd *abfd, void *vfile, asection *pdata_section) - altent += imagebase; - - if (altent >= pdata_vma -- && (altent + PDATA_ROW_SIZE <= pdata_vma -- + pei_section_data (abfd, pdata_section)->virt_size)) -+ && altent - pdata_vma + PDATA_ROW_SIZE <= stop) - { - pex64_get_runtime_function - (abfd, &arf, &pdata[altent - pdata_vma]); --- -2.9.3 - diff --git a/system/binutils/CVE-2019-9075.patch b/system/binutils/CVE-2019-9075.patch deleted file mode 100644 index 0084d3368..000000000 --- a/system/binutils/CVE-2019-9075.patch +++ /dev/null @@ -1,96 +0,0 @@ -From 8abac8031ed369a2734b1cdb7df28a39a54b4b49 Mon Sep 17 00:00:00 2001 -From: Alan Modra <amodra@gmail.com> -Date: Wed, 20 Feb 2019 08:21:24 +1030 -Subject: [PATCH] PR24236, Heap buffer overflow in - _bfd_archive_64_bit_slurp_armap - - PR 24236 - * archive64.c (_bfd_archive_64_bit_slurp_armap): Move code adding - sentinel NUL to string buffer nearer to loop where it is used. - Don't go past sentinel when scanning strings, and don't write - NUL again. - * archive.c (do_slurp_coff_armap): Simplify string handling to - archive64.c style. ---- - bfd/archive.c | 17 +++++++---------- - bfd/archive64.c | 10 +++++----- - 3 files changed, 22 insertions(+), 15 deletions(-) - -diff --git a/bfd/archive.c b/bfd/archive.c -index d2d9b72..68a92a3 100644 ---- a/bfd/archive.c -+++ b/bfd/archive.c -@@ -1012,6 +1012,7 @@ do_slurp_coff_armap (bfd *abfd) - int *raw_armap, *rawptr; - struct artdata *ardata = bfd_ardata (abfd); - char *stringbase; -+ char *stringend; - bfd_size_type stringsize; - bfd_size_type parsed_size; - carsym *carsyms; -@@ -1071,22 +1072,18 @@ do_slurp_coff_armap (bfd *abfd) - } - - /* OK, build the carsyms. */ -- for (i = 0; i < nsymz && stringsize > 0; i++) -+ stringend = stringbase + stringsize; -+ *stringend = 0; -+ for (i = 0; i < nsymz; i++) - { -- bfd_size_type len; -- - rawptr = raw_armap + i; - carsyms->file_offset = swap ((bfd_byte *) rawptr); - carsyms->name = stringbase; -- /* PR 17512: file: 4a1d50c1. */ -- len = strnlen (stringbase, stringsize); -- if (len < stringsize) -- len ++; -- stringbase += len; -- stringsize -= len; -+ stringbase += strlen (stringbase); -+ if (stringbase != stringend) -+ ++stringbase; - carsyms++; - } -- *stringbase = 0; - - ardata->symdef_count = nsymz; - ardata->first_file_filepos = bfd_tell (abfd); -diff --git a/bfd/archive64.c b/bfd/archive64.c -index 312bf82..42f6ed9 100644 ---- a/bfd/archive64.c -+++ b/bfd/archive64.c -@@ -100,8 +100,6 @@ _bfd_archive_64_bit_slurp_armap (bfd *abfd) - return FALSE; - carsyms = ardata->symdefs; - stringbase = ((char *) ardata->symdefs) + carsym_size; -- stringbase[stringsize] = 0; -- stringend = stringbase + stringsize; - - raw_armap = (bfd_byte *) bfd_alloc (abfd, ptrsize); - if (raw_armap == NULL) -@@ -115,15 +113,17 @@ _bfd_archive_64_bit_slurp_armap (bfd *abfd) - goto release_raw_armap; - } - -+ stringend = stringbase + stringsize; -+ *stringend = 0; - for (i = 0; i < nsymz; i++) - { - carsyms->file_offset = bfd_getb64 (raw_armap + i * 8); - carsyms->name = stringbase; -- if (stringbase < stringend) -- stringbase += strlen (stringbase) + 1; -+ stringbase += strlen (stringbase); -+ if (stringbase != stringend) -+ ++stringbase; - ++carsyms; - } -- *stringbase = '\0'; - - ardata->symdef_count = nsymz; - ardata->first_file_filepos = bfd_tell (abfd); --- -2.9.3 - diff --git a/system/binutils/CVE-2019-9077.patch b/system/binutils/CVE-2019-9077.patch deleted file mode 100644 index de044e387..000000000 --- a/system/binutils/CVE-2019-9077.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 7fc0c668f2aceb8582d74db1ad2528e2bba8a921 Mon Sep 17 00:00:00 2001 -From: Nick Clifton <nickc@redhat.com> -Date: Wed, 20 Feb 2019 17:03:47 +0000 -Subject: [PATCH] Fix a illegal memory access fault when parsing a corrupt MIPS - option section using readelf. - - PR 24243 - * readelf.c (process_mips_specific): Check for an options section - that is too small to even contain a single option. ---- - binutils/readelf.c | 6 ++++++ - 2 files changed, 9 insertions(+) - -diff --git a/binutils/readelf.c b/binutils/readelf.c -index 54d165e..20ebacc 100644 ---- a/binutils/readelf.c -+++ b/binutils/readelf.c -@@ -16187,6 +16187,12 @@ process_mips_specific (Filedata * filedata) - error (_("No MIPS_OPTIONS header found\n")); - return FALSE; - } -+ /* PR 24243 */ -+ if (sect->sh_size < sizeof (* eopt)) -+ { -+ error (_("The MIPS options section is too small.\n")); -+ return FALSE; -+ } - - eopt = (Elf_External_Options *) get_data (NULL, filedata, options_offset, 1, - sect->sh_size, _("options")); --- -2.9.3 - diff --git a/system/binutils/ar-deterministic-tests.patch b/system/binutils/ar-deterministic-tests.patch new file mode 100644 index 000000000..f3f63b937 --- /dev/null +++ b/system/binutils/ar-deterministic-tests.patch @@ -0,0 +1,67 @@ +From: Stephen Kitt <steve@sk2.org> +Date: Mon, 11 Mar 2024 07:21:47 +0000 (+0100) +Subject: tests: force non-deterministic mode in non-deterministic tests +X-Git-Tag: gdb-15-branchpoint~761 +X-Git-Url: https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff_plain;h=64e215c15bc316f673161c76db93a50bda45666a;hp=5790996072837620a8fd3756dda5138eb2f2781b + +tests: force non-deterministic mode in non-deterministic tests + +Since ar can be built defaulting to deterministic mode, tests which +expect non-deterministic behaviour need to explicitly set the U flag. + +The non-deterministic member test expects SOURCE_DATE_EPOCH to not be +set; this documents that. Unconditionally unsetting the variable +causes issues in test infrastructure (which expects unsetenv to only +be called on variables which are already set). + +Signed-off-by: Stephen Kitt <steve@sk2.org> +--- + +diff --git a/binutils/testsuite/binutils-all/ar.exp b/binutils/testsuite/binutils-all/ar.exp +index d4e4f64b42e..998cbe1f0a9 100644 +--- a/binutils/testsuite/binutils-all/ar.exp ++++ b/binutils/testsuite/binutils-all/ar.exp +@@ -538,6 +538,7 @@ proc replacing_deterministic_member { } { + } + + # Test replacing a member of a non-deterministic archive. ++# This test expects SOURCE_DATE_EPOCH to not be set in the environment. + + proc replacing_non_deterministic_member { } { + global AR +@@ -581,7 +582,7 @@ proc replacing_non_deterministic_member { } { + + # Build the archive with the *newer* object file. + +- set got [binutils_run $AR "rc $archive ${newer_objfile}"] ++ set got [binutils_run $AR "rcU $archive ${newer_objfile}"] + if ![string match "" $got] { + fail "$testname: (could not build archive)" + return +@@ -589,7 +590,7 @@ proc replacing_non_deterministic_member { } { + + # Now try to replace the newer file with the older one. This should not work. + +- set got [binutils_run $AR "ru $archive $older_objfile"] ++ set got [binutils_run $AR "ruU $archive $older_objfile"] + if ![string match "" $got] { + fail "$testname: (failed to replace file)" + return +@@ -651,7 +652,7 @@ proc replacing_sde_deterministic_member { } { + # Build the archive with the *newer* object file. + setenv SOURCE_DATE_EPOCH "1000" + +- set got [binutils_run $AR "rc $archive ${newer_objfile}"] ++ set got [binutils_run $AR "rcU $archive ${newer_objfile}"] + if ![string match "" $got] { + fail "$testname: (could not build archive)" + unsetenv SOURCE_DATE_EPOCH +@@ -662,7 +663,7 @@ proc replacing_sde_deterministic_member { } { + # archive this will not work, but one created to be deterministic + # should always replace its members. + +- set got [binutils_run $AR "ru $archive $older_objfile"] ++ set got [binutils_run $AR "ruU $archive $older_objfile"] + if ![string match "" $got] { + fail "$testname: (failed to replace file)" + unsetenv SOURCE_DATE_EPOCH diff --git a/system/binutils/binutils-ld-fix-static-linking.patch b/system/binutils/binutils-ld-fix-static-linking.patch index bc5d76265..d1bbe41a4 100644 --- a/system/binutils/binutils-ld-fix-static-linking.patch +++ b/system/binutils/binutils-ld-fix-static-linking.patch @@ -3,7 +3,7 @@ diff --git a/ld/scripttempl/elf.sc b/ld/scripttempl/elf.sc index e8126cb..9532bfb 100644 --- a/ld/scripttempl/elf.sc +++ b/ld/scripttempl/elf.sc -@@ -235,8 +235,8 @@ test "${LARGE_SECTIONS}" = "yes" && LARGE_SECTIONS=" +@@ -269,8 +269,8 @@ test "${LARGE_SECTIONS}" = "yes" && LARGE_SECTIONS=" if test "${ENABLE_INITFINI_ARRAY}" = "yes"; then SORT_INIT_ARRAY="KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))" SORT_FINI_ARRAY="KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))" @@ -14,7 +14,7 @@ index e8126cb..9532bfb 100644 else SORT_INIT_ARRAY="KEEP (*(SORT(.init_array.*)))" SORT_FINI_ARRAY="KEEP (*(SORT(.fini_array.*)))" -@@ -270,15 +270,14 @@ CTOR=".ctors ${CONSTRUCTING-0} : +@@ -310,15 +310,14 @@ CTOR=".ctors ${CONSTRUCTING-0} : doesn't matter which directory crtbegin.o is in. */ @@ -32,7 +32,7 @@ index e8126cb..9532bfb 100644 KEEP (*(SORT(.ctors.*))) KEEP (*(.ctors)) ${CONSTRUCTING+${CTOR_END}} -@@ -286,9 +285,8 @@ CTOR=".ctors ${CONSTRUCTING-0} : +@@ -326,9 +325,8 @@ CTOR=".ctors ${CONSTRUCTING-0} : DTOR=".dtors ${CONSTRUCTING-0} : { ${CONSTRUCTING+${DTOR_START}} diff --git a/system/binutils/disable-gnu-mbind.patch b/system/binutils/disable-gnu-mbind.patch deleted file mode 100644 index 796e6d0fc..000000000 --- a/system/binutils/disable-gnu-mbind.patch +++ /dev/null @@ -1,32 +0,0 @@ -These tests do not work on PIE. Disable them. - ---- binutils-2.29/ld/testsuite/ld-elf/elf.exp.old 2017-08-19 22:39:31.236907813 +0000 -+++ binutils-2.29/ld/testsuite/ld-elf/elf.exp 2017-08-20 00:12:04.735925829 +0000 -@@ -296,27 +296,6 @@ - || [istarget *-*-nacl*] - || [istarget *-*-gnu*] } { - run_ld_link_exec_tests $array_tests_pie $xfails -- -- run_ld_link_exec_tests [list \ -- [list \ -- "Run mbind2a" \ -- "$NOPIE_LDFLAGS -Wl,-z,common-page-size=0x4000" \ -- "" \ -- { mbind2a.s mbind2b.c } \ -- "mbind2a" \ -- "pass.out" \ -- "-O2 -I../bfd" \ -- ] \ -- [list \ -- "Run mbind2b" \ -- "-static -Wl,-z,common-page-size=0x4000" \ -- "" \ -- { mbind2a.s mbind2b.c } \ -- "mbind2b" \ -- "pass.out" \ -- "-O2 -I../bfd" \ -- ] \ -- ] - } - - # <http://www.gnu.org/software/hurd/open_issues/binutils.html#static> diff --git a/system/binutils/disable-ifunc-tests.patch b/system/binutils/disable-ifunc-tests.patch index b50d20b0e..9f21a03fc 100644 --- a/system/binutils/disable-ifunc-tests.patch +++ b/system/binutils/disable-ifunc-tests.patch @@ -1,12 +1,11 @@ --- binutils-2.31.1/ld/testsuite/ld-ifunc/ifunc.exp.old 2018-06-27 07:55:16.000000000 +0000 +++ binutils-2.31.1/ld/testsuite/ld-ifunc/ifunc.exp 2018-10-12 03:23:09.240000000 +0000 -@@ -34,7 +34,8 @@ - && ([istarget "*-*-elf*"] - || [istarget "*-*-nacl*"] - || [istarget "*-*-linux*"] -- || [istarget "*-*-gnu*"])) } { -+ || [istarget "*-*-gnu*"]) -+ && ![istarget "*-*-musl*"]) } { +@@ -44,7 +44,8 @@ + || [istarget sh*-*-*] + || [istarget tic6x-*-*] + || [istarget tile*-*-*] ++ || [istarget *-*-musl*] + || [istarget vax-*-*] } { verbose "IFUNC tests not run - target does not support IFUNC" return } diff --git a/system/binutils/disable-mbind2b.patch b/system/binutils/disable-mbind2b.patch new file mode 100644 index 000000000..dee8690f1 --- /dev/null +++ b/system/binutils/disable-mbind2b.patch @@ -0,0 +1,20 @@ +XXX working upstream with musl, trying to push to other arches for testing + +--- binutils-2.41/ld/testsuite/ld-elf/elf.exp.old 2023-09-22 22:22:00.860304785 -0500 ++++ binutils-2.41/ld/testsuite/ld-elf/elf.exp 2023-09-22 23:43:12.163396014 -0500 +@@ -493,15 +493,6 @@ + "pass.out" \ + "-O2 -I../bfd" \ + ] \ +- [list \ +- "Run mbind2b" \ +- "-static -Wl,-z,common-page-size=0x4000 -Wl,-z,noexecstack" \ +- "" \ +- { mbind2a.s mbind2b.c } \ +- "mbind2b" \ +- "pass.out" \ +- "-O2 -I../bfd" \ +- ] \ + ] + } + diff --git a/system/binutils/disable-pr26580-test.patch b/system/binutils/disable-pr26580-test.patch new file mode 100644 index 000000000..681b8ec0c --- /dev/null +++ b/system/binutils/disable-pr26580-test.patch @@ -0,0 +1,20 @@ +For some reason, the output binary is over-aligned on x86_64. + +This test passes on all platforms but x86_64, so this (just barely) meets +Tier 1 standards for system/ packages. + +Not reported upstream. + +--- binutils-2.41/ld/testsuite/ld-elf/shared.exp.old 2023-09-30 00:31:20.814410396 -0500 ++++ binutils-2.41/ld/testsuite/ld-elf/shared.exp 2023-09-30 01:23:23.564443008 -0500 +@@ -1157,10 +1157,6 @@ + "" "" \ + {pr26580-a.c} "pr26580-3" "pr26580-3.out" "-fcommon" "c" "" \ + "-Wl,--as-needed tmpdir/libpr26580-2.so" ] \ +- [list "pr26580-4" \ +- "" "" \ +- {pr26580-a.c} "pr26580-4" "pr26580-4.out" "-fcommon" "c" "" \ +- "-Wl,--no-as-needed tmpdir/libpr26580-2.so" ] \ + [list "Run pr26590 (2)" \ + "" "" \ + {pr26590c.c pr26590d.c} "pr26590" "pass.out" "" "c" "" \ diff --git a/system/binutils/disable-preinit-array-tests.patch b/system/binutils/disable-preinit-array-tests.patch index f3d36c1b3..5693d4bbd 100644 --- a/system/binutils/disable-preinit-array-tests.patch +++ b/system/binutils/disable-preinit-array-tests.patch @@ -1,6 +1,6 @@ --- binutils-2.29/ld/testsuite/ld-elf/elf.exp.old 2017-07-04 08:43:21.000000000 +0000 +++ binutils-2.29/ld/testsuite/ld-elf/elf.exp 2017-08-19 04:46:32.214460537 +0000 -@@ -262,8 +262,6 @@ +@@ -392,8 +392,6 @@ } set array_tests { @@ -9,7 +9,7 @@ {"init array" "" "" {init.c} "init" "init.out"} {"fini array" "" "" -@@ -272,8 +270,6 @@ +@@ -402,8 +400,6 @@ {init-mixed.c} "init-mixed" "init-mixed.out" "-I."} } set array_tests_pie { @@ -18,7 +18,7 @@ {"PIE init array" "-pie" "" {init.c} "init" "init.out" "-fPIE"} {"PIE fini array" "-pie" "" -@@ -284,8 +280,6 @@ +@@ -414,8 +410,6 @@ {pr14525.c} "pr14525" "pr14525.out" "-fPIE"} } set array_tests_static { diff --git a/system/binutils/disable-relr-glibc-tests.patch b/system/binutils/disable-relr-glibc-tests.patch new file mode 100644 index 000000000..1edf30acb --- /dev/null +++ b/system/binutils/disable-relr-glibc-tests.patch @@ -0,0 +1,19 @@ +While musl does support DT_RELR, and other DT_RELR related tests *do* pass, +these glibc-specific tests do not because they require the linker to output +glibc-specific .version_info. + +Upstream-URL: https://sourceware.org/bugzilla/show_bug.cgi?id=30917 + +--- binutils-2.41/ld/testsuite/ld-elf/dt-relr.exp.old 2023-07-02 18:00:00.000000000 -0500 ++++ binutils-2.41/ld/testsuite/ld-elf/dt-relr.exp 2023-09-22 20:28:27.455427142 -0500 +@@ -27,6 +27,10 @@ + return + } + ++if { [istarget *-*-musl*] } { ++ return ++} ++ + run_cc_link_tests [list \ + [list \ + "Build dt-relr-glibc-1a.so" \ diff --git a/system/binutils/disable-sframe-tests.patch b/system/binutils/disable-sframe-tests.patch new file mode 100644 index 000000000..994349853 --- /dev/null +++ b/system/binutils/disable-sframe-tests.patch @@ -0,0 +1,17 @@ +SFrame tests fail due to incorrect PC offset in generated binary. + +Upstream-URL: https://sourceware.org/bugzilla/show_bug.cgi?id=30914 + +--- binutils-2.41/ld/testsuite/lib/ld-lib.exp.old 2023-07-02 18:00:00.000000000 -0500 ++++ binutils-2.41/ld/testsuite/lib/ld-lib.exp 2023-09-29 03:19:04.223613176 -0500 +@@ -1723,10 +1723,5 @@ + # if {$enable_libsframe eq "no"} { + # return 1 + # } +- +- if [check_as_sframe] { +- return 0 +- } +- + return 1 + } diff --git a/system/binutils/fix-deprecated-egrep-usage.patch b/system/binutils/fix-deprecated-egrep-usage.patch new file mode 100644 index 000000000..755068267 --- /dev/null +++ b/system/binutils/fix-deprecated-egrep-usage.patch @@ -0,0 +1,33 @@ +diff -ur a/config.rpath b/config.rpath +--- a/config.rpath 2023-04-06 08:16:36.067385369 -0500 ++++ b/config.rpath 2023-04-06 08:17:09.704066414 -0500 +@@ -143,7 +143,7 @@ + ld_shlibs=no + ;; + beos*) +- if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then ++ if $LD --help 2>&1 | grep -E ': supported targets:.* elf' > /dev/null; then + : + else + ld_shlibs=no +@@ -162,9 +162,9 @@ + netbsd*) + ;; + solaris* | sysv5*) +- if $LD -v 2>&1 | egrep 'BFD 2\.8' > /dev/null; then ++ if $LD -v 2>&1 | grep -E 'BFD 2\.8' > /dev/null; then + ld_shlibs=no +- elif $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then ++ elif $LD --help 2>&1 | grep -E ': supported targets:.* elf' > /dev/null; then + : + else + ld_shlibs=no +@@ -174,7 +174,7 @@ + hardcode_direct=yes + ;; + *) +- if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then ++ if $LD --help 2>&1 | grep -E ': supported targets:.* elf' > /dev/null; then + : + else + ld_shlibs=no diff --git a/system/binutils/libctf-32bit-test.patch b/system/binutils/libctf-32bit-test.patch new file mode 100644 index 000000000..788c46259 --- /dev/null +++ b/system/binutils/libctf-32bit-test.patch @@ -0,0 +1,27 @@ +We need to use the proper format specifiers. + +Upstream-Status: Pending +Upstream-URL: https://sourceware.org/bugzilla/show_bug.cgi?id=31882 + +--- binutils-2.41/libctf/testsuite/libctf-lookup/struct-iteration.c.old 2023-07-02 18:00:00.000000000 -0500 ++++ binutils-2.41/libctf/testsuite/libctf-lookup/struct-iteration.c 2024-06-11 16:22:32.976649333 -0500 +@@ -53,7 +53,7 @@ + { + char *type_name = ctf_type_aname (fp, membtype); + +- printf ("next test: %s, offset %lx, has type %lx/%s\n", ++ printf ("next test: %s, offset %zi, has type %lx/%s\n", + name, offset, membtype, type_name); + free (type_name); + } +--- binutils-2.41/libctf/testsuite/libctf-lookup/unnamed-field-info.c.old 2023-07-02 18:00:00.000000000 -0500 ++++ binutils-2.41/libctf/testsuite/libctf-lookup/unnamed-field-info.c 2024-06-11 16:23:19.191708550 -0500 +@@ -16,7 +16,7 @@ + goto err; + + if (mi.ctm_offset != offset * 8) +- fprintf (stderr, "field %s inconsistency: offsetof() says %zi bits, CTF says %zi\n", ++ fprintf (stderr, "field %s inconsistency: offsetof() says %zi bits, CTF says %li\n", + name, offset * 8, mi.ctm_offset); + + return; diff --git a/system/binutils/memory.patch b/system/binutils/memory.patch deleted file mode 100644 index f2cfea130..000000000 --- a/system/binutils/memory.patch +++ /dev/null @@ -1,449 +0,0 @@ -From 9999de060bbcc7cca9dce213deeeec6593887a8e Mon Sep 17 00:00:00 2001 -From: "H.J. Lu" <hjl.tools@gmail.com> -Date: Tue, 27 Feb 2018 12:22:58 -0800 -Subject: [PATCH] Limit memory size to half of address space - -When link_info.keep_memory is TRUE, linker caches the relocation -information and symbol tables of input files in memory. On 32-bit -hosts, linker runs out of 32-bit virtual memory on input files with many -relocations. This patch limits the allocated memory size to half of -the address space for 32-bit hosts. - -bfd/ - - PR ld/18028 - * bfd-in.h (_bfd_link_keep_memory): New. - * bfd-in2.h: Regenerated. - * bfd.c (bfd): Add alloc_size. - * elf-bfd.h (_bfd_elf_link_info_read_relocs): New. - * elf32-i386.c (elf_i386_check_relocs): Use _bfd_link_keep_memory. - Update cache_size. - * elf64-x86-64.c (elf_x86_64_check_relocs): Likewise. - * elflink.c (_bfd_elf_link_read_relocs): Renamed to ... - (_bfd_elf_link_info_read_relocs): This. Update cache_size. - (_bfd_elf_link_read_relocs): New. - (_bfd_elf_link_check_relocs): Call _bfd_elf_link_info_read_relocs - instead of _bfd_elf_link_read_relocs. - (elf_link_add_object_symbols): Likewise. - (elf_link_input_bfd): Likewise. - (init_reloc_cookie_rels): Likewise. - (init_reloc_cookie): Update cache_size. Call - _bfd_elf_link_info_read_relocs instead of - _bfd_elf_link_read_relocs. - (link_info_ok): New. - (elf_gc_smash_unused_vtentry_relocs): Updated. Call - _bfd_elf_link_info_read_relocs instead of - _bfd_elf_link_read_relocs. - (bfd_elf_gc_sections): Use link_info_ok. Pass &link_info_ok - to elf_gc_smash_unused_vtentry_relocs. - * linker.c (_bfd_link_keep_memory): New. - * opncls.c (bfd_alloc): Update alloc_size. - -include/ - - PR ld/18028 - * bfdlink.h (bfd_link_info): Add cache_size and max_alloc_size. - -ld/ - - PR ld/18028 - * ldmain.c: Include "bfd_stdint.h". - (main): Set link_info.max_alloc_size to half of the address space. ---- - bfd/bfd-in.h | 2 ++ - bfd/bfd-in2.h | 5 +++ - bfd/bfd.c | 3 ++ - bfd/elf-bfd.h | 3 ++ - bfd/elf32-i386.c | 3 +- - bfd/elf64-x86-64.c | 3 +- - bfd/elflink.c | 89 ++++++++++++++++++++++++++++++++++++++++-------------- - bfd/linker.c | 33 ++++++++++++++++++++ - bfd/opncls.c | 2 ++ - include/bfdlink.h | 7 +++++ - ld/ldmain.c | 3 ++ - 11 files changed, 128 insertions(+), 25 deletions(-) - -diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h -index a06cd740c0..ca4bec8aab 100644 ---- a/bfd/bfd-in.h -+++ b/bfd/bfd-in.h -@@ -600,6 +600,8 @@ struct bfd_section_already_linked; - struct bfd_elf_version_tree; - #endif - -+extern bfd_boolean _bfd_link_keep_memory (struct bfd_link_info *); -+ - extern bfd_boolean bfd_section_already_linked_table_init (void); - extern void bfd_section_already_linked_table_free (void); - extern bfd_boolean _bfd_handle_already_linked -diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h -index 9742c1ac7f..0794bcdcdb 100644 ---- a/bfd/bfd-in2.h -+++ b/bfd/bfd-in2.h -@@ -607,6 +607,8 @@ struct bfd_section_already_linked; - struct bfd_elf_version_tree; - #endif - -+extern bfd_boolean _bfd_link_keep_memory (struct bfd_link_info *); -+ - extern bfd_boolean bfd_section_already_linked_table_init (void); - extern void bfd_section_already_linked_table_free (void); - extern bfd_boolean _bfd_handle_already_linked -@@ -6989,6 +6991,9 @@ struct bfd - be used only for archive elements. */ - int archive_pass; - -+ /* The total size of memory from bfd_alloc. */ -+ bfd_size_type alloc_size; -+ - /* Stuff only useful for object files: - The start address. */ - bfd_vma start_address; -diff --git a/bfd/bfd.c b/bfd/bfd.c -index 288b5b14fe..182b544662 100644 ---- a/bfd/bfd.c -+++ b/bfd/bfd.c -@@ -267,6 +267,9 @@ CODE_FRAGMENT - . be used only for archive elements. *} - . int archive_pass; - . -+. {* The total size of memory from bfd_alloc. *} -+. bfd_size_type alloc_size; -+. - . {* Stuff only useful for object files: - . The start address. *} - . bfd_vma start_address; -diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h -index afd6982a92..37a7b07e51 100644 ---- a/bfd/elf-bfd.h -+++ b/bfd/elf-bfd.h -@@ -2294,6 +2294,9 @@ extern char *_bfd_elfcore_strndup - - extern Elf_Internal_Rela *_bfd_elf_link_read_relocs - (bfd *, asection *, void *, Elf_Internal_Rela *, bfd_boolean); -+extern Elf_Internal_Rela *_bfd_elf_link_info_read_relocs -+ (bfd *, struct bfd_link_info *, asection *, void *, Elf_Internal_Rela *, -+ bfd_boolean); - - extern bfd_boolean _bfd_elf_link_output_relocs - (bfd *, asection *, Elf_Internal_Shdr *, Elf_Internal_Rela *, -diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c -index 61a14097b0..9a781dc089 100644 ---- a/bfd/elf32-i386.c -+++ b/bfd/elf32-i386.c -@@ -1909,13 +1909,14 @@ elf_i386_check_relocs (bfd *abfd, - - if (elf_section_data (sec)->this_hdr.contents != contents) - { -- if (!converted && !info->keep_memory) -+ if (!converted && !_bfd_link_keep_memory (info)) - free (contents); - else - { - /* Cache the section contents for elf_link_input_bfd if any - load is converted or --no-keep-memory isn't used. */ - elf_section_data (sec)->this_hdr.contents = contents; -+ info->cache_size += sec->size; - } - } - -diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c -index 7016964ace..4ba15ec9fa 100644 ---- a/bfd/elf64-x86-64.c -+++ b/bfd/elf64-x86-64.c -@@ -2281,13 +2281,14 @@ elf_x86_64_check_relocs (bfd *abfd, struct bfd_link_info *info, - - if (elf_section_data (sec)->this_hdr.contents != contents) - { -- if (!converted && !info->keep_memory) -+ if (!converted && !_bfd_link_keep_memory (info)) - free (contents); - else - { - /* Cache the section contents for elf_link_input_bfd if any - load is converted or --no-keep-memory isn't used. */ - elf_section_data (sec)->this_hdr.contents = contents; -+ info->cache_size += sec->size; - } - } - -diff --git a/bfd/elflink.c b/bfd/elflink.c -index 092edaea26..831605b80a 100644 ---- a/bfd/elflink.c -+++ b/bfd/elflink.c -@@ -2475,14 +2475,16 @@ elf_link_read_relocs_from_section (bfd *abfd, - according to the KEEP_MEMORY argument. If O has two relocation - sections (both REL and RELA relocations), then the REL_HDR - relocations will appear first in INTERNAL_RELOCS, followed by the -- RELA_HDR relocations. */ -+ RELA_HDR relocations. If INFO isn't NULL and KEEP_MEMORY is TRUE, -+ update cache_size. */ - - Elf_Internal_Rela * --_bfd_elf_link_read_relocs (bfd *abfd, -- asection *o, -- void *external_relocs, -- Elf_Internal_Rela *internal_relocs, -- bfd_boolean keep_memory) -+_bfd_elf_link_info_read_relocs (bfd *abfd, -+ struct bfd_link_info *info, -+ asection *o, -+ void *external_relocs, -+ Elf_Internal_Rela *internal_relocs, -+ bfd_boolean keep_memory) - { - void *alloc1 = NULL; - Elf_Internal_Rela *alloc2 = NULL; -@@ -2502,7 +2504,11 @@ _bfd_elf_link_read_relocs (bfd *abfd, - - size = (bfd_size_type) o->reloc_count * sizeof (Elf_Internal_Rela); - if (keep_memory) -- internal_relocs = alloc2 = (Elf_Internal_Rela *) bfd_alloc (abfd, size); -+ { -+ internal_relocs = alloc2 = (Elf_Internal_Rela *) bfd_alloc (abfd, size); -+ if (info) -+ info->cache_size += size; -+ } - else - internal_relocs = alloc2 = (Elf_Internal_Rela *) bfd_malloc (size); - if (internal_relocs == NULL) -@@ -2568,6 +2574,22 @@ _bfd_elf_link_read_relocs (bfd *abfd, - return NULL; - } - -+/* This is similar to _bfd_elf_link_info_read_relocs, except for that -+ NULL is passed to _bfd_elf_link_info_read_relocs for pointer to -+ struct bfd_link_info. */ -+ -+Elf_Internal_Rela * -+_bfd_elf_link_read_relocs (bfd *abfd, -+ asection *o, -+ void *external_relocs, -+ Elf_Internal_Rela *internal_relocs, -+ bfd_boolean keep_memory) -+{ -+ return _bfd_elf_link_info_read_relocs (abfd, NULL, o, external_relocs, -+ internal_relocs, keep_memory); -+ -+} -+ - /* Compute the size of, and allocate space for, REL_HDR which is the - section header for a section containing relocations for O. */ - -@@ -3736,8 +3758,10 @@ _bfd_elf_link_check_relocs (bfd *abfd, struct bfd_link_info *info) - || bfd_is_abs_section (o->output_section)) - continue; - -- internal_relocs = _bfd_elf_link_read_relocs (abfd, o, NULL, NULL, -- info->keep_memory); -+ internal_relocs = _bfd_elf_link_info_read_relocs (abfd, info, -+ o, NULL, -+ NULL, -+ _bfd_link_keep_memory (info)); - if (internal_relocs == NULL) - return FALSE; - -@@ -4990,9 +5014,10 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info) - && (s->flags & SEC_DEBUGGING) != 0)) - continue; - -- internal_relocs = _bfd_elf_link_read_relocs (abfd, s, NULL, -- NULL, -- info->keep_memory); -+ internal_relocs = _bfd_elf_link_info_read_relocs (abfd, info, -+ s, NULL, -+ NULL, -+ _bfd_link_keep_memory (info)); - if (internal_relocs == NULL) - goto error_free_vers; - -@@ -10518,8 +10543,10 @@ elf_link_input_bfd (struct elf_final_link_info *flinfo, bfd *input_bfd) - - /* Get the swapped relocs. */ - internal_relocs -- = _bfd_elf_link_read_relocs (input_bfd, o, flinfo->external_relocs, -- flinfo->internal_relocs, FALSE); -+ = _bfd_elf_link_info_read_relocs (input_bfd, flinfo->info, o, -+ flinfo->external_relocs, -+ flinfo->internal_relocs, -+ FALSE); - if (internal_relocs == NULL - && o->reloc_count > 0) - return FALSE; -@@ -12684,8 +12711,12 @@ init_reloc_cookie (struct elf_reloc_cookie *cookie, - info->callbacks->einfo (_("%P%X: can not read symbols: %E\n")); - return FALSE; - } -- if (info->keep_memory) -- symtab_hdr->contents = (bfd_byte *) cookie->locsyms; -+ if (_bfd_link_keep_memory (info) ) -+ { -+ symtab_hdr->contents = (bfd_byte *) cookie->locsyms; -+ info->cache_size += (cookie->locsymcount -+ * sizeof (Elf_External_Sym_Shndx)); -+ } - } - return TRUE; - } -@@ -12718,8 +12749,9 @@ init_reloc_cookie_rels (struct elf_reloc_cookie *cookie, - } - else - { -- cookie->rels = _bfd_elf_link_read_relocs (abfd, sec, NULL, NULL, -- info->keep_memory); -+ cookie->rels = _bfd_elf_link_info_read_relocs (abfd, info, sec, -+ NULL, NULL, -+ _bfd_link_keep_memory (info)); - if (cookie->rels == NULL) - return FALSE; - cookie->rel = cookie->rels; -@@ -13233,14 +13265,21 @@ elf_gc_propagate_vtable_entries_used (struct elf_link_hash_entry *h, void *okp) - return TRUE; - } - -+struct link_info_ok -+{ -+ struct bfd_link_info *info; -+ bfd_boolean ok; -+}; -+ - static bfd_boolean --elf_gc_smash_unused_vtentry_relocs (struct elf_link_hash_entry *h, void *okp) -+elf_gc_smash_unused_vtentry_relocs (struct elf_link_hash_entry *h, void *ptr) - { - asection *sec; - bfd_vma hstart, hend; - Elf_Internal_Rela *relstart, *relend, *rel; - const struct elf_backend_data *bed; - unsigned int log_file_align; -+ struct link_info_ok *info = (struct link_info_ok *) ptr; - - /* Take care of both those symbols that do not describe vtables as - well as those that are not loaded. */ -@@ -13256,9 +13295,10 @@ elf_gc_smash_unused_vtentry_relocs (struct elf_link_hash_entry *h, void *okp) - hstart = h->root.u.def.value; - hend = hstart + h->size; - -- relstart = _bfd_elf_link_read_relocs (sec->owner, sec, NULL, NULL, TRUE); -+ relstart = _bfd_elf_link_info_read_relocs (sec->owner, info->info, -+ sec, NULL, NULL, TRUE); - if (!relstart) -- return *(bfd_boolean *) okp = FALSE; -+ return info->ok = FALSE; - bed = get_elf_backend_data (sec->owner); - log_file_align = bed->s->log_file_align; - -@@ -13379,6 +13419,7 @@ bfd_elf_gc_sections (bfd *abfd, struct bfd_link_info *info) - elf_gc_mark_hook_fn gc_mark_hook; - const struct elf_backend_data *bed = get_elf_backend_data (abfd); - struct elf_link_hash_table *htab; -+ struct link_info_ok info_ok; - - if (!bed->can_gc_sections - || !is_elf_hash_table (info->hash)) -@@ -13420,8 +13461,10 @@ bfd_elf_gc_sections (bfd *abfd, struct bfd_link_info *info) - return FALSE; - - /* Kill the vtable relocations that were not used. */ -- elf_link_hash_traverse (htab, elf_gc_smash_unused_vtentry_relocs, &ok); -- if (!ok) -+ info_ok.info = info; -+ info_ok.ok = TRUE; -+ elf_link_hash_traverse (htab, elf_gc_smash_unused_vtentry_relocs, &info_ok); -+ if (!info_ok.ok) - return FALSE; - - /* Mark dynamically referenced symbols. */ -diff --git a/bfd/linker.c b/bfd/linker.c -index c29a6e7e10..909d768552 100644 ---- a/bfd/linker.c -+++ b/bfd/linker.c -@@ -3471,3 +3471,36 @@ _bfd_nolink_bfd_define_start_stop (struct bfd_link_info *info ATTRIBUTE_UNUSED, - { - return (struct bfd_link_hash_entry *) _bfd_ptr_bfd_null_error (sec->owner); - } -+ -+bfd_boolean -+_bfd_link_keep_memory (struct bfd_link_info * info) -+{ -+ bfd *abfd; -+ bfd_size_type size; -+ -+ if (!info->keep_memory) -+ return FALSE; -+ -+ /* Keep allocated memory size below limit only for 32-bit hosts. */ -+ if (sizeof (void *) > 4) -+ return TRUE; -+ -+ abfd = info->input_bfds; -+ size = info->cache_size; -+ do -+ { -+ if (size >= info->max_alloc_size) -+ { -+ /* Over the limit. Reduce the memory usage. */ -+ info->keep_memory = FALSE; -+ return FALSE; -+ } -+ if (!abfd) -+ break; -+ size += abfd->alloc_size; -+ abfd = abfd->link.next; -+ } -+ while (1); -+ -+ return TRUE; -+} -diff --git a/bfd/opncls.c b/bfd/opncls.c -index 16b568c8ab..86262e1231 100644 ---- a/bfd/opncls.c -+++ b/bfd/opncls.c -@@ -949,6 +949,8 @@ bfd_alloc (bfd *abfd, bfd_size_type size) - ret = objalloc_alloc ((struct objalloc *) abfd->memory, ul_size); - if (ret == NULL) - bfd_set_error (bfd_error_no_memory); -+ else -+ abfd->alloc_size += size; - return ret; - } - -diff --git a/include/bfdlink.h b/include/bfdlink.h -index 5d637acbab..f06d5171c3 100644 ---- a/include/bfdlink.h -+++ b/include/bfdlink.h -@@ -635,6 +635,13 @@ struct bfd_link_info - - /* The version information. */ - struct bfd_elf_version_tree *version_info; -+ -+ /* Size of cache. Backend can use it to keep strace cache size. */ -+ bfd_size_type cache_size; -+ -+ /* The maximum size of allocated memory. Backend can use cache_size -+ and and max_alloc_size to decide if keep_memory should be honored. */ -+ bfd_size_type max_alloc_size; - }; - - /* This structures holds a set of callback functions. These are called -diff --git a/ld/ldmain.c b/ld/ldmain.c -index b6914db5da..14c3349c97 100644 ---- a/ld/ldmain.c -+++ b/ld/ldmain.c -@@ -21,6 +21,7 @@ - - #include "sysdep.h" - #include "bfd.h" -+#include "bfd_stdint.h" - #include "safe-ctype.h" - #include "libiberty.h" - #include "progress.h" -@@ -271,6 +272,8 @@ main (int argc, char **argv) - - link_info.allow_undefined_version = TRUE; - link_info.keep_memory = TRUE; -+ /* Limit the allocated memory size to half of the address space. */ -+ link_info.max_alloc_size = ((uintptr_t) (void *) -1) / 2; - link_info.combreloc = TRUE; - link_info.strip_discarded = TRUE; - link_info.emit_hash = DEFAULT_EMIT_SYSV_HASH; diff --git a/system/binutils/musl-preinit-array.patch b/system/binutils/musl-preinit-array.patch new file mode 100644 index 000000000..f06084658 --- /dev/null +++ b/system/binutils/musl-preinit-array.patch @@ -0,0 +1,35 @@ +musl libc currently does not run .preinit_array functions. + +--- binutils-2.41/ld/testsuite/ld-elf/elf.exp.old 2023-09-22 20:55:13.894385414 -0500 ++++ binutils-2.41/ld/testsuite/ld-elf/elf.exp 2023-09-22 21:31:13.354594152 -0500 +@@ -428,17 +428,21 @@ + run_ld_link_exec_tests $array_tests_pie $xfails + + if { $STATIC_PIE_LDFLAGS != "" } then { ++ if { ![istarget *-*-musl*] } then { ++ run_ld_link_exec_tests [list \ ++ [list \ ++ "Static PIE preinit array" \ ++ "$STATIC_PIE_LDFLAGS" \ ++ "" \ ++ {preinit.c} \ ++ "preinit-static-pie" \ ++ "preinit.out" \ ++ "-fPIE" \ ++ ] \ ++ ] ++ } + run_ld_link_exec_tests [list \ + [list \ +- "Static PIE preinit array" \ +- "$STATIC_PIE_LDFLAGS" \ +- "" \ +- {preinit.c} \ +- "preinit-static-pie" \ +- "preinit.out" \ +- "-fPIE" \ +- ] \ +- [list \ + "Static PIE init array" \ + "$STATIC_PIE_LDFLAGS" \ + "" \ diff --git a/system/binutils/musl-versioned-syms.patch b/system/binutils/musl-versioned-syms.patch new file mode 100644 index 000000000..ce7c9fb7d --- /dev/null +++ b/system/binutils/musl-versioned-syms.patch @@ -0,0 +1,19 @@ +This test will not work on musl which does not support symbol versioning. + +--- binutils-2.41/ld/testsuite/ld-elfvers/vers.exp.old 2023-07-02 18:00:00.000000000 -0500 ++++ binutils-2.41/ld/testsuite/ld-elfvers/vers.exp 2023-09-22 22:20:51.407688782 -0500 +@@ -890,8 +890,12 @@ + # Test that when we override a versioned symbol from the library this + # symbol appears in the dynamic symbol table of the executable. + # +-build_vers_lib_pic "vers16a" vers16a.c vers16a "" vers16.map vers16a.ver vers16a.dsym "" +-build_exec "vers16" vers16.c vers16 "-Wl,--no-as-needed" vers16a.so "" vers16.dsym "" ++if { [istarget *-*-musl*] } then { ++ xfail "vers16" ++} else { ++ build_vers_lib_pic "vers16a" vers16a.c vers16a "" vers16.map vers16a.ver vers16a.dsym "" ++ build_exec "vers16" vers16.c vers16 "-Wl,--no-as-needed" vers16a.so "" vers16.dsym "" ++} + + # Test a weak versioned symbol. + build_vers_lib_pic "vers17" vers17.c vers17 "" vers17.map vers17.ver vers17.dsym "" diff --git a/system/binutils/pr25749-test-size.patch b/system/binutils/pr25749-test-size.patch new file mode 100644 index 000000000..c5d4c46d9 --- /dev/null +++ b/system/binutils/pr25749-test-size.patch @@ -0,0 +1,26 @@ +Loading these libraries on musl appear to be affected by ASLR. + +The size has the entire address loaded, and we only want the size bytes. + +Not reported upstream. + +--- binutils-2.41/ld/testsuite/ld-elf/pr25749-1b.c.old 2023-07-02 18:00:00.000000000 -0500 ++++ binutils-2.41/ld/testsuite/ld-elf/pr25749-1b.c 2023-09-29 22:43:56.154343091 -0500 +@@ -5,5 +5,5 @@ + intptr_t + size (void) + { +- return (intptr_t) &_binary_pr25749_1_c_size; ++ return (intptr_t) &_binary_pr25749_1_c_size & 0xfff; + } +--- binutils-2.41/ld/testsuite/ld-elf/pr25749-2.c.old 2023-07-02 18:00:00.000000000 -0500 ++++ binutils-2.41/ld/testsuite/ld-elf/pr25749-2.c 2023-09-30 00:20:28.484403583 -0500 +@@ -6,7 +6,7 @@ + int + main () + { +- if (size == 289 /* size of this file */) ++ if ((size & 0xfff) == 299 /* size of this file */) + printf ("PASS\n"); + #ifdef __GLIBC_PREREQ + # if !__GLIBC_PREREQ (2, 28) diff --git a/system/binutils/remove-pr19553c-test.patch b/system/binutils/remove-pr19553c-test.patch index 7e5b76ab0..a536137b7 100644 --- a/system/binutils/remove-pr19553c-test.patch +++ b/system/binutils/remove-pr19553c-test.patch @@ -2,13 +2,13 @@ This test requires symbol versioning which the musl libc does not support. --- binutils-2.29/ld/testsuite/ld-elf/indirect.exp.old 2017-07-04 08:43:21.000000000 +0000 +++ binutils-2.29/ld/testsuite/ld-elf/indirect.exp 2017-08-19 05:00:13.086002872 +0000 -@@ -186,9 +186,6 @@ - {"Run with libpr19553b.so" - "-Wl,--no-as-needed tmpdir/libpr19553b.so tmpdir/libpr19553d.so -Wl,-rpath-link,." "" - {pr19553a.c} "pr19553b" "pr19553b.out"} -- {"Run with libpr19553c.so" -- "-Wl,--no-as-needed tmpdir/libpr19553c.so tmpdir/libpr19553b.so tmpdir/libpr19553d.so" "" -- {pr19553a.c} "pr19553c" "pr19553c.out"} - {"Run with libpr19553d.so" - "-Wl,--no-as-needed tmpdir/libpr19553d.so tmpdir/libpr19553b.so -Wl,-rpath-link,." "" - {pr19553a.c} "pr19553d" "pr19553d.out"} +@@ -190,9 +190,6 @@ + [list "Run with libpr19553b.so" \ + "-Wl,--no-as-needed tmpdir/libpr19553b.so tmpdir/libpr19553d.so -Wl,-rpath-link,." "" \ + {pr19553a.c} "pr19553b" "pr19553b.out"] \ +- [list "Run with libpr19553c.so" \ +- "-Wl,--no-as-needed tmpdir/libpr19553c.so tmpdir/libpr19553b.so tmpdir/libpr19553d.so" "" \ +- {pr19553a.c} "pr19553c" "pr19553c.out"] \ + [list "Run with libpr19553d.so" \ + "-Wl,--no-as-needed tmpdir/libpr19553d.so tmpdir/libpr19553b.so -Wl,-rpath-link,." "" \ + {pr19553a.c} "pr19553d" "pr19553d.out"] \ diff --git a/system/binutils/remove-pr19719-test.patch b/system/binutils/remove-pr19719-test.patch index 8fbc08db6..24f44479b 100644 --- a/system/binutils/remove-pr19719-test.patch +++ b/system/binutils/remove-pr19719-test.patch @@ -1,9 +1,9 @@ We always use -fPIE (it's in our spec file), so it isn't possible to test this. --- binutils-2.30/ld/testsuite/ld-elf/shared.exp.old 2018-05-25 06:28:07.252414401 +0000 +++ binutils-2.30/ld/testsuite/ld-elf/shared.exp 2018-05-25 06:51:50.637028357 +0000 -@@ -1102,5 +1102,4 @@ +@@ -1593,5 +1593,4 @@ } } --mix_pic_and_non_pic [list "arm*-*-*" "aarch64*-*-*"] "" "" "pr19719" +-mix_pic_and_non_pic [list "arm*-*-*"] "" "" "pr19719" mix_pic_and_non_pic [] "-fPIE" "-pie" "pr19719pie" diff --git a/system/binutils/remove-pr2404-tests.patch b/system/binutils/remove-pr2404-tests.patch index 9efdf5242..94ea63996 100644 --- a/system/binutils/remove-pr2404-tests.patch +++ b/system/binutils/remove-pr2404-tests.patch @@ -1,71 +1,91 @@ These tests fail to link correctly on musl. ---- binutils-2.29/ld/testsuite/ld-elf/shared.exp.old 2017-07-04 08:43:21.000000000 +0000 -+++ binutils-2.29/ld/testsuite/ld-elf/shared.exp 2017-08-19 04:59:05.319481464 +0000 -@@ -375,15 +375,6 @@ - {"Build needed3" - "tmpdir/needed3.o -Wl,--as-needed -Ltmpdir -lneeded3a -lneeded3b -lneeded1b" "" - {dummy.c} {} "needed3"} -- {"Build libpr2404a.so" -- "-shared" "-fPIC" -- {pr2404a.c} {} "libpr2404a.so"} -- {"Build libpr2404n.so" -- "-shared -Wl,-z,now" "-fPIC" -- {pr2404a.c} {} "libpr2404n.so"} -- {"Build libpr2404b.a" -- "" "" -- {pr2404b.c} {} "libpr2404b.a"} - {"Build rdynamic-1" - "-Wl,--no-dynamic-linker,-export-dynamic,--gc-sections" "-ffunction-sections" - {rdynamic-1.c} {{readelf {-s} rdynamic-1.rd}} "rdynamic-1"} -@@ -531,12 +522,6 @@ +--- binutils-2.41/ld/testsuite/ld-elf/shared.exp.old 2023-09-22 20:47:52.781342124 -0500 ++++ binutils-2.41/ld/testsuite/ld-elf/shared.exp 2023-09-22 20:54:03.151915244 -0500 +@@ -800,30 +800,6 @@ + + run_cc_link_tests [list \ + [list \ +- "Build libpr2404a.so" \ +- "-shared $NOSANITIZE_CFLAGS" \ +- "-fPIC $NOSANITIZE_CFLAGS" \ +- {pr2404a.c} \ +- {} \ +- "libpr2404a.so" \ +- ] \ +- [list \ +- "Build libpr2404n.so" \ +- "-shared -Wl,-z,now $NOSANITIZE_CFLAGS" \ +- "-fPIC $NOSANITIZE_CFLAGS" \ +- {pr2404a.c} \ +- {} \ +- "libpr2404n.so" \ +- ] \ +- [list \ +- "Build libpr2404b.a" \ +- "" \ +- "$NOSANITIZE_CFLAGS" \ +- {pr2404b.c} \ +- {} \ +- "libpr2404b.a" \ +- ] \ +- [list \ + "Build libpr26590a.so" \ + "-shared" \ + "-fPIC" \ +@@ -1133,17 +1107,6 @@ [list "Run relmain" \ "-Wl,--no-as-needed,-rpath=tmpdir -Ltmpdir -lrel" "" \ {relmain.c} "relmain" "relmain.out" ] \ - [list "Run pr2404" \ -- "-Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404a.so" "" \ -- {dummy.c} "pr2404" "pr2404.out" ] \ +- "$NOSANITIZE_CFLAGS -Wl,--no-as-needed \ +- tmpdir/pr2404b.o tmpdir/libpr2404a.so" \ +- "" \ +- {dummy.c} "pr2404" "pr2404.out" \ +- "$NOSANITIZE_CFLAGS" ] \ - [list "Run pr2404n" \ -- "-Wl,-z,now -Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404n.so" "" \ -- {dummy.c} "pr2404n" "pr2404.out" ] \ +- "$NOSANITIZE_CFLAGS -Wl,-z,now \ +- -Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404n.so" "" \ +- {dummy.c} "pr2404n" "pr2404.out" \ +- "$NOSANITIZE_CFLAGS" ] \ [list "Run pr18458" \ "-Wl,--no-as-needed,-z,now tmpdir/libpr18458a.so tmpdir/libpr18458b.so" "" \ {pr18458c.c} "pr18458" "pass.out" ] \ -@@ -675,14 +660,6 @@ +@@ -1338,14 +1303,6 @@ || [istarget *-*-gnu*] } { run_cc_link_tests [list \ [list \ - "Build libpr2404b.a with PIE" \ - "" \ -- "-fPIE" \ +- "-fPIE $NOSANITIZE_CFLAGS" \ - { pr2404b.c } \ - {} \ - "libpr2404b.a" \ - ] \ - [list \ "Build pr19579a.o" \ - "" "-fPIE" \ + "" "-fPIE -fcommon" \ {pr19579a.c} \ -@@ -717,24 +694,6 @@ +@@ -1425,24 +1382,6 @@ "-fPIE" \ ] \ [list \ - "Run pr2404 with PIE" \ -- "-pie -Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404a.so" \ +- "-pie $NOSANITIZE_CFLAGS -Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404a.so" \ - "" \ - { dummy.c } \ - "pr2404pie" \ - "pr2404.out" \ -- "-fPIE" \ +- "-fPIE $NOSANITIZE_CFLAGS" \ - ] \ - [list \ - "Run pr2404 with PIE (-z now)" \ -- "-pie -Wl,-z,now -Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404n.so" \ +- "-pie $NOSANITIZE_CFLAGS -Wl,-z,now -Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404n.so" \ - "" \ - { dummy.c } \ - "pr2404pien" \ - "pr2404.out" \ -- "-fPIE" \ +- "-fPIE $NOSANITIZE_CFLAGS" \ - ] \ - [list \ "Run pr18718" \ diff --git a/system/binutils/srec.patch b/system/binutils/srec.patch deleted file mode 100644 index ce3eac10b..000000000 --- a/system/binutils/srec.patch +++ /dev/null @@ -1,127 +0,0 @@ -X-Git-Url: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blobdiff_plain;f=bfd%2Fmerge.c;h=632c852390355829f95e149b7d72f0982a1a0b2b;hp=fb7c0858bebb27b5375564054c148b2b68124554;hb=ebd2263ba9a9124d93bbc0ece63d7e0fae89b40e;hpb=65d8004072ccb15441c143c380949d785a8446cd - -diff --git a/bfd/merge.c b/bfd/merge.c -index fb7c085..632c852 100644 ---- a/bfd/merge.c -+++ b/bfd/merge.c -@@ -621,7 +621,7 @@ is_suffix (const struct sec_merge_hash_entry *A, - - /* This is a helper function for _bfd_merge_sections. It attempts to - merge strings matching suffixes of longer strings. */ --static bfd_boolean -+static struct sec_merge_sec_info * - merge_strings (struct sec_merge_info *sinfo) - { - struct sec_merge_hash_entry **array, **a, *e; -@@ -633,7 +633,7 @@ merge_strings (struct sec_merge_info *sinfo) - amt = sinfo->htab->size * sizeof (struct sec_merge_hash_entry *); - array = (struct sec_merge_hash_entry **) bfd_malloc (amt); - if (array == NULL) -- return FALSE; -+ return NULL; - - for (e = sinfo->htab->first, a = array; e; e = e->next) - if (e->alignment) -@@ -703,11 +703,6 @@ merge_strings (struct sec_merge_info *sinfo) - } - } - secinfo->sec->size = size; -- if (secinfo->sec->alignment_power != 0) -- { -- bfd_size_type align = (bfd_size_type) 1 << secinfo->sec->alignment_power; -- secinfo->sec->size = (secinfo->sec->size + align - 1) & -align; -- } - - /* And now adjust the rest, removing them from the chain (but not hashtable) - at the same time. */ -@@ -724,7 +719,7 @@ merge_strings (struct sec_merge_info *sinfo) - e->u.index = e->u.suffix->u.index + (e->u.suffix->len - e->len); - } - } -- return TRUE; -+ return secinfo; - } - - /* This function is called once after all SEC_MERGE sections are registered -@@ -740,7 +735,8 @@ _bfd_merge_sections (bfd *abfd, - - for (sinfo = (struct sec_merge_info *) xsinfo; sinfo; sinfo = sinfo->next) - { -- struct sec_merge_sec_info * secinfo; -+ struct sec_merge_sec_info *secinfo; -+ bfd_size_type align; - - if (! sinfo->chain) - continue; -@@ -751,6 +747,7 @@ _bfd_merge_sections (bfd *abfd, - secinfo->next = NULL; - - /* Record the sections into the hash table. */ -+ align = 1; - for (secinfo = sinfo->chain; secinfo; secinfo = secinfo->next) - if (secinfo->sec->flags & SEC_EXCLUDE) - { -@@ -758,18 +755,25 @@ _bfd_merge_sections (bfd *abfd, - if (remove_hook) - (*remove_hook) (abfd, secinfo->sec); - } -- else if (! record_section (sinfo, secinfo)) -- return FALSE; -- -- if (secinfo) -- continue; -+ else -+ { -+ if (!record_section (sinfo, secinfo)) -+ return FALSE; -+ if (align) -+ { -+ align = (bfd_size_type) 1 << secinfo->sec->alignment_power; -+ if ((secinfo->sec->size & (align - 1)) != 0) -+ align = 0; -+ } -+ } - - if (sinfo->htab->first == NULL) - continue; - - if (sinfo->htab->strings) - { -- if (!merge_strings (sinfo)) -+ secinfo = merge_strings (sinfo); -+ if (!secinfo) - return FALSE; - } - else -@@ -789,8 +793,7 @@ _bfd_merge_sections (bfd *abfd, - e->secinfo->first_str = e; - size = 0; - } -- size = (size + e->alignment - 1) -- & ~((bfd_vma) e->alignment - 1); -+ size = (size + e->alignment - 1) & ~((bfd_vma) e->alignment - 1); - e->u.index = size; - size += e->len; - secinfo = e->secinfo; -@@ -798,11 +801,16 @@ _bfd_merge_sections (bfd *abfd, - secinfo->sec->size = size; - } - -- /* Finally remove all input sections which have not made it into -- the hash table at all. */ -- for (secinfo = sinfo->chain; secinfo; secinfo = secinfo->next) -- if (secinfo->first_str == NULL) -- secinfo->sec->flags |= SEC_EXCLUDE | SEC_KEEP; -+ /* If the input sections were padded according to their alignments, -+ then pad the output too. */ -+ if (align) -+ secinfo->sec->size = (secinfo->sec->size + align - 1) & -align; -+ -+ /* Finally remove all input sections which have not made it into -+ the hash table at all. */ -+ for (secinfo = sinfo->chain; secinfo; secinfo = secinfo->next) -+ if (secinfo->first_str == NULL) -+ secinfo->sec->flags |= SEC_EXCLUDE | SEC_KEEP; - } - - return TRUE; diff --git a/system/binutils/visibility-musl.patch b/system/binutils/visibility-musl.patch new file mode 100644 index 000000000..4b833ffd3 --- /dev/null +++ b/system/binutils/visibility-musl.patch @@ -0,0 +1,19 @@ +The tests need to know musl can support symbol visibility. + +Upstream-URL: https://sourceware.org/bugzilla/show_bug.cgi?id=30915 + +--- binutils-2.41/ld/testsuite/ld-vsb/main.c.old 2023-07-02 18:00:00.000000000 -0500 ++++ binutils-2.41/ld/testsuite/ld-vsb/main.c 2023-09-29 03:03:53.103603661 -0500 +@@ -5,9 +5,9 @@ + int + main (void) + { +-#if defined (__GLIBC__) && (__GLIBC__ > 2 \ +- || (__GLIBC__ == 2 \ +- && __GLIBC_MINOR__ >= 2)) ++#if !defined (__GLIBC__) || (__GLIBC__ > 2 \ ++ || (__GLIBC__ == 2 \ ++ && __GLIBC_MINOR__ >= 2)) + puts ("yes"); + #else + puts ("no"); diff --git a/system/binutils/vsb-hammer.patch b/system/binutils/vsb-hammer.patch new file mode 100644 index 000000000..72446276d --- /dev/null +++ b/system/binutils/vsb-hammer.patch @@ -0,0 +1,19 @@ +Disable protected visibility tests that are known to be "broken" / "a mess". + +Not reported upstream to binutils, as this is a musl thing. + +--- binutils-2.41/ld/testsuite/ld-vsb/vsb.exp.old 2023-07-02 23:00:00.000000000 +0000 ++++ binutils-2.41/ld/testsuite/ld-vsb/vsb.exp 2023-09-30 11:21:09.367314546 +0000 +@@ -519,12 +519,8 @@ + + visibility_run hidden + visibility_run hidden_normal +-visibility_run hidden_undef + visibility_run hidden_undef_def + visibility_run hidden_weak +-visibility_run protected +-visibility_run protected_undef +-visibility_run protected_undef_def + visibility_run protected_weak + visibility_run normal + diff --git a/system/binutils/x86_64-mark-plt.patch b/system/binutils/x86_64-mark-plt.patch new file mode 100644 index 000000000..29e1bd3bc --- /dev/null +++ b/system/binutils/x86_64-mark-plt.patch @@ -0,0 +1,37 @@ +From 6ef47613129c9251a5b8d5fa15ce6ea3ebe81ec1 Mon Sep 17 00:00:00 2001 +From: "H.J. Lu" <hjl.tools@gmail.com> +Date: Wed, 10 Jul 2024 15:19:23 -0700 +Subject: [PATCH] x86-64: Skip -z mark-plt tests on MUSL + +Skip -z mark-plt tests, which are specific to glibc, on MUSL. + + PR ld/31970 + * ld/testsuite/ld-x86-64/x86-64.exp: Skip -z mark-plt tests on + MUSL. + +Signed-off-by: H.J. Lu <hjl.tools@gmail.com> +--- + ld/testsuite/ld-x86-64/x86-64.exp | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp +index dddac4375e1..57a1cc44e2c 100644 +--- a/ld/testsuite/ld-x86-64/x86-64.exp ++++ b/ld/testsuite/ld-x86-64/x86-64.exp +@@ -2274,6 +2274,13 @@ run_dump_test "ibt-plt-3a-x32" + run_dump_test "ibt-plt-3b-x32" + run_dump_test "ibt-plt-3c-x32" + run_dump_test "ibt-plt-3d-x32" ++ ++# Skip -z mark-plt tests on MUSL. ++if { [istarget "x86_64-*-musl*"]} { ++ set ASFLAGS "$saved_ASFLAGS" ++ return ++} ++ + run_dump_test "mark-plt-1a" + run_dump_test "mark-plt-1b" + run_dump_test "mark-plt-1c" +-- +2.45.2 + diff --git a/system/binutils/x86_64-missing-test.patch b/system/binutils/x86_64-missing-test.patch new file mode 100644 index 000000000..e6544c1a1 --- /dev/null +++ b/system/binutils/x86_64-missing-test.patch @@ -0,0 +1,91 @@ +From: Indu Bhagat <indu.bhagat@oracle.com> +Date: Tue, 30 Jan 2024 08:35:04 +0000 (-0800) +Subject: gas: scfi: add missing ginsn-cofi-1 testcase files +X-Git-Url: https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff_plain;h=48942a586ebc056bd059d3f63a5eed3a2fa46ab3;hp=7586594c484bbc2a1fb472b988c7e9cbc08c8416 + +gas: scfi: add missing ginsn-cofi-1 testcase files + +Previous commit a58dc5427f0 intended to bring the following two commits +from master branch: + + 91cdbed4d7b gas: scfi: untraceable control flow should be a hard error + 16cbeae1b27 x86: testsuite: scfi: adjust COFI testcase + +But missed adding the testcase files. Fix the failure by adding the +missing files. + +gas/testsuite/ + * gas/scfi/x86_64/ginsn-cofi-1.l: New test. + * gas/scfi/x86_64/ginsn-cofi-1.s: Likewise. +--- + +diff --git a/gas/testsuite/gas/scfi/x86_64/ginsn-cofi-1.l b/gas/testsuite/gas/scfi/x86_64/ginsn-cofi-1.l +new file mode 100644 +index 00000000000..ab6b50d47e8 +--- /dev/null ++++ b/gas/testsuite/gas/scfi/x86_64/ginsn-cofi-1.l +@@ -0,0 +1,38 @@ ++.*: Assembler messages: ++.*:20: Error: untraceable control flow for func 'foo' ++GAS LISTING .* ++ ++ ++ 1 # Testcase with a variety of "change of flow instructions" ++ 2 # ++ 3 # This test does not have much going on wrt synthesis of CFI; ++ 4 # it just aims to ensure x8_64 -> ginsn decoding behaves ++ 5 # gracefully for these "change of flow instructions" ++ 6 .text ++ 7 .globl foo ++ 8 .type foo, @function ++ 8 ginsn: SYM FUNC_BEGIN ++ 9 foo: ++ 9 ginsn: SYM foo ++ 10 \?\?\?\? 4801D0 addq %rdx, %rax ++ 10 ginsn: ADD %r1, %r0, %r0 ++ 11 \?\?\?\? E200 loop foo ++ 11 ginsn: JCC ++ 12 \?\?\?\? 3EFFE0 notrack jmp \*%rax ++ 12 ginsn: JMP %r0, ++ 13 \?\?\?\? 41FFD0 call \*%r8 ++ 13 ginsn: CALL ++ 14 \?\?\?\? 67E305 jecxz .L179 ++ 14 ginsn: JCC ++ 15 \?\?\?\? FF6730 jmp \*48\(%rdi\) ++ 15 ginsn: JMP %r5, ++ 16 \?\?\?\? 7000 jo .L179 ++ 16 ginsn: JCC ++ 17 .L179: ++ 17 ginsn: SYM .L179 ++ 18 \?\?\?\? C3 ret ++ 18 ginsn: RET ++ 19 .LFE0: ++ 19 ginsn: SYM .LFE0 ++ 20 .size foo, .-foo ++ 20 ginsn: SYM FUNC_END +diff --git a/gas/testsuite/gas/scfi/x86_64/ginsn-cofi-1.s b/gas/testsuite/gas/scfi/x86_64/ginsn-cofi-1.s +new file mode 100644 +index 00000000000..0a63910e046 +--- /dev/null ++++ b/gas/testsuite/gas/scfi/x86_64/ginsn-cofi-1.s +@@ -0,0 +1,20 @@ ++# Testcase with a variety of "change of flow instructions" ++# ++# This test does not have much going on wrt synthesis of CFI; ++# it just aims to ensure x8_64 -> ginsn decoding behaves ++# gracefully for these "change of flow instructions" ++ .text ++ .globl foo ++ .type foo, @function ++foo: ++ addq %rdx, %rax ++ loop foo ++ notrack jmp *%rax ++ call *%r8 ++ jecxz .L179 ++ jmp *48(%rdi) ++ jo .L179 ++.L179: ++ ret ++.LFE0: ++ .size foo, .-foo |