请教内建函数 DATA_SEGMENT_ALIGN
下边这段是info ld里边的文档,一直没有看懂他的意思,哪位能解释一下。PS:网上的ld中文版本里边,到这个地方就没有翻译了。郁闷。。。。
DATA_SEGMENT_ALIGN(maxpagesize, commonpagesize)
This is equivalent to either
(ALIGN(maxpagesize) + (. & (maxpagesize - 1)))
or
(ALIGN(maxpagesize) + (. & (maxpagesize - commonpagesize)))
depending on whether the latter uses fewer commonpagesize sized pages for the data segment (area between the result of this expression and DATA_SEGMENT_END) than the former or not. If the latter form is used, it means commonpagesize bytes of runtime memory will be saved at the expense of up to commonpagesize wasted bytes in the on-disk file.
This expression can only be used directly in SECTIONS commands, not in any output section descriptions and only once in the linker script. commonpagesize should be less or equal to maxpagesize and should be the system page size the object wants to be optimized for (while still working on system page sizes up to maxpagesize).
Example:
. = DATA_SEGMENT_ALIGN(0x10000, 0x2000);
DATA_SEGMENT_END(exp)
This defines the end of data segment for DATA_SEGMENT_ALIGN evaluation purposes.
. = DATA_SEGMENT_END(.); 偶也领悟领悟. 看来版主最近在玩股。
2天了,还没有找到答案。
这段英文的意思我也不明白。
the latter uses fewer commonpagesize
其中的latter指的是什么好像不是很明确。
[ 本帖最后由 Benson_linux 于 2007-8-8 19:37 编辑 ] 做个实验:
echo 'main(){}' > dummy.c
gcc dummy.c -Wl, --verbose &> dummy.log
然后观察 dummy.log 里面就有 DATA_SEGMENT_ALIGN()和DATA_SEGMENT_END()的输出。
页:
[1]