Note: This bug is displayed in read-only format because
the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Description of problem:
binutils are not able to correctly read objects and binaries compiled with "clang -flto".
I tested this in RHEL-9.0 and Fedora 34+. In those environments the output is as expected.
This is reproducible in every supported arch.
How reproducible:
100%
Steps to Reproduce:
1. echo "void lto_function(){}" | clang -flto -O2 -c -x c -o foo.o -
2. nm foo.o
3. ar crs foo.a foo.o
4. readelf -c foo.a
Actual results:
[root@hpe-apollo-cn99xx-14-vm-25 ~]# echo "void lto_function(){}" | clang -flto -O2 -c -x c -o foo.o -
[root@hpe-apollo-cn99xx-14-vm-25 ~]# nm foo.o
nm: foo.o: file format not recognized
[root@hpe-apollo-cn99xx-14-vm-25 ~]# ar crs foo.a foo.o
[root@hpe-apollo-cn99xx-14-vm-25 ~]# readelf -c foo.a
foo.a has no archive index
readelf: foo.a: Error: foo.a: unable to dump the index as none was found
Expected results:
$ echo "void lto_function(){}" | clang -flto -O2 -c -x c -o foo.o -
$ nm foo.o
00000000 T lto_function
$ ranlib foo.a foo.o
ranlib: foo.o: file format not recognized
$ ar crs foo.a foo.o
$ readelf -c foo.a
Index of archive foo.a: (1 entries, 0xe bytes in the symbol table)
Contents of binary foo.a(foo.o) at offset 0x5a
lto_function
Right - I have found the problem. There is a bug in the BFD library. It does automatically load a plugin when needed, but it looks in the wrong place for it:
# strace nm foo.o |& grep plugin
openat(AT_FDCWD, "/usr/bin/../bin/../lib/bfd-plugins", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = -1 ENOENT (No such file or directory)
The LLVMgold.so plugin is in the /usr/lib64/bfd-plugins directory not the /usr/lib/bfd-plugins directory.
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.
For information on the advisory (binutils bug fix and enhancement update), and where to find the updated
files, follow the link below.
If the solution does not work for you, open a new bug report.
https://access.redhat.com/errata/RHBA-2023:2949
Description of problem: binutils are not able to correctly read objects and binaries compiled with "clang -flto". I tested this in RHEL-9.0 and Fedora 34+. In those environments the output is as expected. This is reproducible in every supported arch. How reproducible: 100% Steps to Reproduce: 1. echo "void lto_function(){}" | clang -flto -O2 -c -x c -o foo.o - 2. nm foo.o 3. ar crs foo.a foo.o 4. readelf -c foo.a Actual results: [root@hpe-apollo-cn99xx-14-vm-25 ~]# echo "void lto_function(){}" | clang -flto -O2 -c -x c -o foo.o - [root@hpe-apollo-cn99xx-14-vm-25 ~]# nm foo.o nm: foo.o: file format not recognized [root@hpe-apollo-cn99xx-14-vm-25 ~]# ar crs foo.a foo.o [root@hpe-apollo-cn99xx-14-vm-25 ~]# readelf -c foo.a foo.a has no archive index readelf: foo.a: Error: foo.a: unable to dump the index as none was found Expected results: $ echo "void lto_function(){}" | clang -flto -O2 -c -x c -o foo.o - $ nm foo.o 00000000 T lto_function $ ranlib foo.a foo.o ranlib: foo.o: file format not recognized $ ar crs foo.a foo.o $ readelf -c foo.a Index of archive foo.a: (1 entries, 0xe bytes in the symbol table) Contents of binary foo.a(foo.o) at offset 0x5a lto_function