程序仅使用特定内存

时间:2016-04-16 20:11:40

标签: linux gcc memory

我希望我的程序在32位linux上运行,只能使用低于0x0804800的内存。

我设法使用set / get / makecontext函数将堆栈移动到较低的地址,但是如何移动其余的可执行文件?

我尝试使用gcc -Ttext = addr,其中addr低于0x08048000,但在尝试运行生成的可执行文件时,我一直遇到分段错误。为什么呢?

简单的PoC给了我相同的结果:

poc.c

#include <stdio.h>
#include <stdlib.h>

int main()
{
    printf("abc\n");
    return 0;
}

编译:{{1​​}}

gcc版本4.8.4

0 个答案:

没有答案