免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3351 | 回复: 3
打印 上一主题 下一主题

请教内建函数 DATA_SEGMENT_ALIGN [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-08-07 15:18 |只看该作者 |倒序浏览
下边这段是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(.);

论坛徽章:
0
2 [报告]
发表于 2007-08-08 18:31 |只看该作者
偶也领悟领悟.

论坛徽章:
0
3 [报告]
发表于 2007-08-08 19:36 |只看该作者
看来版主最近在玩股。

2天了,还没有找到答案。

这段英文的意思我也不明白。

  1. the latter uses fewer commonpagesize
复制代码


其中的latter指的是什么好像不是很明确。

[ 本帖最后由 Benson_linux 于 2007-8-8 19:37 编辑 ]

论坛徽章:
0
4 [报告]
发表于 2007-08-12 14:27 |只看该作者
做个实验:

echo 'main(){}' > dummy.c

gcc dummy.c -Wl, --verbose &> dummy.log

然后观察 dummy.log 里面就有 DATA_SEGMENT_ALIGN()和DATA_SEGMENT_END()的输出。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP