【标题描述】gcc-10.3.1,在进行pie编译的时候,x86_64架构和arm64架构编译结果不同。
【环境信息】
硬件信息:
arm64环境
[root@localhost test]# lscpu
架构: aarch64
CPU 运行模式: 64-bit
字节序: Little Endian
CPU: 16
在线 CPU 列表: 0-15
厂商 ID: HiSilicon
BIOS Vendor ID: QEMU
型号名称: Kunpeng-920
BIOS Model name: virt-4.1
x86_64环境:
[test1@localhost test]$ lscpu
架构: x86_64
CPU 运行模式: 32-bit, 64-bit
Address sizes: 40 bits physical, 57 bits virtual
字节序: Little Endian
CPU: 12
在线 CPU 列表: 0-11
厂商 ID: GenuineIntel
型号名称: Intel Xeon Processor (Icelake)
CPU 系列: 6
型号: 134
每个核的线程数: 1
每个座的核数: 1
座: 12
步进: 0
BogoMIPS: 4800.00
软件信息:
1) OS版本及分支
[test1@localhost test]$ cat /etc/openEuler-release
openEuler release 22.03 (LTS-SP2)
2) 内核信息
[test1@localhost test]$ uname -r
5.10.0-146.0.0.75.oe2203sp2.x86_64
3) 发现问题的组件版本信息
gcc-10.3.1-27.oe2203sp2.x86_64
binutils-2.37-15.oe2203sp2.x86_64
【问题复现步骤】
x86_64架构
[test1@localhost test]$ gcc -o test main.c -Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/generic-hardened-ld -no-pie -lm
/usr/bin/ld: /tmp/ccQLtDcP.o: relocation R_X86_64_32 against `.rodata' can not be used when making a PIE object; recompile with -fPIE
collect2: 错误:ld 返回 1
arm64架构
[root@localhost test]# gcc -o test main.c -Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/generic-hardened-ld -lm
[root@localhost test]# file test
test: ELF 64-bit LSB pie executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, BuildID[sha1]=eed747246f449dcbd2f65c4ef4a05837968d82be, for GNU/Linux 3.7.0, not stripped
【预期结果】
根据手册,两个架构应该结果一样。
【实际结果】
根据gcc的手册,应该是ld的时候使用-pie,编译的时候组合使用-fpie/-fPIE,但是在arm64架构上并不需要组合。和手册描述不符。参看file结果,此时已经是pie的可执行程序了。
请解答一下原因。
Hi jane-jessica, welcome to the openEuler Community.
I'm the Bot here serving you. You can find the instructions on how to interact with me at Here.
If you have any questions, please contact the SIG: Compiler, and any of the maintainers: @Noah , @eastb233 , @kuen , @Peilin Guo , @Haijian.Zhang , @编译小伙 , @huangxiaoquan , @笨鸟不飞就是鸡 , @cf-zhao , @周磊 , @stubCode
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
登录 后才可以发表评论