写入文本段 [英] Writing to text segment

查看:69
本文介绍了写入文本段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

void foo(void){

/ * blah blah * /

}


char buf [] = { ....};

memcpy((void *)& foo,buf,sizeof buf);


这个东西在RHEL上给出了分段错误5 / gcc 4.1。文本

段是否受到保护?我假设foo有足够的空间用于buf。

void foo(void) {
/* blah blah */
}

char buf[] = {....};
memcpy( (void *)&foo, buf, sizeof buf);

This thing is giving segmentation fault on RHEL 5/gcc 4.1. Is the text
segment protected? I am assuming foo has enough space for buf.

推荐答案

rahul写道:
rahul wrote:

void foo(void){

/ * blah blah * /

}


char buf [] = {... 。};

memcpy((void *)& foo,buf,sizeof buf);


这件事在RHEL 5 / gcc上给出了分段错误4.1。文本

段是否受到保护?我假设foo有足够的空间用于buf。
void foo(void) {
/* blah blah */
}

char buf[] = {....};
memcpy( (void *)&foo, buf, sizeof buf);

This thing is giving segmentation fault on RHEL 5/gcc 4.1. Is the text
segment protected? I am assuming foo has enough space for buf.



我很惊讶你甚至设法得到它,无论如何,编译。


发布真实代码。


-

Ian Collins。

I''m amazed you even managed to get it, what ever it is, to compile.

Post real code.

--
Ian Collins.


2008年6月10日8:29 ,rahul写道:
On 10 Jun 2008 at 8:29, rahul wrote:

这件事在RHEL 5 / gcc 4.1上给出了分段错误。文本

段是否受到保护?
This thing is giving segmentation fault on RHEL 5/gcc 4.1. Is the text
segment protected?


objdump -ha


a:文件格式elf32-i386


部分:

Idx名称大小VMA LMA文件关闭Algn

[snip]

12 .text 0000016c 080482f0 080482f0 000002f0 2 ** 4

目录,ALLOC,LOAD,READONLY,CODE

[snip]


是的,在理智的操作系统上,文本段确实似乎是只读b
$ b。也许你的黑客尝试在Windows上会更好。

objdump -h a

a: file format elf32-i386

Sections:
Idx Name Size VMA LMA File off Algn
[snip]
12 .text 0000016c 080482f0 080482f0 000002f0 2**4
CONTENTS, ALLOC, LOAD, READONLY, CODE
[snip]

Yes, on sane operating systems the text segment does seem to be
read-only. Maybe your hacking attempts will fare better on Windows.


这篇关于写入文本段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆