且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

更改哪个libc.so被链接?

更新时间:2023-02-02 21:41:01

想通了。必须使用buildroot构建一个uClibc工具链。

Im trying to cross compile for MIPSEL on my router. I got stuff working in assembly, but now Im moving to trying to compile basic C code.

Currently just have simple hello world c code, and using the mipsel-linux-gnu-gcc compiler, which works for assembly.

Compiler command:

 mipsel-linux-gnu-gcc  -L/home/uname/devel/extr/squashfs-root/lib -l:libc.so.0 -mips32 -Wl,--build-id=none -Wl,--dynamic-linker=/lib/ld-uClibc.so.0  ma.c

The libc.so.0 is extracted from the firmware for the router.

The program compiles, however in readelf, the issue is that it links against libc.so.6

 0x00000001 (NEEDED)                     Shared library: [libc.so.6]

whereas pulling the busybox binary from the firmware and running readelf on it

0x00000001 (NEEDED)                     Shared library: [libc.so.0]

How do I get it to link against libc.so.0?

Figured it out. Had to build a uClibc toolchain using buildroot.