Closed amlamarra closed 4 years ago
Looks like the version of the toolchain you're using in incompatible with the version used to build your firmware. Are you able to build a simple helloworld and run it on that firmware?
GCC toolchain versions are notoriously picky about forward/backward compatibility. It's also pretty picky about what toolchain versions will build what other toolchain versions. I used to collect and hoard gcc toolchains for this reason, because sometimes it would be trial-and-error finding one that would build binaries that would run on a given firmware.
Sorry. I'm not much of a software developer. I just installed this package on my system: https://packages.debian.org/buster/gcc-mipsel-linux-gnu
That's what allowed me to cross compile to mips. A simple helloworld does work:
andrew ~/E1200/squashfs-root $ cat hello.c
#include <stdio.h>
int main() {
printf("Hello world\n");
return 0;
}
andrew ~/E1200/squashfs-root $ mipsel-linux-gnu-gcc hello.c -o hello
andrew ~/E1200/squashfs-root $ file hello
hello: ELF 32-bit LSB shared object, MIPS, MIPS32 rel2 version 1 (SYSV), dynamically linked, interpreter /lib/ld.so.1, BuildID[sha1]=dd4c3c686dfbcd3513219a2cf4dd02494047321c, for GNU/Linux 3.2.0, not stripped
andrew ~/E1200/squashfs-root $ sudo chroot . ./qemu-mipsel-static ./hello
Hello world
andrew ~/E1200/squashfs-root $ sudo chroot . ./qemu-mipsel-static -E LD_PRELOAD="./libnvram-faker.so" ./hello
Hello world
Is there any way for me figure out what toolchain version was used to build the firmware? Would I need the source (if that would even tell me)?
Never mind. I found the correct toolchain and it all works now, thanks!
Never mind. I found the correct toolchain and it all works now, thanks!
What is the correct toolchain?
In this particular case, it was uclibc-4.2.3
.
In this particular case, it was
uclibc-4.2.3
.
Thanks~!ʕ •ᴥ•ʔ
Sorry to bother you again. After solving the above problems,the new one arose:
can't resolve symbol '__ctype_b_loc'
Did I miss sth?(╥ω╥) I used the toolchain from: https://toolchains.bootlin.com/
You've just set the LD_PRELOAD environment variable for every program you run in that terminal. When you executed ls
, it first looked to /lib/libnvram-faker.so
for the __ctype_b_loc
symbol. Which, apparently it had but couldn't resolve properly... I'm not sure.
Anyway, you need to use libnvram-faker.so
when executing something specific. In my case, I was trying to run the httpd
binary from a router's firmware in a QEMU user environment like so:
sudo chroot . ./qemu-mipsel-static -E LD_PRELOAD="./libnvram-faker.so" usr/sbin/httpd
$ sudo chroot . ./qemu-mips-static -E LD_PRELOAD="./lib/libnvram-faker.so" ./sbin/lighttpd
./sbin/lighttpd: can't resolve symbol '__ctype_b_loc'
Sad. I give up.(╥ω╥) Maybe the toolchain is wrong again
Yeah~The toolchain is wrong again.
Hey, I'd love to use this, but it's not working. I'm trying to emulate the Linksys E1200 firmware (and some others). After building and copying the necessary files to the root of the filesystem, I get errors indicating that it's looking for a different version of libc and ld than what's on the filesystem. Here's a look at what I'm doing:
Any idea on how to resolve this?
BTW, I had to update the
buildmipsel.sh
to replace every instance ofmipsel-linux-
wthmipsel-linux-gnu-
: