- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我有一个带有 Raspbian GNU/Linux 8 (Jessie) 操作系统的 Raspberry Pi 3。
我写了这个简单的程序。我用 gcc -o hello hello.c
编译了它。
#include <stdio.h>
void main(){
printf("hello!\n");
}
从 readelf 输出看来一切正常:
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
EXIDX 0x0004cc 0x000104cc 0x000104cc 0x00008 0x00008 R 0x4
PHDR 0x000034 0x00010034 0x00010034 0x00120 0x00120 R E 0x4
INTERP 0x000154 0x00010154 0x00010154 0x00019 0x00019 R 0x1
[Requesting program interpreter: /lib/ld-linux-armhf.so.3]
LOAD 0x000000 0x00010000 0x00010000 0x004d8 0x004d8 R E 0x10000
LOAD 0x000f0c 0x00020f0c 0x00020f0c 0x0011c 0x00120 RW 0x10000
DYNAMIC 0x000f18 0x00020f18 0x00020f18 0x000e8 0x000e8 RW 0x4
NOTE 0x000170 0x00010170 0x00010170 0x00044 0x00044 R 0x4
GNU_STACK 0x000000 0x00000000 0x00000000 0x00000 0x00000 RW 0x10
GNU_RELRO 0x000f0c 0x00020f0c 0x00020f0c 0x000f4 0x000f4 R 0x1
但是当我运行程序时,堆栈是可执行的:
0x7efdf000 0x7f000000 0x00000000 rwx [stack]
我也尝试使用选项 -z noexecstack
进行编译,但没有任何变化。
我也尝试下载具有此代码的 libarmmmem.so
版本:
#if defined(__linux__) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits
#endif
但没有任何改变。
为什么栈段在树莓派上是可执行的?
编辑我添加 LD_DEBUG=files ./hello 命令的输出
23110:
23110: file=/usr/lib/arm-linux-gnueabihf/libarmmem.so [0]; needed by ./hello [0]
23110: file=/usr/lib/arm-linux-gnueabihf/libarmmem.so [0]; generating link map
23110: dynamic: 0x76f273fc base: 0x76f13000 size: 0x00014524
23110: entry: 0x76f13568 phdr: 0x76f13034 phnum: 6
23110:
23110:
23110: file=libc.so.6 [0]; needed by ./hello [0]
23110: file=libc.so.6 [0]; generating link map
23110: dynamic: 0x76f0ef20 base: 0x76dd4000 size: 0x0013e550
23110: entry: 0x76dea840 phdr: 0x76dd4034 phnum: 10
23110:
23110:
23110: calling init: /lib/arm-linux-gnueabihf/libc.so.6
23110:
23110:
23110: calling init: /usr/lib/arm-linux-gnueabihf/libarmmem.so
23110:
23110:
23110: initialize program: ./hello
23110:
23110:
23110: transferring control: ./hello
23110:
hello!
23110:
23110: calling fini: ./hello [0]
23110:
23110:
23110: calling fini: /usr/lib/arm-linux-gnueabihf/libarmmem.so [0]
23110:
添加更多信息:我编辑文件 architecture.S,并在收到 make 之后:
gcc -std=gnu99 -O2 -c -o trampoline.o trampoline.c
gcc -shared -o libarmmem.so architecture.o memcmp.o memcpymove.o memcpymove-a7.o memset.o trampoline.o
`architecture' referenced in section `.text' of trampoline.o: defined in discarded section `.note.GNU-stack' of architecture.o
`architecture' referenced in section `.text' of trampoline.o: defined in discarded section `.note.GNU-stack' of architecture.o
`architecture' referenced in section `.text' of trampoline.o: defined in discarded section `.note.GNU-stack' of architecture.o
`architecture' referenced in section `.text' of trampoline.o: defined in discarded section `.note.GNU-stack' of architecture.o
collect2: error: ld returned 1 exit status
Makefile:13: recipe for target 'libarmmem.so' failed
make: *** [libarmmem.so] Error 1
最佳答案
很可能是 /usr/lib/arm-linux-gnueabihf/libarmmem.so
导致的。我找到了这个源文件:
它缺少不可执行的堆栈注释,因此 glibc 在预加载 DSO 时保守地使堆栈可执行。其他源文件有这个:
/* Prevent the stack from becoming executable */
#if defined(__linux__) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits
#endif
所以你只需要将它复制到architecture.S
(在文件末尾)并重建。
如果这个 DSO 确实是罪魁祸首,您可以使用 eu-readelf -l/usr/lib/arm-linux-gnueabihf/libarmmmem.so
进行验证。它应该根本不显示 GNU_STACK
程序头,或者在倒数第二列中标记为 RWE
的 GNU_STACK
程序头。
关于linux - 为什么堆栈段在树莓派上是可执行的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45253755/
(“ donut 派”)是否有最大切片数?我使用了 highchart(“ donut 派”)示例,但无法超过 10 个切片。请注意,内部切片“F”丢失了。下面是示例代码。 http://jsfidd
有谁知道如何找到 Samsung Galaxy 手机等同于 Settings.ACTION_ZEN_MODE_PRIORITY_SETTINGS 的常量?我有一个应用程序在三星用户单击应该将他们带到“
所以我很难弄清楚如何设置饼图/图例位置的布局。我希望图例左对齐,饼图右对齐。 40/60 百分比 -ish。 像这样: chart = new Highcharts.Chart({ c
我试图创建一种带有 4 个切片的圆形旋转木马,通过单击一个切片,它会扩展到约 2/3 的饼图,显示它的内容(另一个切片同样会收缩)基本上我是从 raphael “growing pie” 演示开始的
我尝试了所有可能的方式来提供 PIE.js 的路径,我使用的是 asp.net,这与在 java+tomcat 中的工作方式相同。我试过这样给 1)文件:css/home.css,css/pie/PI
cmds = ['time'] while True: inp = input('::> ') sinp = inp.split() if str(sinp[0]) in cm
我已经在 Raphael Google Groups 上看到过这个问题,但经过数小时的搜索后,在这里以及 Google 上,我似乎找不到解决方案。 我只是希望能够使用 jQuery 定位我的饼图(sv
这个问题在这里已经有了答案: Permission Denial: startForeground requires android.permission.FOREGROUND_SERVICE (5
我是一名优秀的程序员,十分优秀!