c - Executable works on compiling machine, not on 2nd machine -


i have 2 systems; openwrt , busybox.

i'm trying compile simple gcc executable on openwrt, copy , run on busybox machine.

they seem have similar cpu assume plan should work.

root@openwrt:/# cat /proc/cpuinfo  system type             : qualcomm atheros qca9558 ver 1 rev 0 machine                 : tp-link tl-wr1043nd v2 processor               : 0 cpu model               : mips 74kc v5.0 bogomips                : 358.80 wait instruction        : yes microsecond timers      : yes tlb_entries             : 32 interrupt vector  : yes hardware watchpoint     : yes, count: 4, address/irw mask: [0x0ffc, 0x0ffc, 0x0ffb, 0x0ffb] isa                     : mips1 mips2 mips32r1 mips32r2 ases implemented        : mips16 dsp dsp2 shadow register sets    : 1 kscratch registers      : 0 package                 : 0 core                    : 0 vced exceptions         : not available vcei exceptions         : not available  busybox v1.15.3 () built-in shell (ash) enter 'help' list of built-in commands. #cat /proc/cpuinfo  system type             : broadlight lilac soc processor               : 0 cpu model               : mips 74kc v4.12 bogomips                : 248.21 wait instruction        : yes microsecond timers      : yes tlb_entries             : 64 interrupt vector  : yes hardware watchpoint     : yes, count: 4, address/irw mask: [0x0000, 0x0000, 0x0000, 0x0000] ases implemented        : mips16 dsp shadow register sets    : 1 core                    : 0 vced exceptions         : not available vcei exceptions         : not available 

trying compile , run on openwrt:

root@openwrt:/# cat /hello.c #include <stdio.h>  int main() {     printf("kut met peren!\n");     return 0; }  root@openwrt:/mnt/sda3# gcc -o hello hello.c  root@openwrt:/mnt/sda3# ./hello kut met peren! root@openwrt:/mnt/sda3# 

copying hello busybox , executing:

#chmod +x hello #ls -l hello -rwxr-xr-x    1 root     root         5284 feb  8 16:46 hello #./hello -sh: ./hello: not found # 

what went wrong?

**updates:

filesystem doesn't seem noexec, anyway can run executables in same directory

#cat /proc/mounts rootfs / rootfs rw 0 0 ubi0_0 / ubifs rw,relatime 0 0 proc /proc proc rw,relatime 0 0 sysfs /sys sysfs rw,relatime 0 0 devpts /dev/pts devpts rw,relatime,gid=5,mode=620 0 0 tmpfs /dev/shm tmpfs rw,relatime 0 0 /dev/ram1 /tmp tmpfs rw,relatime,size=65536k 0 0 /dev/ubi1_1 /configs ubifs rw,relatime 0 0 /dev/ubi5_0 /logs ubifs rw,relatime 0 0 

file, ldd , strace on openwrt box rather requested 2nd system:

root@openwrt:/mnt/sda3# file ./hello hello: elf 32-bit msb executable, mips, mips32 rel2 version 1, dynamically linked (uses shared libs), not stripped  root@openwrt:/mnt/sda3# ldd ./hello         libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x77f12000)         libc.so.0 => /lib/libc.so.0 (0x77ea5000)         ld-uclibc.so.0 => /lib/ld-uclibc.so.0 (0x77f36000)   root@openwrt:/mnt/sda3# strace ./hello execve("./hello", ["./hello"], [/* 13 vars */]) = 0 mmap(null, 4096, prot_read|prot_write, map_private|map_anonymous|0x4000000, -1, 0) = 0x775c2000 stat("/etc/ld.so.cache", {st_mode=s_ifreg|0644, st_size=2683, ...}) = 0 open("/etc/ld.so.cache", o_rdonly|o_cloexec) = 3 mmap(null, 2683, prot_read, map_shared, 3, 0) = 0x775be000 close(3)                                = 0 open("/lib/libgcc_s.so.1", o_rdonly)    = 3 fstat(3, {st_mode=s_ifreg|0644, st_size=78648, ...}) = 0 mmap(null, 4096, prot_read|prot_write, map_private|map_anonymous|0x4000000, -1, 0) = 0x775bf000 read(3, "\177elf\1\2\1\0\0\0\0\0\0\0\0\0\0\3\0\10\0\0\0\1\0\0006\340\0\0\0004"..., 4096) = 4096 mmap(null, 147456, prot_none, map_private|map_anonymous, -1, 0) = 0x77586000 mmap(0x77586000, 78268, prot_read|prot_exec, map_private|map_fixed, 3, 0) = 0x77586000 mmap(0x775a9000, 824, prot_read|prot_write, map_private|map_fixed, 3, 0x13000) = 0x775a9000 close(3)                                = 0 munmap(0x775bf000, 4096)                = 0 open("/lib/libc.so.0", o_rdonly)        = 3 fstat(3, {st_mode=s_ifreg|0755, st_size=359596, ...}) = 0 mmap(null, 4096, prot_read|prot_write, map_private|map_anonymous|0x4000000, -1, 0) = 0x775bf000 read(3, "\177elf\1\2\1\0\0\0\0\0\0\0\0\0\0\3\0\10\0\0\0\1\0\0\235\0\0\0\0004"..., 4096) = 4096 mmap(null, 446464, prot_none, map_private|map_anonymous, -1, 0) = 0x77519000 mmap(0x77519000, 352496, prot_read|prot_exec, map_private|map_fixed, 3, 0) = 0x77519000 mmap(0x7757f000, 7340, prot_read|prot_write, map_private|map_fixed, 3, 0x56000) = 0x7757f000 mmap(0x77581000, 17508, prot_read|prot_write, map_private|map_fixed|map_anonymous, -1, 0) = 0x77581000 close(3)                                = 0 munmap(0x775bf000, 4096)                = 0 open("/lib/libc.so.0", o_rdonly)        = 3 fstat(3, {st_mode=s_ifreg|0755, st_size=359596, ...}) = 0 close(3)                                = 0 stat("/lib/ld-uclibc.so.0", {st_mode=s_ifreg|0755, st_size=28972, ...}) = 0 munmap(0x775be000, 2683)                = 0 mmap(null, 4096, prot_read|prot_write, map_private|map_anonymous|0x4000000, -1, 0) = 0x775bf000 set_thread_area(0x775c6440)             = 0 mprotect(0x7757f000, 4096, prot_read)   = 0 mprotect(0x775c0000, 4096, prot_read)   = 0 ioctl(0, tiocnxcl, {b38400 opost isig icanon echo ...}) = 0 ioctl(1, tiocnxcl, {b38400 opost isig icanon echo ...}) = 0 write(1, "kut met peren!\n", 15kut met peren! ) 

use file(1) & strace(1) & ldd(1) on second machine (if don't have them, install them, perhaps building them source code cross-compiler on laptop).

i guess shared library missing, or dynamic linker different, try on it:

 file ./hello  ldd ./hello  strace ./hello 

also run cat /proc/cpuinfo on second machine.

this should understanding wrong.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -