warricksothr / RustBuild

Scripts and patches to auto build Rustc and Cargo on ARM
MIT License
104 stars 8 forks source link

Segmentation fault while executing crosscompiled binary @ RPi 1 Rev. b #5

Closed iamsebastian closed 8 years ago

iamsebastian commented 8 years ago

Hello.

If I compile something with: rustc -C linker=arm-linux-gnueabihf-gcc --target=arm-unknown-linux-gnueabihf hello.rs, copy that binary to my RPi1b and trying to execute that binary, after copying finished, I get a segmentation fault at the @RPi1b: [1] 20396 segmentation fault ./hello Any ideas why this is happening?


CPU on my RPi1b:

processor       : 0
model name      : ARMv6-compatible processor rev 7 (v6l)
BogoMIPS        : 2.28
Features        : half thumb fastmult vfp edsp java tls 
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x0
CPU part        : 0xb76
CPU revision    : 7

Hardware        : BCM2708
Revision        : 000d
Serial          : 0000000089ffe808
$ file hello
hello: ELF 32-bit LSB shared object, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=0x02f2a58e4f9061f758700b088ee33909e42d7d43, not stripped
iamsebastian commented 8 years ago

By the way: hello.rs does not contain more than the default cargo hello-world:

pub fn main() {
  println!("Hello world!");
}
warricksothr commented 8 years ago

Are you using the latest ARMv6-armhf binary builds as the library for your cross compiler?

I just got them building in the Raspbian container again last night and my test on the Raspberry Pi worked. https://github.com/warricksothr/RustBuild/issues/4

However I haven't tried crosscompiling with the latest builds, so I'll look into that.

Forgot that the cross compiler requires matching versions of Rustc. I may need to recompile the latest beta and stable. I'll let you know after my tests. Which were you using? Beta or Stable?
warricksothr commented 8 years ago

With the latest stable build for ARMv6-armhf I too am getting a segmentation fault when I cross compile.

Here is the trace of the fault that I'm looking into now.

pi@raspberrypi ~ $ strace ./hello
execve("./hello", ["./hello"], [/* 16 vars */]) = 0
brk(0)                                  = 0xb7dfa000
uname({sys="Linux", node="raspberrypi", ...}) = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6f58000
readlink("/proc/self/exe", "/home/pi/hello", 4096) = 14
access("/etc/ld.so.preload", R_OK)      = 0
open("/etc/ld.so.preload", O_RDONLY)    = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=44, ...}) = 0
mmap2(NULL, 44, PROT_READ|PROT_WRITE, MAP_PRIVATE, 3, 0) = 0xb6f57000
close(3)                                = 0
open("/usr/lib/arm-linux-gnueabihf/libcofi_rpi.so", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\270\4\0\0004\0\0\0"..., 512) = 512
lseek(3, 7276, SEEK_SET)                = 7276
read(3, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1080) = 1080
lseek(3, 7001, SEEK_SET)                = 7001
read(3, "A.\0\0\0aeabi\0\1$\0\0\0\0056\0\6\6\10\1\t\1\n\2\22\4\24\1\25"..., 47) = 47
fstat64(3, {st_mode=S_IFREG|0755, st_size=10170, ...}) = 0
mmap2(NULL, 39740, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6f2b000
mprotect(0xb6f2d000, 28672, PROT_NONE)  = 0
mmap2(0xb6f34000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1) = 0xb6f34000
close(3)                                = 0
munmap(0xb6f57000, 44)                  = 0
open("/home/pi/../../../.multirust/toolchains/stable/lib/rustlib/arm-unknown-linux-gnueabihf/lib/tls/v6l/vfp/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/home/pi/../../../.multirust/toolchains/stable/lib/rustlib/arm-unknown-linux-gnueabihf/lib/tls/v6l/vfp", 0xbeea5f20) = -1 ENOENT (No such file or directory)
open("/home/pi/../../../.multirust/toolchains/stable/lib/rustlib/arm-unknown-linux-gnueabihf/lib/tls/v6l/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/home/pi/../../../.multirust/toolchains/stable/lib/rustlib/arm-unknown-linux-gnueabihf/lib/tls/v6l", 0xbeea5f20) = -1 ENOENT (No such file or directory)
open("/home/pi/../../../.multirust/toolchains/stable/lib/rustlib/arm-unknown-linux-gnueabihf/lib/tls/vfp/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/home/pi/../../../.multirust/toolchains/stable/lib/rustlib/arm-unknown-linux-gnueabihf/lib/tls/vfp", 0xbeea5f20) = -1 ENOENT (No such file or directory)
open("/home/pi/../../../.multirust/toolchains/stable/lib/rustlib/arm-unknown-linux-gnueabihf/lib/tls/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/home/pi/../../../.multirust/toolchains/stable/lib/rustlib/arm-unknown-linux-gnueabihf/lib/tls", 0xbeea5f20) = -1 ENOENT (No such file or directory)
open("/home/pi/../../../.multirust/toolchains/stable/lib/rustlib/arm-unknown-linux-gnueabihf/lib/v6l/vfp/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/home/pi/../../../.multirust/toolchains/stable/lib/rustlib/arm-unknown-linux-gnueabihf/lib/v6l/vfp", 0xbeea5f20) = -1 ENOENT (No such file or directory)
open("/home/pi/../../../.multirust/toolchains/stable/lib/rustlib/arm-unknown-linux-gnueabihf/lib/v6l/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/home/pi/../../../.multirust/toolchains/stable/lib/rustlib/arm-unknown-linux-gnueabihf/lib/v6l", 0xbeea5f20) = -1 ENOENT (No such file or directory)
open("/home/pi/../../../.multirust/toolchains/stable/lib/rustlib/arm-unknown-linux-gnueabihf/lib/vfp/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/home/pi/../../../.multirust/toolchains/stable/lib/rustlib/arm-unknown-linux-gnueabihf/lib/vfp", 0xbeea5f20) = -1 ENOENT (No such file or directory)
open("/home/pi/../../../.multirust/toolchains/stable/lib/rustlib/arm-unknown-linux-gnueabihf/lib/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/home/pi/../../../.multirust/toolchains/stable/lib/rustlib/arm-unknown-linux-gnueabihf/lib", 0xbeea5f20) = -1 ENOENT (No such file or directory)
open("/usr/local/lib/rustlib/arm-unknown-linux-gnueabihf/lib/tls/v6l/vfp/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/usr/local/lib/rustlib/arm-unknown-linux-gnueabihf/lib/tls/v6l/vfp", 0xbeea5f20) = -1 ENOENT (No such file or directory)
open("/usr/local/lib/rustlib/arm-unknown-linux-gnueabihf/lib/tls/v6l/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/usr/local/lib/rustlib/arm-unknown-linux-gnueabihf/lib/tls/v6l", 0xbeea5f20) = -1 ENOENT (No such file or directory)
open("/usr/local/lib/rustlib/arm-unknown-linux-gnueabihf/lib/tls/vfp/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/usr/local/lib/rustlib/arm-unknown-linux-gnueabihf/lib/tls/vfp", 0xbeea5f20) = -1 ENOENT (No such file or directory)
open("/usr/local/lib/rustlib/arm-unknown-linux-gnueabihf/lib/tls/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/usr/local/lib/rustlib/arm-unknown-linux-gnueabihf/lib/tls", 0xbeea5f20) = -1 ENOENT (No such file or directory)
open("/usr/local/lib/rustlib/arm-unknown-linux-gnueabihf/lib/v6l/vfp/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/usr/local/lib/rustlib/arm-unknown-linux-gnueabihf/lib/v6l/vfp", 0xbeea5f20) = -1 ENOENT (No such file or directory)
open("/usr/local/lib/rustlib/arm-unknown-linux-gnueabihf/lib/v6l/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/usr/local/lib/rustlib/arm-unknown-linux-gnueabihf/lib/v6l", 0xbeea5f20) = -1 ENOENT (No such file or directory)
open("/usr/local/lib/rustlib/arm-unknown-linux-gnueabihf/lib/vfp/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/usr/local/lib/rustlib/arm-unknown-linux-gnueabihf/lib/vfp", 0xbeea5f20) = -1 ENOENT (No such file or directory)
open("/usr/local/lib/rustlib/arm-unknown-linux-gnueabihf/lib/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/usr/local/lib/rustlib/arm-unknown-linux-gnueabihf/lib", 0xbeea5f20) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=59405, ...}) = 0
mmap2(NULL, 59405, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb6f1c000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/arm-linux-gnueabihf/libdl.so.2", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0(\t\0\0004\0\0\0"..., 512) = 512
lseek(3, 8652, SEEK_SET)                = 8652
read(3, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1160) = 1160
lseek(3, 8320, SEEK_SET)                = 8320
read(3, "A0\0\0\0aeabi\0\1&\0\0\0\0056\0\6\6\10\1\t\1\n\2\22\4\24\1\25"..., 49) = 49
fstat64(3, {st_mode=S_IFREG|0644, st_size=9812, ...}) = 0
mmap2(NULL, 41136, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6f11000
mprotect(0xb6f13000, 28672, PROT_NONE)  = 0
mmap2(0xb6f1a000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1) = 0xb6f1a000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/arm-linux-gnueabihf/libpthread.so.0", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\274V\0\0004\0\0\0"..., 512) = 512
lseek(3, 82712, SEEK_SET)               = 82712
read(3, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1400) = 1400
lseek(3, 82308, SEEK_SET)               = 82308
read(3, "A0\0\0\0aeabi\0\1&\0\0\0\0056\0\6\6\10\1\t\1\n\2\22\4\24\1\25"..., 49) = 49
fstat64(3, {st_mode=S_IFREG|0755, st_size=116462, ...}) = 0
mmap2(NULL, 123412, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6ef2000
mprotect(0xb6f06000, 28672, PROT_NONE)  = 0
mmap2(0xb6f0d000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x13) = 0xb6f0d000
mmap2(0xb6f0f000, 4628, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb6f0f000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/arm-linux-gnueabihf/librt.so.1", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\300\26\0\0004\0\0\0"..., 512) = 512
lseek(3, 25312, SEEK_SET)               = 25312
read(3, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1320) = 1320
lseek(3, 24924, SEEK_SET)               = 24924
read(3, "A0\0\0\0aeabi\0\1&\0\0\0\0056\0\6\6\10\1\t\1\n\2\22\4\24\1\25"..., 49) = 49
strace ./hello
execve("./hello", ["./hello"], [/* 16 vars */]) = 0
brk(0)                                  = 0xb8cc1000
uname({sys="Linux", node="raspberrypi", ...}) = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6f93000
readlink("/proc/self/exe", "/home/pi/hello", 4096) = 14
access("/etc/ld.so.preload", R_OK)      = 0
open("/etc/ld.so.preload", O_RDONLY)    = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=44, ...}) = 0
mmap2(NULL, 44, PROT_READ|PROT_WRITE, MAP_PRIVATE, 3, 0) = 0xb6f92000
close(3)                                = 0
open("/usr/lib/arm-linux-gnueabihf/libcofi_rpi.so", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\270\4\0\0004\0\0\0"..., 512) = 512
lseek(3, 7276, SEEK_SET)                = 7276
read(3, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1080) = 1080
lseek(3, 7001, SEEK_SET)                = 7001
read(3, "A.\0\0\0aeabi\0\1$\0\0\0\0056\0\6\6\10\1\t\1\n\2\22\4\24\1\25"..., 47) = 47
fstat64(3, {st_mode=S_IFREG|0755, st_size=10170, ...}) = 0
mmap2(NULL, 39740, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6f66000
mprotect(0xb6f68000, 28672, PROT_NONE)  = 0
mmap2(0xb6f6f000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1) = 0xb6f6f000
close(3)                                = 0
munmap(0xb6f92000, 44)                  = 0
open("/home/pi/../../../.multirust/toolchains/stable/lib/rustlib/arm-unknown-linux-gnueabihf/lib/tls/v6l/vfp/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/home/pi/../../../.multirust/toolchains/stable/lib/rustlib/arm-unknown-linux-gnueabihf/lib/tls/v6l/vfp", 0xbea51f20) = -1 ENOENT (No such file or directory)
open("/home/pi/../../../.multirust/toolchains/stable/lib/rustlib/arm-unknown-linux-gnueabihf/lib/tls/v6l/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/home/pi/../../../.multirust/toolchains/stable/lib/rustlib/arm-unknown-linux-gnueabihf/lib/tls/v6l", 0xbea51f20) = -1 ENOENT (No such file or directory)
open("/home/pi/../../../.multirust/toolchains/stable/lib/rustlib/arm-unknown-linux-gnueabihf/lib/tls/vfp/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/home/pi/../../../.multirust/toolchains/stable/lib/rustlib/arm-unknown-linux-gnueabihf/lib/tls/vfp", 0xbea51f20) = -1 ENOENT (No such file or directory)
open("/home/pi/../../../.multirust/toolchains/stable/lib/rustlib/arm-unknown-linux-gnueabihf/lib/tls/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/home/pi/../../../.multirust/toolchains/stable/lib/rustlib/arm-unknown-linux-gnueabihf/lib/tls", 0xbea51f20) = -1 ENOENT (No such file or directory)
open("/home/pi/../../../.multirust/toolchains/stable/lib/rustlib/arm-unknown-linux-gnueabihf/lib/v6l/vfp/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/home/pi/../../../.multirust/toolchains/stable/lib/rustlib/arm-unknown-linux-gnueabihf/lib/v6l/vfp", 0xbea51f20) = -1 ENOENT (No such file or directory)
open("/home/pi/../../../.multirust/toolchains/stable/lib/rustlib/arm-unknown-linux-gnueabihf/lib/v6l/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/home/pi/../../../.multirust/toolchains/stable/lib/rustlib/arm-unknown-linux-gnueabihf/lib/v6l", 0xbea51f20) = -1 ENOENT (No such file or directory)
open("/home/pi/../../../.multirust/toolchains/stable/lib/rustlib/arm-unknown-linux-gnueabihf/lib/vfp/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/home/pi/../../../.multirust/toolchains/stable/lib/rustlib/arm-unknown-linux-gnueabihf/lib/vfp", 0xbea51f20) = -1 ENOENT (No such file or directory)
open("/home/pi/../../../.multirust/toolchains/stable/lib/rustlib/arm-unknown-linux-gnueabihf/lib/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/home/pi/../../../.multirust/toolchains/stable/lib/rustlib/arm-unknown-linux-gnueabihf/lib", 0xbea51f20) = -1 ENOENT (No such file or directory)
open("/usr/local/lib/rustlib/arm-unknown-linux-gnueabihf/lib/tls/v6l/vfp/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/usr/local/lib/rustlib/arm-unknown-linux-gnueabihf/lib/tls/v6l/vfp", 0xbea51f20) = -1 ENOENT (No such file or directory)
open("/usr/local/lib/rustlib/arm-unknown-linux-gnueabihf/lib/tls/v6l/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/usr/local/lib/rustlib/arm-unknown-linux-gnueabihf/lib/tls/v6l", 0xbea51f20) = -1 ENOENT (No such file or directory)
open("/usr/local/lib/rustlib/arm-unknown-linux-gnueabihf/lib/tls/vfp/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/usr/local/lib/rustlib/arm-unknown-linux-gnueabihf/lib/tls/vfp", 0xbea51f20) = -1 ENOENT (No such file or directory)
open("/usr/local/lib/rustlib/arm-unknown-linux-gnueabihf/lib/tls/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/usr/local/lib/rustlib/arm-unknown-linux-gnueabihf/lib/tls", 0xbea51f20) = -1 ENOENT (No such file or directory)
open("/usr/local/lib/rustlib/arm-unknown-linux-gnueabihf/lib/v6l/vfp/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/usr/local/lib/rustlib/arm-unknown-linux-gnueabihf/lib/v6l/vfp", 0xbea51f20) = -1 ENOENT (No such file or directory)
open("/usr/local/lib/rustlib/arm-unknown-linux-gnueabihf/lib/v6l/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/usr/local/lib/rustlib/arm-unknown-linux-gnueabihf/lib/v6l", 0xbea51f20) = -1 ENOENT (No such file or directory)
open("/usr/local/lib/rustlib/arm-unknown-linux-gnueabihf/lib/vfp/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/usr/local/lib/rustlib/arm-unknown-linux-gnueabihf/lib/vfp", 0xbea51f20) = -1 ENOENT (No such file or directory)
open("/usr/local/lib/rustlib/arm-unknown-linux-gnueabihf/lib/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/usr/local/lib/rustlib/arm-unknown-linux-gnueabihf/lib", 0xbea51f20) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=59405, ...}) = 0
mmap2(NULL, 59405, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb6f57000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/arm-linux-gnueabihf/libdl.so.2", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0(\t\0\0004\0\0\0"..., 512) = 512
lseek(3, 8652, SEEK_SET)                = 8652
read(3, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1160) = 1160
lseek(3, 8320, SEEK_SET)                = 8320
read(3, "A0\0\0\0aeabi\0\1&\0\0\0\0056\0\6\6\10\1\t\1\n\2\22\4\24\1\25"..., 49) = 49
fstat64(3, {st_mode=S_IFREG|0644, st_size=9812, ...}) = 0
mmap2(NULL, 41136, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6f4c000
mprotect(0xb6f4e000, 28672, PROT_NONE)  = 0
mmap2(0xb6f55000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1) = 0xb6f55000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/arm-linux-gnueabihf/libpthread.so.0", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\274V\0\0004\0\0\0"..., 512) = 512
lseek(3, 82712, SEEK_SET)               = 82712
read(3, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1400) = 1400
lseek(3, 82308, SEEK_SET)               = 82308
read(3, "A0\0\0\0aeabi\0\1&\0\0\0\0056\0\6\6\10\1\t\1\n\2\22\4\24\1\25"..., 49) = 49
fstat64(3, {st_mode=S_IFREG|0755, st_size=116462, ...}) = 0
mmap2(NULL, 123412, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6f2d000
mprotect(0xb6f41000, 28672, PROT_NONE)  = 0
mmap2(0xb6f48000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x13) = 0xb6f48000
mmap2(0xb6f4a000, 4628, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb6f4a000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/arm-linux-gnueabihf/librt.so.1", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\300\26\0\0004\0\0\0"..., 512) = 512
lseek(3, 25312, SEEK_SET)               = 25312
read(3, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1320) = 1320
lseek(3, 24924, SEEK_SET)               = 24924
read(3, "A0\0\0\0aeabi\0\1&\0\0\0\0056\0\6\6\10\1\t\1\n\2\22\4\24\1\25"..., 49) = 49
fstat64(3, {st_mode=S_IFREG|0644, st_size=26632, ...}) = 0
mmap2(NULL, 57876, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6f1e000
mprotect(0xb6f24000, 28672, PROT_NONE)  = 0
mmap2(0xb6f2b000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x5) = 0xb6f2b000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/arm-linux-gnueabihf/libgcc_s.so.1", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0P\364\0\0004\0\0\0"..., 512) = 512
lseek(3, 129288, SEEK_SET)              = 129288
read(3, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1160) = 1160
lseek(3, 128956, SEEK_SET)              = 128956
read(3, "A2\0\0\0aeabi\0\1(\0\0\0\0056\0\6\6\10\1\t\1\n\2\22\4\24\1\25"..., 51) = 51
fstat64(3, {st_mode=S_IFREG|0644, st_size=130448, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6f92000
mmap2(NULL, 161780, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6ef6000
mprotect(0xb6f16000, 28672, PROT_NONE)  = 0
mmap2(0xb6f1d000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1f) = 0xb6f1d000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/arm-linux-gnueabihf/libc.so.6", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\210y\1\0004\0\0\0"..., 512) = 512
lseek(3, 1198880, SEEK_SET)             = 1198880
read(3, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1360) = 1360
lseek(3, 1198444, SEEK_SET)             = 1198444
read(3, "A.\0\0\0aeabi\0\1$\0\0\0\0056\0\6\6\10\1\t\1\n\2\22\4\24\1\25"..., 47) = 47
fstat64(3, {st_mode=S_IFREG|0755, st_size=1200240, ...}) = 0
mmap2(NULL, 1242400, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6dc6000
mprotect(0xb6ee9000, 28672, PROT_NONE)  = 0
mmap2(0xb6ef0000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x122) = 0xb6ef0000
mmap2(0xb6ef3000, 9504, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb6ef3000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/arm-linux-gnueabihf/libm.so.6", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\3201\0\0004\0\0\0"..., 512) = 512
lseek(3, 426468, SEEK_SET)              = 426468
read(3, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1160) = 1160
lseek(3, 426136, SEEK_SET)              = 426136
read(3, "A0\0\0\0aeabi\0\1&\0\0\0\0056\0\6\6\10\1\t\1\n\2\22\4\24\1\25"..., 49) = 49
fstat64(3, {st_mode=S_IFREG|0644, st_size=427628, ...}) = 0
mmap2(NULL, 458912, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6d55000
mprotect(0xb6dbd000, 28672, PROT_NONE)  = 0
mmap2(0xb6dc4000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x67) = 0xb6dc4000
close(3)                                = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6f91000
set_tls(0xb6f916d0, 0xb6f91e28, 0xb6f96048, 0xb6f916d0, 0xb6f96048) = 0
mprotect(0xb6dc4000, 4096, PROT_READ)   = 0
mprotect(0xb6ef0000, 8192, PROT_READ)   = 0
mprotect(0xb6f2b000, 4096, PROT_READ)   = 0
mprotect(0xb6f48000, 4096, PROT_READ)   = 0
mprotect(0xb6f55000, 4096, PROT_READ)   = 0
mprotect(0xb6fde000, 8192, PROT_READ)   = 0
mprotect(0xb6f95000, 4096, PROT_READ)   = 0
munmap(0xb6f57000, 59405)               = 0
set_tid_address(0xb6f91278)             = 3454
set_robust_list(0xb6f91280, 0xc)        = 0
futex(0xbea527f8, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 1, NULL, b6f49000) = -1 EAGAIN (Resource temporarily unavailable)
rt_sigaction(SIGRTMIN, {0xb6f3220c, [], SA_SIGINFO|0x4000000}, NULL, 8) = 0
rt_sigaction(SIGRT_1, {0xb6f320b4, [], SA_RESTART|SA_SIGINFO|0x4000000}, NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
getrlimit(RLIMIT_STACK, {rlim_cur=8192*1024, rlim_max=RLIM_INFINITY}) = 0
--- SIGSEGV (Segmentation fault) @ 0 (0) ---
+++ killed by SIGSEGV +++
Segmentation fault
warricksothr commented 8 years ago

The weirdest part is that the compiled binary works on my ARMv7 machine with no issue.

Additionally the same stable release of the ARMv6-armhf versions of cargo and rust compile and run a hello world on the Pi. So I don't think it's the build that's wrong. Something in the crosscompiling linking must be off.

warricksothr commented 8 years ago

Here's a strace of the exact same program compiled on a Raspberry Pi B

pi@raspberrypi ~ $ strace ./main
execve("./main", ["./main"], [/* 17 vars */]) = 0
brk(0)                                  = 0xb7ad8000
uname({sys="Linux", node="raspberrypi", ...}) = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6ebe000
readlink("/proc/self/exe", "/home/pi/main", 4096) = 13
access("/etc/ld.so.preload", R_OK)      = 0
open("/etc/ld.so.preload", O_RDONLY)    = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=44, ...}) = 0
mmap2(NULL, 44, PROT_READ|PROT_WRITE, MAP_PRIVATE, 3, 0) = 0xb6ebd000
close(3)                                = 0
open("/usr/lib/arm-linux-gnueabihf/libcofi_rpi.so", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\270\4\0\0004\0\0\0"..., 512) = 512
lseek(3, 7276, SEEK_SET)                = 7276
read(3, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1080) = 1080
lseek(3, 7001, SEEK_SET)                = 7001
read(3, "A.\0\0\0aeabi\0\1$\0\0\0\0056\0\6\6\10\1\t\1\n\2\22\4\24\1\25"..., 47) = 47
fstat64(3, {st_mode=S_IFREG|0755, st_size=10170, ...}) = 0
mmap2(NULL, 39740, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6e91000
mprotect(0xb6e93000, 28672, PROT_NONE)  = 0
mmap2(0xb6e9a000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1) = 0xb6e9a000
close(3)                                = 0
munmap(0xb6ebd000, 44)                  = 0
open("/home/pi/../../opt/rust_stable/lib/rustlib/arm-unknown-linux-gnueabihf/lib/tls/v6l/vfp/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/home/pi/../../opt/rust_stable/lib/rustlib/arm-unknown-linux-gnueabihf/lib/tls/v6l/vfp", 0xbed73f00) = -1 ENOENT (No such file or directory)
open("/home/pi/../../opt/rust_stable/lib/rustlib/arm-unknown-linux-gnueabihf/lib/tls/v6l/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/home/pi/../../opt/rust_stable/lib/rustlib/arm-unknown-linux-gnueabihf/lib/tls/v6l", 0xbed73f00) = -1 ENOENT (No such file or directory)
open("/home/pi/../../opt/rust_stable/lib/rustlib/arm-unknown-linux-gnueabihf/lib/tls/vfp/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/home/pi/../../opt/rust_stable/lib/rustlib/arm-unknown-linux-gnueabihf/lib/tls/vfp", 0xbed73f00) = -1 ENOENT (No such file or directory)
open("/home/pi/../../opt/rust_stable/lib/rustlib/arm-unknown-linux-gnueabihf/lib/tls/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/home/pi/../../opt/rust_stable/lib/rustlib/arm-unknown-linux-gnueabihf/lib/tls", 0xbed73f00) = -1 ENOENT (No such file or directory)
open("/home/pi/../../opt/rust_stable/lib/rustlib/arm-unknown-linux-gnueabihf/lib/v6l/vfp/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/home/pi/../../opt/rust_stable/lib/rustlib/arm-unknown-linux-gnueabihf/lib/v6l/vfp", 0xbed73f00) = -1 ENOENT (No such file or directory)
open("/home/pi/../../opt/rust_stable/lib/rustlib/arm-unknown-linux-gnueabihf/lib/v6l/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/home/pi/../../opt/rust_stable/lib/rustlib/arm-unknown-linux-gnueabihf/lib/v6l", 0xbed73f00) = -1 ENOENT (No such file or directory)
open("/home/pi/../../opt/rust_stable/lib/rustlib/arm-unknown-linux-gnueabihf/lib/vfp/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/home/pi/../../opt/rust_stable/lib/rustlib/arm-unknown-linux-gnueabihf/lib/vfp", 0xbed73f00) = -1 ENOENT (No such file or directory)
open("/home/pi/../../opt/rust_stable/lib/rustlib/arm-unknown-linux-gnueabihf/lib/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/home/pi/../../opt/rust_stable/lib/rustlib/arm-unknown-linux-gnueabihf/lib", 0xbed73f00) = -1 ENOENT (No such file or directory)
open("/home/pi/dev/hello_world/lib/rustlib/arm-unknown-linux-gnueabihf/lib/tls/v6l/vfp/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/home/pi/dev/hello_world/lib/rustlib/arm-unknown-linux-gnueabihf/lib/tls/v6l/vfp", 0xbed73f00) = -1 ENOENT (No such file or directory)
open("/home/pi/dev/hello_world/lib/rustlib/arm-unknown-linux-gnueabihf/lib/tls/v6l/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/home/pi/dev/hello_world/lib/rustlib/arm-unknown-linux-gnueabihf/lib/tls/v6l", 0xbed73f00) = -1 ENOENT (No such file or directory)
open("/home/pi/dev/hello_world/lib/rustlib/arm-unknown-linux-gnueabihf/lib/tls/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/home/pi/dev/hello_world/lib/rustlib/arm-unknown-linux-gnueabihf/lib/tls", 0xbed73f00) = -1 ENOENT (No such file or directory)
open("/home/pi/dev/hello_world/lib/rustlib/arm-unknown-linux-gnueabihf/lib/v6l/vfp/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/home/pi/dev/hello_world/lib/rustlib/arm-unknown-linux-gnueabihf/lib/v6l/vfp", 0xbed73f00) = -1 ENOENT (No such file or directory)
open("/home/pi/dev/hello_world/lib/rustlib/arm-unknown-linux-gnueabihf/lib/v6l/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/home/pi/dev/hello_world/lib/rustlib/arm-unknown-linux-gnueabihf/lib/v6l", 0xbed73f00) = -1 ENOENT (No such file or directory)
open("/home/pi/dev/hello_world/lib/rustlib/arm-unknown-linux-gnueabihf/lib/vfp/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/home/pi/dev/hello_world/lib/rustlib/arm-unknown-linux-gnueabihf/lib/vfp", 0xbed73f00) = -1 ENOENT (No such file or directory)
open("/home/pi/dev/hello_world/lib/rustlib/arm-unknown-linux-gnueabihf/lib/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/home/pi/dev/hello_world/lib/rustlib/arm-unknown-linux-gnueabihf/lib", 0xbed73f00) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=59405, ...}) = 0
mmap2(NULL, 59405, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb6e82000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/arm-linux-gnueabihf/libdl.so.2", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0(\t\0\0004\0\0\0"..., 512) = 512
lseek(3, 8652, SEEK_SET)                = 8652
read(3, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1160) = 1160
lseek(3, 8320, SEEK_SET)                = 8320
read(3, "A0\0\0\0aeabi\0\1&\0\0\0\0056\0\6\6\10\1\t\1\n\2\22\4\24\1\25"..., 49) = 49
fstat64(3, {st_mode=S_IFREG|0644, st_size=9812, ...}) = 0
mmap2(NULL, 41136, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6e77000
mprotect(0xb6e79000, 28672, PROT_NONE)  = 0
mmap2(0xb6e80000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1) = 0xb6e80000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/arm-linux-gnueabihf/libpthread.so.0", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\274V\0\0004\0\0\0"..., 512) = 512
lseek(3, 82712, SEEK_SET)               = 82712
read(3, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1400) = 1400
lseek(3, 82308, SEEK_SET)               = 82308
read(3, "A0\0\0\0aeabi\0\1&\0\0\0\0056\0\6\6\10\1\t\1\n\2\22\4\24\1\25"..., 49) = 49
fstat64(3, {st_mode=S_IFREG|0755, st_size=116462, ...}) = 0
mmap2(NULL, 123412, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6e58000
mprotect(0xb6e6c000, 28672, PROT_NONE)  = 0
mmap2(0xb6e73000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x13) = 0xb6e73000
mmap2(0xb6e75000, 4628, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb6e75000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/arm-linux-gnueabihf/librt.so.1", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\300\26\0\0004\0\0\0"..., 512) = 512
lseek(3, 25312, SEEK_SET)               = 25312
read(3, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1320) = 1320
lseek(3, 24924, SEEK_SET)               = 24924
read(3, "A0\0\0\0aeabi\0\1&\0\0\0\0056\0\6\6\10\1\t\1\n\2\22\4\24\1\25"..., 49) = 49
fstat64(3, {st_mode=S_IFREG|0644, st_size=26632, ...}) = 0
mmap2(NULL, 57876, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6e49000
mprotect(0xb6e4f000, 28672, PROT_NONE)  = 0
mmap2(0xb6e56000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x5) = 0xb6e56000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/arm-linux-gnueabihf/libgcc_s.so.1", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0P\364\0\0004\0\0\0"..., 512) = 512
lseek(3, 129288, SEEK_SET)              = 129288
read(3, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1160) = 1160
lseek(3, 128956, SEEK_SET)              = 128956
read(3, "A2\0\0\0aeabi\0\1(\0\0\0\0056\0\6\6\10\1\t\1\n\2\22\4\24\1\25"..., 51) = 51
fstat64(3, {st_mode=S_IFREG|0644, st_size=130448, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6ebd000
mmap2(NULL, 161780, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6e21000
mprotect(0xb6e41000, 28672, PROT_NONE)  = 0
mmap2(0xb6e48000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1f) = 0xb6e48000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/arm-linux-gnueabihf/libc.so.6", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\210y\1\0004\0\0\0"..., 512) = 512
lseek(3, 1198880, SEEK_SET)             = 1198880
read(3, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1360) = 1360
lseek(3, 1198444, SEEK_SET)             = 1198444
read(3, "A.\0\0\0aeabi\0\1$\0\0\0\0056\0\6\6\10\1\t\1\n\2\22\4\24\1\25"..., 47) = 47
fstat64(3, {st_mode=S_IFREG|0755, st_size=1200240, ...}) = 0
mmap2(NULL, 1242400, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6cf1000
mprotect(0xb6e14000, 28672, PROT_NONE)  = 0
mmap2(0xb6e1b000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x122) = 0xb6e1b000
mmap2(0xb6e1e000, 9504, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb6e1e000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/arm-linux-gnueabihf/libm.so.6", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\3201\0\0004\0\0\0"..., 512) = 512
lseek(3, 426468, SEEK_SET)              = 426468
read(3, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1160) = 1160
lseek(3, 426136, SEEK_SET)              = 426136
read(3, "A0\0\0\0aeabi\0\1&\0\0\0\0056\0\6\6\10\1\t\1\n\2\22\4\24\1\25"..., 49) = 49
fstat64(3, {st_mode=S_IFREG|0644, st_size=427628, ...}) = 0
mmap2(NULL, 458912, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6c80000
mprotect(0xb6ce8000, 28672, PROT_NONE)  = 0
mmap2(0xb6cef000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x67) = 0xb6cef000
close(3)                                = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6ebc000
set_tls(0xb6ebc6d0, 0xb6ebce28, 0xb6ec1048, 0xb6ebc6d0, 0xb6ec1048) = 0
mprotect(0xb6cef000, 4096, PROT_READ)   = 0
mprotect(0xb6e1b000, 8192, PROT_READ)   = 0
mprotect(0xb6e56000, 4096, PROT_READ)   = 0
mprotect(0xb6e73000, 4096, PROT_READ)   = 0
mprotect(0xb6e80000, 4096, PROT_READ)   = 0
mprotect(0xb6ec0000, 4096, PROT_READ)   = 0
munmap(0xb6e82000, 59405)               = 0
set_tid_address(0xb6ebc278)             = 4042
set_robust_list(0xb6ebc280, 0xc)        = 0
futex(0xbed747d8, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 1, NULL, b6e74000) = -1 EAGAIN (Resource temporarily unavailable)
rt_sigaction(SIGRTMIN, {0xb6e5d20c, [], SA_SIGINFO|0x4000000}, NULL, 8) = 0
rt_sigaction(SIGRT_1, {0xb6e5d0b4, [], SA_RESTART|SA_SIGINFO|0x4000000}, NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
getrlimit(RLIMIT_STACK, {rlim_cur=8192*1024, rlim_max=RLIM_INFINITY}) = 0
readlink("/etc/je_malloc.conf", 0xbed73690, 4096) = -1 ENOENT (No such file or directory)
brk(0)                                  = 0xb7ad8000
mmap2(NULL, 4194304, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6880000
munmap(0xb6880000, 4194304)             = 0
mmap2(NULL, 8384512, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6481000
munmap(0xb6481000, 3665920)             = 0
munmap(0xb6c00000, 524288)              = 0
open("/proc/stat", O_RDONLY|O_CLOEXEC)  = 3
read(3, "cpu  21606 0 14834 7168081 2675 "..., 8192) = 1317
close(3)                                = 0
brk(0xb7af9000)                         = 0xb7af9000
open("/proc/self/maps", O_RDONLY)       = 3
getrlimit(RLIMIT_STACK, {rlim_cur=8192*1024, rlim_max=RLIM_INFINITY}) = 0
fstat64(3, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6ebb000
read(3, "b6800000-b6c00000 rw-p 00000000 "..., 1024) = 1024
read(3, "ihf/libgcc_s.so.1\nb6e49000-b6e4f"..., 1024) = 1024
read(3, "nueabihf/libdl-2.13.so\nb6e81000-"..., 1024) = 1024
close(3)                                = 0
munmap(0xb6ebb000, 4096)                = 0
sched_getaffinity(4042, 32, {1})        = 4
mmap2(0xbe575000, 4096, PROT_NONE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xbe575000
rt_sigaction(SIGSEGV, {0xb6ecd52c, [], SA_STACK|SA_SIGINFO|0x4000000}, NULL, 8) = 0
rt_sigaction(SIGBUS, {0xb6ecd52c, [], SA_STACK|SA_SIGINFO|0x4000000}, NULL, 8) = 0
mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6eba000
sigaltstack({ss_sp=0xb6eba000, ss_flags=0, ss_size=8192}, NULL) = 0
mmap2(NULL, 4194304, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6400000
rt_sigaction(SIGPIPE, {SIG_IGN, [PIPE], SA_RESTART|0x4000000}, {SIG_DFL, [], 0}, 8) = 0
write(1, "Hello, world!\n", 14Hello, world!
)         = 14
munmap(0xb6eba000, 8192)                = 0
exit_group(0)                           = ?
warricksothr commented 8 years ago

It's your linker. I bet it's built for crosslinking ARMv7.

I just put together a container with Debian Wheezy and the Raspberry Pi's Rasbian GCC 4.8.3 crosslinker and those builds work on my Raspberry Pi B.

In my Debian Wheezy container with the Raspbian Cross Linker

root@add04ae671e8:~/dev/rust/hello_world# cat hello.rs
pub fn main() {
        println!("Hello World!");
}
root@add04ae671e8:~/dev/rust/hello_world# rustc -C linker=arm-linux-gnueabihf-gcc --target=arm-unknown-linux-gnueabihf hello.rs
root@add04ae671e8:~/dev/rust/hello_world# file hello
hello: ELF 32-bit LSB shared object, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.26, BuildID[sha1]=0x3e2dd5817ed574d3a57b80a51ae972d8bb22d9cb, not stripped
root@add04ae671e8:~/dev/rust/hello_world# scp hello pi@192.168.2.117:~

On My Raspberry Pi B

pi@raspberrypi ~ $ ./hello
Hello World!

Also the file sizes for the natively compiled vs the cross compiles are much closer now.


pi@raspberrypi ~ $ ls -al
...
-rwxr-xr-x 1 pi   pi   435390 Oct  9 00:32 hello # <- The Cross Compiled Binary
-rwxr-xr-x 1 pi   pi   435724 Oct  8 21:20 main # <- The Natively Compiled Binary
...

I've done the work of creating a docker image that contains everything necessary to build rust stable 1.3.0 cross compiled binaries for ARMv6 devices with atleast glibc 2.13+

It's on docker hub as sothr/rustbuild:armv6-crosscompile

https://hub.docker.com/r/sothr/rustbuild/