relocation truncated to fit: R_386_16 against `.text' 以及 defined in discarded section `_TEXT'

brookmill 2008-11-25 03:36:54
用的是redhat 9,NASM 0.98.35
相关的代码差不多是这样:
func_table      dw      func1
dw func2
dw func3
dw func4

global my_func
my_func:
......

编译过了,链接的时候ld报错:
test.asm:(.text+0xc41): relocation truncated to fit: R_386_16 against `.text'
test.asm:(.text+0xc43): relocation truncated to fit: R_386_16 against `.text'
test.asm:(.text+0xc45): relocation truncated to fit: R_386_16 against `.text'
test.asm:(.text+0xc47): relocation truncated to fit: R_386_16 against `.text'
我用objdump看了test.o,0xc41就是源代码里的函数表

后来把代码加了两行:
section _DATA class=DATA public use16 algn=4
func_table dw func1
dw func2
dw func3
dw func4

section _TEXT class=CODE public use16 algn=4
global my_func
my_func:
......

还是ld出错,`my_func' referenced in section `.data' of patterns/entry.o: defined in discarded section `_TEXT' of test.o

请高手帮忙看看。谢谢!
...全文
2108 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
brookmill 2008-12-13
  • 打赏
  • 举报
回复
谢谢各位。

relocation truncated to fit: R_386_16 against `.text'
这个错误其实很简单,32位系统的函数表显然应该用dd而不是dw。
这段代码是以前16位系统的代码,没注意到这个问题。


xiaopoy 2008-12-11
  • 打赏
  • 举报
回复
说明太少了,有不知所谓的感觉

有一些可能是段属性的设置问题。希望更多点环境和情况描述
brookmill 2008-12-10
  • 打赏
  • 举报
回复
谢谢楼上两位。再顶一下,周末结帖
帅得不敢出门 2008-12-07
  • 打赏
  • 举报
回复
哈哈 无意路过 发现此贴.
的确很冷啊.
brookmill 2008-11-27
  • 打赏
  • 举报
回复
这个版真清静啊
都两天了,居然还在第1页
ZKM_ZHANG 2008-11-25
  • 打赏
  • 举报
回复
接分

21,496

社区成员

发帖
与我相关
我的任务
社区描述
汇编语言(Assembly Language)是任何一种用于电子计算机、微处理器、微控制器或其他可编程器件的低级语言,亦称为符号语言。
社区管理员
  • 汇编语言
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧