[ELDK] ld.so.1 needed by libpthread.so.0 not found

Stefan Kolb Stefan.Kolb at avat.de
Wed Jul 30 11:01:31 CEST 2014


Hi,

back to the original topic. We had the same problem by trying to use ELDK
3.1.1 on Ubuntu 14.4 LTS and discovered the reason for the problem. 
The result of my analysis and possible solutions are given in the following.

To address the problem I compared the strace output of the command 
ppc_82xx-gcc  main.c
run on our old working system with the output on Ubuntu 14.4. The diff shows
that the path to the linker executable is wrongly generated on Ubuntu. The
path is generated by ppc_82xx-gcc in three steps. First of all the symbolic link
"/opt/eldk-3.1.1/usr/bin/../lib/gcc-lib/ppc-linux/3.3.3/../../../../ppc-linux/
bin/ld"
is resolved to
"../../bin/ppc-linux-ld"
via readlink. Afterwards "ld" is removed, from the path to the symbolic
link, and then
"../../bin/ppc-linux-ld"
is appended which leads to
"/opt/eldk-3.1.1/usr/bin/../lib/gcc-lib/ppc-linux/3.3.3/../../../../ppc-linux/
bin/../../bin/ppc-linux-ld".
In the last step the misbehaving function remove_relative_paths is used to
transform the generated relative path to an absolute one. This function uses
the strcpy function on overlapping source and destination strings, which is
not allowed. The manpage for strcpy points out:
... The strings may not overlap, and the destination string dest must be
large enough to receive the copy. ...

A simple implementation of the strcpy function like the one given in the
solution section below can handle overlapping strings but more sophisticated
optimized implementations not. The strcpy function is part of the libc
library, which is installed in different versions on the older working and the
new system. We found out that the implementation of strcpy changed from libc
version 2.13 (the version used on the system where the ELDK is working) to
version 2.15. Since version 2.15 strcpy is optimized by using SSE2 and SSSE3
instructions (http://upstream-tracker.org/changelogs/glibc/2.15/changelog.html).

The function remove_relative_paths was introduced to gcc by the patch
gcc-3.3.3-runtime-prefix.patch form the ELDK. The ELDK-3.1.1 sources for gcc
can for example be found at
"http://mirror.switch.ch/ftp/mirror/eldk/3.1.1/ppc-linux-x86/sources/SRPMS/
gcc-ppc-3.3.3-9.src.rpm".

Solution 1:
Downgrade the libc version to a version below 2.15. Note on a 64bit system
you have do downgrade the 32bit version of the library.

Solution 2:
Temporary replace the strcpy function of libc by preloading a library which
contains an unoptimized version of strcpy.

In the following we show an example of such an library. This example
constists of two files strcpy.c and Makefile.

-----------------------------------------
//strcpy.c
#include <stddef.h>

char * strcpy(char *dest, const char *src)
{
    size_t i;

    for (i = 0; src[i] != '\0'; i++)
    {
        dest[i] = src[i];
    }
    dest[i] = '\0';
    return dest;
}

-----------------------------------------
#Makefile
#To compile 32bit applications on a 64bit Ubuntu linux it is necessary to
install the package gcc-multilib

CC=gcc -m32
CFLAGS=-c -Wall -fPIC
SOURCES=strcpy.c
OBJECTS=$(SOURCES:.c=.o)
LIBRARY=libstrcpy.so.1

all: $(LIBRARY)
  
$(LIBRARY): $(OBJECTS) 
  $(CC) -shared -Wl,-soname,libstrcpy.so.1 -o libstrcpy.so.1.0.1 $<

.c.o:
  $(CC) $(CFLAGS) $< -o $@

-----------------------------------------

To test the library you can type something like

export LD_PRELOAD="/path/to/lib/libstrcpy.so.1.0.1"
ppc_82xx-gcc main.c 

into a terminal.

Best regards,

Stefan Kolb

AVAT Automation GmbH
Derendinger Strasse 40
72072 Tuebingen
Germany
phone +49 7071 9735-0 (front office)
fax +49 7071 9735-55

http://www.avat.de/
Location: Tuebingen
General Manager: Dipl.-Ing. Frank Ganssloser
Commercial Register Entry: AG Stuttgart HRB 381463




More information about the eldk mailing list