我想在我的 ARM 项目中使用 libftdi。我构建了 libftdi,所有示例都可以正常工作。
程序:
#include <stdio.h>
int main()
{
printf("hello world\n");
return 0;
}
编译:
/usr/local/arm/4.3.4-armv4t-arm920t-eabi/usr/bin/arm-linux-gcc main.cpp -lftdi
strace 输出:
execve("./unwork", ["./unwork"], [/* 17 vars */]) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40005000
open("/lib/libftdi.so.1", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0755, st_size=59028, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40006000
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\370\24\0\0004\0\0\0\24"..., 4096) = 4096
mmap2(NULL, 57344, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x4000e000
mmap2(0x4000e000, 20744, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0x4000e000
mmap2(0x4001b000, 740, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x5) = 0x4001b000
close(3) = 0
munmap(0x40006000, 4096) = 0
open("/lib/libgcc_s.so.1", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=44280, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40006000
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0p'\0\0004\0\0\0\20"..., 4096) = 4096
mmap2(NULL, 77824, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x4001c000
mmap2(0x4001c000, 42492, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0x4001c000
mmap2(0x4002e000, 2072, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0xa) = 0x4002e000
close(3) = 0
munmap(0x40006000, 4096) = 0
open("/lib/libc.so.0", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0755, st_size=342748, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40006000
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\20\270\0\0004\0\0\0\364"..., 4096) = 4096
mmap2(NULL, 393216, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x4002f000
mmap2(0x4002f000, 335672, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0x4002f000
mmap2(0x40089000, 5112, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x52) = 0x40089000
mmap2(0x4008b000, 15120, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x4008b000
close(3) = 0
munmap(0x40006000, 4096) = 0
open("/home/xav/Projects/compile/libusb-compat/lib/libusb-0.1.so.4", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/xav/Projects/compile/libusb/lib/libusb-0.1.so.4", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/lib/libusb-0.1.so.4", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0755, st_size=44642, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40006000
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\24\21\0\0004\0\0\0$"..., 4096) = 4096
mmap2(NULL, 45056, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x4008f000
mmap2(0x4008f000, 11748, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0x4008f000
mmap2(0x40099000, 4012, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x2) = 0x40099000
close(3) = 0
munmap(0x40006000, 4096) = 0
open("/home/xav/Projects/compile/libusb-compat/lib/libusb-1.0.so.0", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/xav/Projects/compile/libusb/lib/libusb-1.0.so.0", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/lib/libusb-1.0.so.0", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0755, st_size=161417, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40006000
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\320\34\0\0004\0\0\0\200"..., 4096) = 4096
mmap2(NULL, 81920, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x4009a000
mmap2(0x4009a000, 45328, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0x4009a000
mmap2(0x400ad000, 1024, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0xb) = 0x400ad000
close(3) = 0
munmap(0x40006000, 4096) = 0
open("/home/xav/Projects/compile/libusb-compat/lib/librt.so.0", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/xav/Projects/compile/libusb/lib/librt.so.0", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/lib/librt.so.0", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0755, st_size=4752, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40006000
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0000\6\0\0004\0\0\0\210"..., 4096) = 4096
mmap2(NULL, 36864, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x400ae000
mmap2(0x400ae000, 3024, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0x400ae000
mmap2(0x400b6000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0x400b6000
close(3) = 0
munmap(0x40006000, 4096) = 0
open("/home/xav/Projects/compile/libusb-compat/lib/libpthread.so.0", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/xav/Projects/compile/libusb/lib/libpthread.so.0", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/lib/libpthread.so.0", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0755, st_size=52952, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40006000
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0 C\0\0004\0\0\0h"..., 4096) = 4096
mmap2(NULL, 110592, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x400b7000
mmap2(0x400b7000, 45132, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0x400b7000
mmap2(0x400ca000, 6808, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0xb) = 0x400ca000
mmap2(0x400cc000, 23368, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x400cc000
close(3) = 0
munmap(0x40006000, 4096) = 0
open("/home/xav/Projects/compile/libusb-compat/lib/libc.so.0", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/xav/Projects/compile/libusb/lib/libc.so.0", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/lib/libc.so.0", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0755, st_size=342748, ...}) = 0
close(3) = 0
open("/lib/libc.so.0", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0755, st_size=342748, ...}) = 0
close(3) = 0
open("/home/xav/Projects/compile/libusb/lib/libusb-1.0.so.0", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/lib/libusb-1.0.so.0", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0755, st_size=161417, ...}) = 0
close(3) = 0
open("/home/xav/Projects/compile/libusb/lib/librt.so.0", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/lib/librt.so.0", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0755, st_size=4752, ...}) = 0
close(3) = 0
open("/home/xav/Projects/compile/libusb/lib/libpthread.so.0", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/lib/libpthread.so.0", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0755, st_size=52952, ...}) = 0
close(3) = 0
open("/home/xav/Projects/compile/libusb/lib/libc.so.0", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/lib/libc.so.0", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0755, st_size=342748, ...}) = 0
close(3) = 0
open("/lib/librt.so.0", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0755, st_size=4752, ...}) = 0
close(3) = 0
open("/lib/libpthread.so.0", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0755, st_size=52952, ...}) = 0
close(3) = 0
open("/lib/libc.so.0", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0755, st_size=342748, ...}) = 0
close(3) = 0
open("/lib/libc.so.0", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0755, st_size=342748, ...}) = 0
close(3) = 0
open("/lib/libc.so.0", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0755, st_size=342748, ...}) = 0
close(3) = 0
stat("/lib/ld-uClibc.so.0", {st_mode=S_IFREG|0755, st_size=21200, ...}) = 0
mprotect(0x40089000, 4096, PROT_READ) = 0
mprotect(0x400b6000, 4096, PROT_READ) = 0
mprotect(0x400ca000, 4096, PROT_READ) = 0
mprotect(0x4000c000, 4096, PROT_READ) = 0
ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
getrlimit(RLIMIT_STACK, {rlim_cur=8192*1024, rlim_max=1074584348}) = 0
setrlimit(RLIMIT_STACK, {rlim_cur=2044*1024, rlim_max=1074584348}) = 0
getpid() = 479
rt_sigaction(SIGRTMIN, {0x400bd988, [], 0x4000000 /* SA_??? */}, NULL, 8) = 0
rt_sigaction(SIGRT_1, {0x400bd8ac, [RTMIN], 0x4000000 /* SA_??? */}, NULL, 8) = 0
rt_sigaction(SIGRT_2, {0x400bd224, [], 0x4000000 /* SA_??? */}, NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, [RTMIN], NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [RT_1], NULL, 8) = 0
--- SIGSEGV (Segmentation fault) @ 0 (0) ---
+++ killed by SIGSEGV +++
我得到“分段错误”而不是在 ARM 上运行。