今天scratchbox又出了点小问题
弄好了交叉编译工具之后,编译/scratchbox/packages目录下的hello world
gcc hello.c
看一下输出文件
[sbox-arm: /scratchbox/packages] > file a.out
a.out: ELF 32-bit LSB executable, ARM, version 1 (ARM), for GNU/Linux 2.4.3, dynamically linked (uses shared libs), not stripped
确实是arm的
可是执行时
[sbox-arm: /scratchbox/packages] > ./a.out
mmap: Permission denied
什么问题?
索性执行一下/scratchbox/packages/tests/init目录下的init_tests.sh脚本
[sbox-arm: /scratchbox/packages/tests/init] > ./init_tests.sh
Starting test: compile
Finishing test: compile, result: OK
Starting test: type
/home/tom/init.9379/hello: ELF 32-bit LSB executable, ARM, version 1 (ARM), for GNU/Linux 2.4.3, dynamically linked (uses shared libs), not stripped
/home/tom/init.9379/hello-static: ELF 32-bit LSB executable, ARM, version 1 (ARM), for GNU/Linux 2.4.3, statically linked, not stripped
/home/tom/init.9379/hellocc: ELF 32-bit LSB executable, ARM, version 1 (ARM), for GNU/Linux 2.4.3, dynamically linked (uses shared libs), not stripped
/home/tom/init.9379/hellocc-static: ELF 32-bit LSB executable, ARM, version 1 (ARM), for GNU/Linux 2.4.3, statically linked, not stripped
Finishing test: type, result: OK
Starting test: dependencies
/home/tom/init.9379/hello
libc.so.6 => /lib/libc.so.6 (0x00000000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x00000000)
/home/tom/init.9379/hellocc
libstdc++.so.6 => /lib/libstdc++.so.6 (0x00000000)
libm.so.6 => /lib/libm.so.6 (0x00000000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00000000)
libc.so.6 => /lib/libc.so.6 (0x00000000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x00000000)
/home/tom/init.9379/hello-static
not a dynamic executable
/home/tom/init.9379/hellocc-static
not a dynamic executable
Finishing test: dependencies, result: OK
Starting test: strip
Finishing test: strip, result: OK
Starting test: execute
mmap: Permission denied
mmap: Permission denied
mmap: Permission denied
mmap: Permission denied
Finishing test: execute, result: ERROR
还是一样的问题,是运行程序时出现的问题
google一下
发现是/proc/sys/vm/mmap_min_addr的问题
记得构建openembedded和基于oe的openmoko编译环境时也要修改它
On current Ubuntu/Debian unstable/testing boxes another trick is necessary. glibc_2.6.1 fails to build since it is unable to generate the necessary locales until you type in the following line:
sudo sysctl -w vm.mmap_min_addr=0
Note that this temporarily disables a new security vulnerability check that has entered /etc/sysctrl - but that makes problems with loads of applications.
To re-enable this check do the following:
sudo sysctl -w vm.mmap_min_addr=65536
在主机上输入
sudo sysctl -w vm.mmap_min_addr=0
搞定