Help.....Embedded Linux uClibc, unable to run shared executables.
Linux - MobileThis forum is for the discussion of all topics relating to Mobile Linux. This includes Android, Tizen, Sailfish OS, Replicant, Ubuntu Touch, webOS, and other similar projects and products.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Help.....Embedded Linux uClibc, unable to run shared executables.
We have been using an embedded glibc toolchain for sometime. I recently bootstrapped an toolchain using uClibc (gcc-4.2.4, binutils-2.18, uClibc-0.29). The target is a broadcom chip which has a mips core it is strapped little-endian (mipsel).
All the libs are in /lib include the important ld-xxx
##################################################################################
# 1. Set up kernel headers, now using the headers_check with ARCH.
#
config-kernel-headers:
$(MAKE) -C $(TOP)/kernel config-kernel
build-gdb:
@echo "Building gdb"
PATH="$(PATH)"; export PATH; \
cd $(BUILD_DIR)/gdb && \
make
install-gdb:
@echo "Installing gdb"
PATH="$(PATH)"; export PATH; \
cd $(BUILD_DIR)/gdb && \
make install
#
#
##################################################################################
##################################################################################
# 8. This is for building a MIPS NATIVE version of the debugger can only be build
# AFTER libs dir is built (for ncurses) could even put this in "utils"
# makefile... This runs too slow on Mediaportal/Mediapoint to be pratical
#
config-gdbnative:
@echo "Configuring gdb native"
rm -rf $(BUILD_DIR)/gdbnative
mkdir -p $(BUILD_DIR)/gdbnative
PATH="$(PATH)"; export PATH; \
export bash_cv_have_mbstate_t=yes; \
export LDFLAGS="-L$(ULIB_DIR)/lib"; \
export CFLAGS="-I$(ULIB_DIR)/include"; \
cd $(BUILD_DIR)/gdbnative && \
$(GDB_DIR)/configure \
--prefix=$(ULIB_DIR) \
--host=$(TARGET) \
--target=$(TARGET) \
--build=$(HOST)
##################################################################################
# 9. gdbserver is a debug stub that runs on target machine. This does not work
# so well, but is slowly getting better as mips support in glibc gets better.
# I don't know about uClibc.
#
config-gdbserver:
@echo "Configuring gdbserver"
rm -rf $(BUILD_DIR)/gdbserver
mkdir -p $(BUILD_DIR)/gdbserver
PATH="$(PATH):$(PREFIX)/bin"; export PATH; \
cd $(BUILD_DIR)/gdbserver && \
CC=$(CROSS_COMPILE)gcc \
LD_FOR_TARGET=$(CROSS_COMPILE)ld \
$(GDB_DIR)/gdb/gdbserver/configure \
--prefix=$(SYSROOT)/bin \
--host=$(TARGET) \
--target=$(TARGET) \
--with-sysroot=$(SYSROOT)
build-gdbserver:
@echo "Building gdbserver"
PATH="$(PATH)"; export PATH; \
cd $(BUILD_DIR)/gdbserver && \
make
# make LDFLAGS=-static
install-gdbserver:
@echo "Installing gdbserver"
PATH="$(PATH)"; export PATH; \
cd $(BUILD_DIR)/gdbserver && \
make install
#
#
##################################################################################
statically linking strace, looks as if the executable cannot be found even though the file can be found.
[root@2WireBlockBuster /bin]# ./strace mount
execve("/bin/mount", ["mount"], [/* 14 vars */]) = -1 ENOENT (No such file or directory)
write(2, "strace: exec: No such file or dir"..., 40strace: exec: No such file or directory
) = 40
exit_group(1) = ?
statically linking strace, looks as if the executable cannot be found even though the file can be found.
[root@2WireBlockBuster /bin]# ./strace mount
execve("/bin/mount", ["mount"], [/* 14 vars */]) = -1 ENOENT (No such file or directory)
write(2, "strace: exec: No such file or dir"..., 40strace: exec: No such file or directory
) = 40
exit_group(1) = ?
Good point, I forgot, I still got a similar result. Something weird about the filesystem. I can run scripts, just not dynamically linked executable. I had to link busybox statically just to get the box up.
[root@2WireBlockBuster /bin]# ./strace ./mount
execve("./mount", ["./mount"], [/* 14 vars */]) = -1 ENOENT (No such file or directory)
write(2, "strace: exec: No such file or dir"..., 40strace: exec: No such file or directory
) = 40
exit_group(1) = ?
[root@2WireBlockBuster /bin]#
Another executable. We have the real lsmod since we are using busybox 1.00 and its module utils don't support 2.6. I did try a newer busybox, but had the same problem anyway.
[root@2WireBlockBuster /bin]# ./strace ./lsmod
execve("./lsmod", ["./lsmod"], [/* 14 vars */]) = -1 ENOENT (No such file or directory)
write(2, "strace: exec: No such file or dir"..., 40strace: exec: No such file or directory
) = 40
Doing an strace on a statically linked executable shows that strace works:
The problem starts early due to the fact that mount can't be found (I am using the linux-utils mount instead of busybox) when Linux cannot mount its "special" filesystems.
Sending DHCP requests ., OK
IP-Config: Got DHCP answer from 10.5.255.254, my address is 10.5.252.165
IP-Config: Complete:
device=eth0, addr=10.5.252.165, mask=255.255.0.0, gw=10.5.0.1,
host=10.5.252.165, domain=2wire.com, nis-domain=(none),
bootserver=10.5.255.254, rootserver=10.5.251.61, rootpath=
Looking up port of RPC 100003/3 on 10.5.251.61
Looking up port of RPC 100005/3 on 10.5.251.61
VFS: Mounted root (nfs filesystem).
Freeing unused kernel memory: 160k freed
init started: BusyBox v1.00 (2000.01.01-00:00+0000) multi-call binary
Starting pid 38, console /dev/ttyS0: '/etc/init.d/rcS'
Mounting proc filesystem.
/etc/init.d/rcS: 16: mount: not found
Mounting /var.../etc/init.d/rcS: 25: mount: not found
failed!
/etc/init.d/rcS: 47: cannot create /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts: Directory nonexistent
Mounting all special filesystems.
/etc/init.d/rcS: 51: mount: not found
/etc/init.d/rcS: 52: mount: not found
/etc/init.d/rcS: 53: mount: not found
/etc/init.d/rcS: 54: mount: not found
/etc/init.d/rcS: 57: depmod: not found
Loading modules:
bcmdriver - /etc/init.d/rcS: 72: insmod: not found
Setting hostname.
Mounting /etc/config as JFFS2.../etc/init.d/rcS: 103: /bin/mount: not found
=> Creating config filesystem
/etc/init.d/rcS: 103: /bin/flash_eraseall: not found
/etc/init.d/rcS: 103: /bin/mount: not found
Config filesystem created successfully.
Factory reset detected
Starting pid 73, console /dev/ttyS0: '/etc/init.d/rc'
Configuring and Starting Network...done.
Starting Network Interface Plugging Daemon:/etc/rc2.d/S10ifplugd: 65: /sbin/ifplugd: not found
eth0.
Starting system log daemon: syslogdstart-stop-daemon: unable to start /sbin/syslogd: No such file or directory
klogdstart-stop-daemon: unable to start /sbin/klogd: No such file or directory
.
Starting NFS client daemons: portmapstart-stop-daemon: nothing in /proc - not mounted?
rpc.statdstart-stop-daemon: nothing in /proc - not mounted?
.
Starting Telnet Server: telnetd.
I figured it out. The interpreter path was incorrect. I patched gcc with a mips patch, but the patch also changed the interpreter patch from /lib to /tools/lib . I changed it back to /lib and rebuild. Now everything is fine.
It was not able to find the ld-uClib.so. I discovered this by statically linking readelf and looking at mount.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.