summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Le Cuirot <chewi@gentoo.org>2024-08-05 23:20:23 +0100
committerJames Le Cuirot <chewi@gentoo.org>2024-08-05 23:20:23 +0100
commit5f9b32f028a31e544134077f5a3b6bd3d8c4230c (patch)
tree5c4229e4b9a110fc7d07128318554c876de004e8 /sys-devel
parentapp-misc/jaq: add 1.6.0 (diff)
downloadgentoo-5f9b32f028a31e544134077f5a3b6bd3d8c4230c.tar.gz
gentoo-5f9b32f028a31e544134077f5a3b6bd3d8c4230c.tar.bz2
gentoo-5f9b32f028a31e544134077f5a3b6bd3d8c4230c.zip
sys-devel/binutils: Rebase cross/prefix linker patches for 2.43
Closes: https://bugs.gentoo.org/937381 Signed-off-by: James Le Cuirot <chewi@gentoo.org>
Diffstat (limited to 'sys-devel')
-rw-r--r--sys-devel/binutils/binutils-2.43.ebuild4
-rw-r--r--sys-devel/binutils/binutils-9999.ebuild4
-rw-r--r--sys-devel/binutils/files/binutils-2.43-linker-prefix.patch53
-rw-r--r--sys-devel/binutils/files/binutils-2.43-linker-search-path.patch43
4 files changed, 100 insertions, 4 deletions
diff --git a/sys-devel/binutils/binutils-2.43.ebuild b/sys-devel/binutils/binutils-2.43.ebuild
index a3e7c641ce6b..9407ec3c37ef 100644
--- a/sys-devel/binutils/binutils-2.43.ebuild
+++ b/sys-devel/binutils/binutils-2.43.ebuild
@@ -131,8 +131,8 @@ src_prepare() {
# This is applied conditionally for now just out of caution.
# It should be okay on non-prefix systems though. See bug #892549.
if is_cross || use prefix; then
- eapply "${FILESDIR}"/binutils-2.40-linker-search-path.patch \
- "${FILESDIR}"/binutils-2.41-linker-prefix.patch
+ eapply "${FILESDIR}"/binutils-2.43-linker-search-path.patch \
+ "${FILESDIR}"/binutils-2.43-linker-prefix.patch
fi
fi
fi
diff --git a/sys-devel/binutils/binutils-9999.ebuild b/sys-devel/binutils/binutils-9999.ebuild
index c05f1529d8c1..44bb4c8c3e76 100644
--- a/sys-devel/binutils/binutils-9999.ebuild
+++ b/sys-devel/binutils/binutils-9999.ebuild
@@ -131,8 +131,8 @@ src_prepare() {
# This is applied conditionally for now just out of caution.
# It should be okay on non-prefix systems though. See bug #892549.
if is_cross || use prefix; then
- eapply "${FILESDIR}"/binutils-2.40-linker-search-path.patch \
- "${FILESDIR}"/binutils-2.41-linker-prefix.patch
+ eapply "${FILESDIR}"/binutils-2.43-linker-search-path.patch \
+ "${FILESDIR}"/binutils-2.43-linker-prefix.patch
fi
fi
fi
diff --git a/sys-devel/binutils/files/binutils-2.43-linker-prefix.patch b/sys-devel/binutils/files/binutils-2.43-linker-prefix.patch
new file mode 100644
index 000000000000..79b30657014b
--- /dev/null
+++ b/sys-devel/binutils/files/binutils-2.43-linker-prefix.patch
@@ -0,0 +1,53 @@
+https://bugs.gentoo.org/892549
+https://github.com/gentoo/binutils-gdb/pull/5
+
+From 302271b0baa52204fab58bd0b74e3919c0789f87 Mon Sep 17 00:00:00 2001
+From: James Le Cuirot <chewi@gentoo.org>
+Date: Sat, 23 Dec 2023 13:48:10 +0000
+Subject: [PATCH] ld: Allow a Gentoo-specific prefix to override the prefix
+ used by ld.bfd
+
+This prefix is only used to locate $prefix/etc/ld.so.conf, with $prefix
+usually being /usr. This file is important on Gentoo Prefix systems,
+where the /usr prefix is within another directory. The problem is that
+Gentoo already passes the same directory as the sysroot, and ld.bfd
+therefore looks for /myprefix/myprefix/usr/etc/ld.so.conf.
+
+The sysroot is dynamic, while the prefix is hardcoded. A hardcoded
+prefix that isn't just /usr is unhelpful, not just because of the
+doubled prefix issue above, but also because it prevents ld.bfd from
+working effectively outside its native environment. We will therefore
+hardcode it to just /usr.
+
+This change does not simply do that though and sets up a $gentoo_prefix
+variable instead, with $prefix as a fallback. This is necessary because
+Gentoo prefix-guest systems, which use the host's libc, do not apply a
+sysroot like RAP prefix systems do. In that case, we must preserve the
+existing behaviour. The binutils ebuild will be responsible for setting
+this variable appropriately.
+---
+ ld/emultempl/elf.em | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/ld/emultempl/elf.em b/ld/emultempl/elf.em
+index 863657e12f5..cf0204e9c76 100644
+--- a/ld/emultempl/elf.em
++++ b/ld/emultempl/elf.em
+@@ -142,7 +142,7 @@ gld${EMULATION_NAME}_before_plugin_all_symbols_read (void)
+ ldelf_before_plugin_all_symbols_read ($IS_LIBPATH, $IS_NATIVE,
+ $IS_LINUX_TARGET,
+ $IS_FREEBSD_TARGET,
+- $ELFSIZE, "$prefix");
++ $ELFSIZE, "${gentoo_prefix-${prefix}}");
+ }
+
+ /* This is called after all the input files have been opened. */
+@@ -151,7 +151,7 @@ static void
+ gld${EMULATION_NAME}_after_open (void)
+ {
+ ldelf_after_open ($IS_LIBPATH, $IS_NATIVE,
+- $IS_LINUX_TARGET, $IS_FREEBSD_TARGET, $ELFSIZE, "$prefix");
++ $IS_LINUX_TARGET, $IS_FREEBSD_TARGET, $ELFSIZE, "${gentoo_prefix-${prefix}}");
+ }
+
+ EOF
diff --git a/sys-devel/binutils/files/binutils-2.43-linker-search-path.patch b/sys-devel/binutils/files/binutils-2.43-linker-search-path.patch
new file mode 100644
index 000000000000..1dcb5e68702d
--- /dev/null
+++ b/sys-devel/binutils/files/binutils-2.43-linker-search-path.patch
@@ -0,0 +1,43 @@
+https://bugs.gentoo.org/892549
+https://github.com/gentoo/binutils-gdb/pull/5
+
+From 470487917306e169fc3ca983c2edf2370b211861 Mon Sep 17 00:00:00 2001
+From: James Le Cuirot <chewi@gentoo.org>
+Date: Sat, 11 Feb 2023 15:15:20 +0000
+Subject: [PATCH] ldelf.c: Always consider -L arguments when handling DT_NEEDED
+
+This is for consistency with other linkers, including gold. Without
+this, we typically rely on ld.so.conf to find libraries such as
+libstdc++.so.6, while other linkers do not use this file at all.
+---
+ ld/ldelf.c | 10 +++-------
+ 1 file changed, 3 insertions(+), 7 deletions(-)
+
+diff --git a/ld/ldelf.c b/ld/ldelf.c
+index 09691609fc0..11edff8c8ec 100644
+--- a/ld/ldelf.c
++++ b/ld/ldelf.c
+@@ -1093,8 +1093,8 @@ ldelf_handle_dt_needed (struct elf_link_hash_table *htab,
+ linker will search. That means that we want to use
+ rpath_link, rpath, then the environment variable
+ LD_LIBRARY_PATH (native only), then the DT_RPATH/DT_RUNPATH
+- entries (native only), then the linker script LIB_SEARCH_DIRS.
+- We do not search using the -L arguments.
++ entries (native only), then the linker script LIB_SEARCH_DIRS,
++ then the -L arguments.
+
+ We search twice. The first time, we skip objects which may
+ introduce version mismatches. The second time, we force
+@@ -1168,11 +1168,7 @@ ldelf_handle_dt_needed (struct elf_link_hash_table *htab,
+ len = strlen (l->name);
+ for (search = search_head; search != NULL; search = search->next)
+ {
+- char *filename;
+-
+- if (search->source != search_dir_linker_script)
+- continue;
+- filename = (char *) xmalloc (strlen (search->name) + len + 2);
++ char *filename = (char *) xmalloc (strlen (search->name) + len + 2);
+ sprintf (filename, "%s/%s", search->name, l->name);
+ nn.name = filename;
+ if (ldelf_try_needed (&nn, force, is_linux))