Nucklear
Nucklear

Reputation: 478

Problems compiling netcat for MIPS in ubuntu

I'm new with this and I am a little messed with it:

I'm trying to compile netcat source code for MIPS in order to deploy it in my router, what I do is:

Download the toolchain for mips: mips-linux-gcc

Download netcat source and expand it to a folder

cd path/to/netcatsource

Execute:
CC=path/to/compiler/mips-linux-gcc ./configure --host=mips-linux

make

The make command works fine and trying the file command over compiled netcat file displays:

file netcat
OUTPUT: ELF 32-bit MSB executable, MIPS, MIPS-I version 1 (SYSV), dynamically linked (uses shared libs), not stripped

For me everything seems fine, but if I execute ./netcat on my ubuntu box it works, and once I upload it to the router it displays the following error:

# ./netcat
Segmentation fault

This is the /proc/cpuinfo from my router:

# cat /proc/cpuinfo
system type             : 963281T_TEF
processor               : 0
cpu model               : Broadcom4350 V7.5
BogoMIPS                : 319.48
wait instruction        : yes
microsecond timers      : yes
tlb_entries             : 32
extra interrupt vector  : no
hardware watchpoint     : no
ASEs implemented        :
shadow register sets    : 1
core                    : 0
VCED exceptions         : not available
VCEI exceptions         : not available

unaligned exceptions            : 1395

Could anyone help me with this? Regards

Upvotes: 1

Views: 2500

Answers (1)

MsO
MsO

Reputation: 87

(I couldn't add a comment due to, I do not have enough points)

Try to static compile the source code
The problem may be happening because you do not have the necessary libraries on the router, maybe the binary is pointing to ld-linux.so and the router uses ld-uclibc.so.
So try static build...

UPDATE
I recomend the buildroot toolchain, which by the way include netcat and many other tools like busybox

Upvotes: 1

Related Questions