如何把32位程序移植到64位平台上呢?zzzzz

drroot 2006-07-06 01:04:44
C代码请见附件:
http://www.newsmth.net/att.php?s.109.78548.1776.gz

在32位Linux上编译一切正常(无任何warning),但在64位Linux上编译出现如下问题:


gcc rad.c -static
rad.c:182:1: warning: "__syscall_return" redefined
In file included from /usr/include/asm/unistd.h:4,
from rad.c:110:
/usr/include/asm-x86_64/unistd.h:567:1: warning: this is the location of the previous definition
rad.c: In function `kwrite':
rad.c:334: warning: cast to pointer from integer of different size
rad.c: In function `exploit':
rad.c:487: warning: cast to pointer from integer of different size
rad.c:487: warning: cast to pointer from integer of different size
rad.c:501: warning: cast to pointer from integer of different size
/tmp/cc0fYo7M.s: Assembler messages:
/tmp/cc0fYo7M.s:119: Error: `pusha' is not supported in 64-bit mode
/tmp/cc0fYo7M.s:120: Error: suffix or operands invalid for `push'
/tmp/cc0fYo7M.s:121: Error: suffix or operands invalid for `push'
/tmp/cc0fYo7M.s:128: Error: suffix or operands invalid for `push'
/tmp/cc0fYo7M.s:131: Error: suffix or operands invalid for `pop'
/tmp/cc0fYo7M.s:132: Error: suffix or operands invalid for `pop'
/tmp/cc0fYo7M.s:133: Error: `popa' is not supported in 64-bit mode
/tmp/cc0fYo7M.s:147: Error: `pusha' is not supported in 64-bit mode
/tmp/cc0fYo7M.s:149: Error: suffix or operands invalid for `push'
/tmp/cc0fYo7M.s:149: Error: suffix or operands invalid for `pop'
/tmp/cc0fYo7M.s:149: Error: `popa' is not supported in 64-bit mode


1.怎么修改这个code让它支持64位呢?
2.按理现在64位Linux都能兼容32位程序,如何以32位模式编译C代码呢?



...全文
232 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
sanhua99999 2006-07-06
  • 打赏
  • 举报
回复
需要在编译中加上64位编译模式吧

你用的gcc版本多少?

69,369

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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