* [PATCH] PowerPC: incorrect library search order?
@ 2017-03-13 3:49 Alexey Neyman
2017-03-13 9:05 ` Alan Modra
2017-03-13 9:20 ` Andreas Schwab
0 siblings, 2 replies; 4+ messages in thread
From: Alexey Neyman @ 2017-03-13 3:49 UTC (permalink / raw)
To: binutils
[-- Attachment #1: Type: text/plain, Size: 1699 bytes --]
Hi,
The problem below resulted in failures of some PowerPC sample toolchains
in crosstool-ng.
As far as I understand, the code in ld/emulparams/elf32ppccommon.sh
attempts to use /lib32 or /lib64 if the endianness of the selected
emulation matches the endianness of the machine, and use the directories
with explicit endianness (such as /lib32le, /lib32be, /lib64le,
/lib64be) otherwise. However, there are two issues with that code:
First, it checks for *host's* triplet, not target. The host may not be
using 'le' suffix to designate its endianness - for example, it may be
little-endian by default. It also doesn't seem to make much sense to
check the host for default layout - why would the expected sysroot
layout on a big-endian host differ from that on a little-endian host?
Second, the check itself is flawed: it should be checking just the CPU
part of the triplet, not the whole string. In its current form, the
check compares $host against "*le-*" pattern - which matches
"x86_64-apple-darwin16.0".
This results in ld configured for powerpc64le-unknown-linux target on
x86_64-unknown-linux host behaving as follows:
- without -m, or with -melf64lppc it searches /lib64le first
- with '-melf64ppc' it searches /lib64 first - which seems to run
counter to the intended purpose of that code, as the target is
configured as little-endian!
'ld' works ok with libraries in /lib (which is always searched as the
last fallback, regardless of the host and selected emulation). Once the
libraries are placed in /lib64 (default gcc's directory for this
target), ld fails to find them.
This erroneous code first appeared in binutils 2.24.
Patch attached.
Regards,
Alexey.
[-- Attachment #2: 0001-Fix-library-paths-on-PowerPC.patch --]
[-- Type: text/x-patch, Size: 1549 bytes --]
From cf2cf4ea661b8527d0fe48a9ffda1b02154d0c67 Mon Sep 17 00:00:00 2001
From: Alexey Neyman <stilor@att.net>
Date: Sat, 11 Mar 2017 17:27:09 -0800
Subject: [PATCH] Fix library paths on PowerPC
First, need to match against just the CPU name, not the whole triplet.
Otherwise, the test picks up "*le-*" pattern from x86_64-apple-darwin
triplet.
Second, it should be testing for $target, not $host. Host may be
little endian by default, and the sysroot directory layout shouldn't
depend on whether it is built on LE or BE machine.
Signed-off-by: Alexey Neyman <stilor@att.net>
---
ld/emulparams/elf32ppccommon.sh | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/ld/emulparams/elf32ppccommon.sh b/ld/emulparams/elf32ppccommon.sh
index 1f54ef8..d00cf68 100644
--- a/ld/emulparams/elf32ppccommon.sh
+++ b/ld/emulparams/elf32ppccommon.sh
@@ -44,11 +44,11 @@ fi
# Look for 64 bit target libraries in /lib64, /usr/lib64 etc., first.
# Similarly, look for 32 bit libraries in /lib32, /usr/lib32 etc.
-case "$host":"$EMULATION_NAME" in
- *le-*:*64lppc*) LIBPATH_SUFFIX=64 ;;
- *le-*:*32lppc*) LIBPATH_SUFFIX=32 ;;
- *le-*:*64*) LIBPATH_SUFFIX=64be ;;
- *le-*:*32*) LIBPATH_SUFFIX=32be ;;
+case `echo "$target" | sed -e 's/-.*//'`:"$EMULATION_NAME" in
+ *le:*64lppc*) LIBPATH_SUFFIX=64 ;;
+ *le:*32lppc*) LIBPATH_SUFFIX=32 ;;
+ *le:*64*) LIBPATH_SUFFIX=64be ;;
+ *le:*32*) LIBPATH_SUFFIX=32be ;;
*:*64lppc*) LIBPATH_SUFFIX=64le ;;
*:*32lppc*) LIBPATH_SUFFIX=32le ;;
*:*64*) LIBPATH_SUFFIX=64 ;;
--
2.9.3
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] PowerPC: incorrect library search order?
2017-03-13 3:49 [PATCH] PowerPC: incorrect library search order? Alexey Neyman
@ 2017-03-13 9:05 ` Alan Modra
2017-03-13 9:20 ` Andreas Schwab
1 sibling, 0 replies; 4+ messages in thread
From: Alan Modra @ 2017-03-13 9:05 UTC (permalink / raw)
To: Alexey Neyman; +Cc: binutils
On Sun, Mar 12, 2017 at 08:49:46PM -0700, Alexey Neyman wrote:
> First, need to match against just the CPU name, not the whole triplet.
> Otherwise, the test picks up "*le-*" pattern from x86_64-apple-darwin
> triplet.
I wonder how many more of these are lurking. I fixed some with
4811ccb48.
> Second, it should be testing for $target, not $host. Host may be
> little endian by default, and the sysroot directory layout shouldn't
> depend on whether it is built on LE or BE machine.
Thanks. Applied with this changelog.
2017-03-13 Alexey Neyman <stilor@att.net>
* emulparams/elf32ppccommon.sh (LIBPATH_SUFFIX): Set from target
cpu, not host.
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] PowerPC: incorrect library search order?
2017-03-13 3:49 [PATCH] PowerPC: incorrect library search order? Alexey Neyman
2017-03-13 9:05 ` Alan Modra
@ 2017-03-13 9:20 ` Andreas Schwab
2017-03-13 11:25 ` Alan Modra
1 sibling, 1 reply; 4+ messages in thread
From: Andreas Schwab @ 2017-03-13 9:20 UTC (permalink / raw)
To: Alexey Neyman; +Cc: binutils
On Mär 12 2017, Alexey Neyman <stilor@att.net> wrote:
> diff --git a/ld/emulparams/elf32ppccommon.sh b/ld/emulparams/elf32ppccommon.sh
> index 1f54ef8..d00cf68 100644
> --- a/ld/emulparams/elf32ppccommon.sh
> +++ b/ld/emulparams/elf32ppccommon.sh
> @@ -44,11 +44,11 @@ fi
>
> # Look for 64 bit target libraries in /lib64, /usr/lib64 etc., first.
> # Similarly, look for 32 bit libraries in /lib32, /usr/lib32 etc.
> -case "$host":"$EMULATION_NAME" in
> - *le-*:*64lppc*) LIBPATH_SUFFIX=64 ;;
> - *le-*:*32lppc*) LIBPATH_SUFFIX=32 ;;
> - *le-*:*64*) LIBPATH_SUFFIX=64be ;;
> - *le-*:*32*) LIBPATH_SUFFIX=32be ;;
> +case `echo "$target" | sed -e 's/-.*//'`:"$EMULATION_NAME" in
That's $target_cpu.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] PowerPC: incorrect library search order?
2017-03-13 9:20 ` Andreas Schwab
@ 2017-03-13 11:25 ` Alan Modra
0 siblings, 0 replies; 4+ messages in thread
From: Alan Modra @ 2017-03-13 11:25 UTC (permalink / raw)
To: Andreas Schwab; +Cc: Alexey Neyman, binutils
On Mon, Mar 13, 2017 at 10:20:40AM +0100, Andreas Schwab wrote:
> On Mär 12 2017, Alexey Neyman <stilor@att.net> wrote:
> > +case `echo "$target" | sed -e 's/-.*//'`:"$EMULATION_NAME" in
>
> That's $target_cpu.
So it is, but target_cpu isn't passed to genscripts.sh.
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-03-13 11:25 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-13 3:49 [PATCH] PowerPC: incorrect library search order? Alexey Neyman
2017-03-13 9:05 ` Alan Modra
2017-03-13 9:20 ` Andreas Schwab
2017-03-13 11:25 ` Alan Modra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).