21 Star 26 Fork 89

src-openEuler / gcc

 / 详情

gcc-pie-arm64架构和操作手册结果不同

待办的
缺陷
创建于  
2023-06-06 10:11

【标题描述】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的可执行程序了。
请解答一下原因。

评论 (1)

Jane_Jessica 创建了缺陷

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

openeuler-ci-bot 添加了
 
sig/Compiler
标签

登录 后才可以发表评论

状态
负责人
项目
里程碑
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
开始日期   -   截止日期
-
置顶选项
优先级
预计工期 (小时)
参与者(2)
5329419 openeuler ci bot 1632792936
1
https://gitee.com/src-openeuler/gcc.git
git@gitee.com:src-openeuler/gcc.git
src-openeuler
gcc
gcc

搜索帮助