gali在Kali Linux上 [英] gcc on Kali Linux

查看:178
本文介绍了gali在Kali Linux上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题在于以下几点。当我在我的kali linux终端上写入 gcc print.s
时,出现以下错误:

  / usr / bin / ld:/tmp/cc45uyZj.o:在创建共享对象时,无法使用R_X86_64_32S和`.data';使用-fPIC 
/ usr / bin / ld重新编译:最终链接失败:输出中不具有代表性的部分
collect2:错误:ld返回1退出状态




  1. 在另一个linux发行版中,我尝试了相同的功能,并且工作得非常好。

  2. 添加-fPIC不起作用。如果您想查看代码: gitrel =nofollow noreferrer> https://github.com/NEGU93/Compilation.git 在Practice> Part1中。 (btw。所有.s文件在执行gcc时都有类似的错误)。



p>我猜在Kali发行版中丢失了一些东西,但我不知道它会是什么。

您的发行版默认启用 -pie (检查 gcc -v 输出),但您的程序集不是位置独立的。尝试编译 -fPIC 下的示例.c文件,并查看它如何生成调用。在你的情况下,它应该是

  call printf @ PLT 

,或者您可以尝试使用 gcc -no-pie 进行编译。


The problem is the following. When I write: gcc print.s on my kali linux terminal I get the following error:

/usr/bin/ld: /tmp/cc45uyZj.o: relocation R_X86_64_32S against `.data' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status

  1. I tried the same in another linux distribution and it worked perfectly.

  2. Adding -fPIC doesn't help. Nor does apt-get update.

  3. if you want to see the code: https://github.com/NEGU93/Compilation.git inside the Practice > Part1. Of course is the file print.s (btw. all the .s files have similar errors when I do gcc).

I guess something is missing in the Kali distro but I don't know what can it be.

解决方案

It seems that your distro enables -pie by default (check gcc -v output) but your assembly is not position-independent. Try compiling a sample .c file under -fPIC and see how it generates calls. In your case it should be

call    printf@PLT

or you can try compiling with gcc -no-pie.

这篇关于gali在Kali Linux上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆