免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1729 | 回复: 4

[内核入门] 2.6.24的head_32.S的问题 [复制链接]

论坛徽章:
0
发表于 2013-05-10 10:00 |显示全部楼层
本帖最后由 aweii 于 2013-05-10 10:02 编辑

我在看2.6.24内核,linux/arch/x86/boot/compressed/head_32.S中,既然运行时被重定位了,那么连接时的标号地址就不准确了,怎么还能直接调用call decompress_kernel呢?相关代码如下:
……
call 1f
1:        popl %ebp
……
movl output_len(%ebx), %eax
        pushl %eax
        pushl %ebp        # output address
        movl input_len(%ebx), %eax
        pushl %eax        # input_len
        leal input_data(%ebx), %eax
        pushl %eax        # input_data
        leal _end(%ebx), %eax
        pushl %eax        # end of the image as third argument
        pushl %esi        # real mode pointer as second arg
        call decompress_kernel
        addl $20, %esp
        popl %ecx
……

既然用了input_len(%ebx), 说明代码是从0地址开始链接的,并且通过寄存器进行了重定位寻址,那么decompress_kernel应该
也是相对于0始址的偏移量(head_32.S和misc_32.c是一起链接的),当压缩内核移到到0x100000+X的地址开始解压缩前夕,decompress_kernel的实际位置显然和链接位置不一致,怎么还能用call decomress_kernel呢(没有重定位)?前面的call 1f 可以看做是短调用(二进制代码中用相对位移,无需重定位),而call decomress_kernel显然不是。

论坛徽章:
0
发表于 2013-05-10 11:24 |显示全部楼层
请大侠们解惑!

论坛徽章:
0
发表于 2013-05-10 11:42 |显示全部楼层
还不光decompress_kernel的定位问题,misc_32.c中定义的变量是不是也有定位问题啊

论坛徽章:
0
发表于 2013-05-10 12:28 |显示全部楼层
-fPIC,复杂了

论坛徽章:
0
发表于 2013-05-10 13:13 |显示全部楼层
call decompress_kernel 是短转移(相对寻址),而misc_32.c中是地址无关代码,不存在定位问题。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP