如何设置内存属性 [英] How to set memory properties

查看:119
本文介绍了如何设置内存属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

某些API / SDK可用于修改设置,例如可读,

" writeable"或者可执行的。

示例:

-
http://msdn.microsoft.com/library/en..._constants.asp

- http://www.opengroup.org/onlinepubs/。 ../mprotect.html

- http ://en.wikipedia.org/wiki/PaX

伴侣功能是否适合realloc编程接口



更改这些属性?

这些标志的管理是标准C库的一部分

已经?
http://en.wikipedia.org/wiki/ Malloc


我想在初始分配后实现更新为只读的内存区域。




问候,

Markus

解决方案

Ma ************ @ web.de 写道:

某些API / SDK可用于修改可读,可写和可写等设置。或者可执行的。
例子:
- http://msdn.microsoft.com/library/en..._constants.asp
- http://www.opengroup.org/onlinepubs/.../mprotect.html
- http://en.wikipedia.org/wiki/PaX

伴随功能是否适合realloc?编程接口
改变这样的属性?


可能会设计出一个设计。

这些标志的管理是否已经成为标准C库的一部分
了?
http://en.wikipedia.org/wiki/Malloc

编号标准认为某些内存可能是只读的,但不需要能力

并且无法控制它。 Fancier属性如

可以忘记内容或者可能按顺序使用

甚至没有梦想过;它们属于特定平台优化的总标题。

我想实现更新为只读的内存区域
初步分配。




大多数实际实现处理内存

页面中的属性。等级,这可能会使任意

属性难以应用于已经获取的内存:如果它们与已经从

同一页?我想你需要一个将这些数据复制到某个地方

else并给它这些属性界面,或者分配

一些记忆,其属性我以后可以改变而不会吹起宇宙中的
那类的东西。如果您考虑可执行文件,后者可能更可取

属性并不能生成

与位置无关的代码。


-

Eric Sosman
es ***** @ acm-dot-org.inva lid


< blockquote>文章< 11 ********************** @ g49g2000cwa.googlegroups .com> ;,

< Ma ** **********@web.de>写道:

:某些API / SDK可用于修改设置,例如可读,

:可写"或者可执行的。


:这些标志的管理是否是标准C库的一部分

:已经?

No.


:我想实现更新为只读的内存区域

:初始分配后。


我似乎记得在C ++中听说过这样的属性,但不是在
C中 - 至少在C89中没有。 C中的'const'属性在编译器级别处理,而不是OS级别。


一般来说,C标准否定所有知识

OS设施超出了狭义定义的
文件I / O运算符的存在。 C不需要内存保护

根本不存在。

-

你会从这个男人那里买一个二手钻头吗? ?


> >这些标志的管理是否是标准

C库的一部分?
http://en.wikipedia.org/wiki/Malloc



否。标准认可某些内存可能是只读的,但不需要该功能,并且无法控制它。 Fancier属性如
可以忘记内容等等。或可能按顺序使用
甚至没有梦想过;它们属于特定于平台的优化的总标题。




是否有可能将这种功能添加到

标准API?


问候,

Markus


Some APIs/SDKs are available to modify settings like "readable",
"writeable" or "executeable".
Examples:
-
http://msdn.microsoft.com/library/en..._constants.asp
- http://www.opengroup.org/onlinepubs/.../mprotect.html
- http://en.wikipedia.org/wiki/PaX

Would a companion function fit to the "realloc" programming interface
to
change such properties?
Is the management of such flags a part of the standard C library
already?
http://en.wikipedia.org/wiki/Malloc

I imagine to implement memory areas that are updated to be "read-only"
after an initial assignment.

Regards,
Markus

解决方案

Ma************@web.de wrote:

Some APIs/SDKs are available to modify settings like "readable",
"writeable" or "executeable".
Examples:
-
http://msdn.microsoft.com/library/en..._constants.asp
- http://www.opengroup.org/onlinepubs/.../mprotect.html
- http://en.wikipedia.org/wiki/PaX

Would a companion function fit to the "realloc" programming interface
to
change such properties?
A design might be worked out.
Is the management of such flags a part of the standard C library
already?
http://en.wikipedia.org/wiki/Malloc
No. The Standard recognizes the possibility that some
memory may be read-only, but does not require the capability
and provides no way to control it. Fancier attributes like
"okay to forget the content" or "likely to be used sequentially"
are not even dreamt of; they fall under the general heading of
platform-specific optimizations.
I imagine to implement memory areas that are updated to be "read-only"
after an initial assignment.



Most actual implementations handle attributes at a "memory
page" level, which could make it difficult to apply arbitrary
attributes to already-acquired memory: what if they conflict
with the attributes of other regions already allocated from the
same page? I think you''d need either a "copy this data somewhere
else and give it these attributes" interface, or else an "allocate
some memory whose attributes I can later change without blowing
up the Universe" sort of thing. The latter might be preferable
if you contemplate an "executable" attribute and cannot generate
position-independent code.

--
Eric Sosman
es*****@acm-dot-org.invalid


In article <11**********************@g49g2000cwa.googlegroups .com>,
<Ma************@web.de> wrote:
:Some APIs/SDKs are available to modify settings like "readable",
:"writeable" or "executeable".

:Is the management of such flags a part of the standard C library
:already?

No.

:I imagine to implement memory areas that are updated to be "read-only"
:after an initial assignment.

I seem to recall hearing of such a property in C++, but not in
C -- at least not in C89. The ''const'' attribute in C is handled at
the compiler level, not the OS level.

Generally speaking, the C standard disavows all knowledge of the
OS facilities beyond the existance of the narrowly-defined
file I/O operators. C does not require that memory protection
exists on the system at all.
--
Would you buy a used bit from this man??


> > Is the management of such flags a part of the standard

C library already?
http://en.wikipedia.org/wiki/Malloc



No. The Standard recognizes the possibility that some
memory may be read-only, but does not require the capability
and provides no way to control it. Fancier attributes like
"okay to forget the content" or "likely to be used sequentially"
are not even dreamt of; they fall under the general heading of
platform-specific optimizations.



Are there any chances that this kind of functionality can be added to
the standard API?

Regards,
Markus


这篇关于如何设置内存属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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