Open
binutil-2.41 BFD 不支持arm64le #206
eggprozAdd on  Apr 28
eggproz
eggproz
Apr 28 Create

【缺陷描述】:请补充详细的缺陷问题现象描述

The input file is a valid ELF64 little-endian AArch64 relocatable object.
readelf recognizes it as:
Class: ELF64
Data: little endian
Type: REL
Machine: AArch64

# objcopy --help| grep "supported targets" -C1
     --info                        List object formats & architectures supported
objcopy: supported targets: elf64-x86-64 elf32-i386 elf32-iamcu elf32-x86-64 pei-i386 pe-x86-64 pei-x86-64 elf64-little elf64-big elf32-little elf32-big pe-bigobj-x86-64 pe-i386 pdb srec symbolsrec verilog tekhex binary ihex plugin
Report bugs to <https://gitee.com/src-openeuler/binutils/issues/>

# strip klp_C_vmlinux_2.ko
strip: Unable to recognise the format of the input file `klp_C_vmlinux_2.ko'

# strip --version
GNU strip (GNU Binutils) 2.41
Copyright (C) 2023 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) any later version.
This program has absolutely no warranty.

# objcopy --version
GNU objcopy (GNU Binutils) 2.41
Copyright (C) 2023 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) any later version.
This program has absolutely no warranty.

# readelf -h klp_C_vmlinux_2.ko
ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              REL (Relocatable file)
  Machine:                           AArch64
  Version:                           0x1
  Entry point address:               0x0
  Start of program headers:          0 (bytes into file)
  Start of section headers:          296336 (bytes into file)
  Flags:                             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           0 (bytes)
  Number of program headers:         0
  Size of section headers:           64 (bytes)
  Number of section headers:         56
  Section header string table index: 55

However, our maintained binutils 2.41 objcopy maps the input BFD architecture to bfd_arch_unknown and fails in copy_object() when calling bfd_set_arch_mach().

if (bfd_get_arch (ibfd) == bfd_arch_unknown)
	non_fatal (_("Unable to recognise the format of the input file `%s'"),
		   bfd_get_archive_filename (ibfd));

readelf -h ./klp_C_vmlinux_2.ko
ELF Header:
Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
Class: ELF64
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: REL (Relocatable file)
Machine: AArch64
Version:

一、缺陷信息

使用openEuler binutils-2.41

【缺陷所属的os版本】

openEuler-22.03-LTS
openEuler-24.03-LTS

【内核版本】

kernel-4.12.14

【缺陷所属软件及版本号】

kernel-4.12.14

【环境信息】

硬件信息

  • 提供跟硬件相关的信息,如架构、cpu和内存规格等
  • 虚拟机场景,额外补充宿主机os版本类型

软件信息

  • 跟缺陷所属软件相关的其它软件版本信息(如软件包构建失败由gcc引起,请填写gcc的版本号)

网络信息

  • 如果有特殊组网,请提供网络拓扑信息以及网络数据走向

【问题复现步骤】

制作任意一个 ELF64 little-endian AArch64 relocatable object.
使用strip 处理该二进制;

# strip klp_C_vmlinux_2.ko
strip: Unable to recognise the format of the input file `klp_C_vmlinux_2.ko'

【实际结果】

出现Unable to recognise the format of the input file

【期望结果】

正常工作,无报错

【其他相关附件信息】

【缺陷详情及分析指导参考链接】

二、缺陷分析结构反馈
影响性分析说明:

缺陷严重等级:(Critical/High/Moderate/Low)

缺陷根因说明:

受影响版本排查(受影响/不受影响):
openEuler-20.03-LTS-SP4
openEuler-22.03-LTS-SP3
openEuler-22.03-LTS-SP4
openEuler-24.03-LTS
openEuler-24.03-LTS-SP1
openEuler-24.03-LTS-SP2

修复是否涉及abi变化(是/否):
openEuler-20.03-LTS-SP4
openEuler-22.03-LTS-SP3
openEuler-22.03-LTS-SP4
openEuler-24.03-LTS
openEuler-24.03-LTS-SP1
openEuler-24.03-LTS-SP2

likedislike
openeuler-ci-botopeneuler-ci-botCollaborators
Apr 28 Added label: sig/Compiler
openeuler-ci-bot
openeuler-ci-botCollaborators
Apr 28 Comments:

Welcome To openEuler Community

Hey @eggproz , thanks for your contribution to the community.

Bot Usage Manual

I'm the Bot here serving you. You can find the instructions on how to interact with me at Here . That means you can comment below every pull request or issue to trigger Bot Commands.

Contact Guide

If you have any questions, please contact the SIG: Compiler ,
and any of the maintainers: @SegFault, @alexanderbill, @cf-zhao, @chenzheng1030, @eastb233, @kuenking111_admin, @li-yancheng, @wangqiang95, @wd-gitcode ,

likedislike
openeuler-ci-botopeneuler-ci-botCollaborators
Apr 28 Assign alexanderbill as responsible person
openeuler-ci-botopeneuler-ci-botCollaborators
Apr 28 Modify description of issue
openeuler-ci-bot
openeuler-ci-botCollaborators
Apr 28 Comments:

以下的要求不是强制性的, 未按模板评论时对issue无任何影响
issue处理注意事项:
1. 当前issue受影响的分支提交pr时, 须在pr描述中填写当前issue编号进行关联, 否则无法关闭当前issue;
2. 模板内容需要填写完整, 无论是受影响或者不受影响都需要填写完整内容,未引入的分支不需要填写, 否则无法关闭当前issue;
3. 以下为模板中需要填写完整的内容, 请复制到评论区回复, 注: 内容的标题名称(影响性分析说明, 缺陷严重等级, 受影响版本排查(受影响/不受影响), 修复是否涉及abi变化(是/否))不能省略,省略后defect-manager将无法正常解析填写内容.
评论区可能使用到的指令说明:

指令 指令说明 使用权限
/check-issue 触发defect-manager校验 不限
/reason xxx /reason +挂起或取消条件 不限

影响性分析说明:

缺陷严重等级:(Critical/High/Moderate/Low)

缺陷根因说明:

受影响版本排查(受影响/不受影响):

  1. openEuler-20.03-LTS-SP4:
  2. openEuler-22.03-LTS-SP3:
  3. openEuler-22.03-LTS-SP4:
  4. openEuler-24.03-LTS:
  5. openEuler-24.03-LTS-SP1:
  6. openEuler-24.03-LTS-SP2:

abi变化(是/否):

  1. openEuler-20.03-LTS-SP4:
  2. openEuler-22.03-LTS-SP3:
  3. openEuler-22.03-LTS-SP4:
  4. openEuler-24.03-LTS:
  5. openEuler-24.03-LTS-SP1:
  6. openEuler-24.03-LTS-SP2:

缺陷issue处理具体操作请参考:
https://atomgit.com/openeuler/cve-manager/blob/master/cve-vulner-manager/doc/md/defect-manager-manual.md
pr关联issue具体操作请参考:
https://docs.atomgit.com/docs/help/home/org_project/pullrequests/pr-related-issue

likedislike
openeuler-ci-botopeneuler-ci-botCollaborators
Apr 28 Added label: DEFECT/UNFIXED
eastb233
eastb233Collaborators
Apr 30 Comments:

当前工具是只支持native架构的处理,比如x86下的binutils包只支持x86格式文件的处理,不支持aarch64格式文件的处理

likedislike
eastb233eastb233Collaborators
Apr 30 Removed responsible person alexanderbill
eastb233eastb233Collaborators
Apr 30 Assign eastb233 as responsible person
huijing_zhanghuijing_zhang
6 days ago Associated pull request
huijing_zhang
huijing_zhang
6 days ago Comments:

已定位根因并在 openEuler-26.09 分支提交修复:PR #468。

根因:spec 中 x86_64 原生构建仅启用了 x86_64-pep 与 bpf-unknown-none 两个额外 BFD 目标,未启用 aarch64 后端,因此 BFD 将 aarch64 ELF 识别为 bfd_arch_unknown,strip/objcopy 报 Unable to recognise the format of the input file。

修复:为 x86_64 主机在 --enable-targets 中加入 aarch64-linux,其余架构不变,仅改 binutils.spec。

验证:用仓库自带 binutils-2.41 源码在 x86_64 实测,修复后 elf64-littleaarch64 出现在 objcopy --info 目标列表中,strip/objcopy 处理 ELF64 小端 AArch64 REL 目标文件(与 issue 中报错文件同类型)退出码 0。

likedislike