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.
This is essentially a clone of bug 1790475, filed for tracking purposes.
This program:
static void alias (void) __attribute__ ((weakref ("implementation")));
const void *const ptr = alias;
Produces this construct:
.section ".toc","aw"
.align 3
.section ".text"
.machine power7
.globl ptr
.weakref alias, implementation
.section .rodata
.align 3
.type ptr, @object
.size ptr, 8
ptr:
.quad alias
.ident "GCC: (GNU) 4.8.5 20150623 (Red Hat 4.8.5-39)"
.section .note.GNU-stack,"",@progbits
The problem is that with the POWER ELFv1 ABI, the address of implementation cannot be resolved by the link editor. It can live in a DSO. Until recently, binutils ld would produce a copy relocation for the OPD entry to cope with that, but those only work with lazy binding (see the binutils ld bug or bug 1790475). With the binutils fix, we get a text relocation instead. But that this is not an improvement.
With GCC 7, I get this instead, which avoids the problem entirely:
.section ".text"
.globl ptr
.weakref alias, implementation
.section .data.rel.ro,"aw",@progbits
.align 3
.type ptr, @object
.size ptr, 8
ptr:
.quad alias
.ident "GCC: (GNU) 7.3.1 20180303 (Red Hat 7.3.1-5)"
.section .note.GNU-stack,"",@progbits
I think we should verify that this is really fixed in later GCC versions which are included in DTS, so that we can safely pick up the upstream binutils fix there eventually, without generating text relocations.
I don't know if we should backport that fix into system GCC, but we should at least consider it.
This got fixed with https://gcc.gnu.org/r206784 aka https://gcc.gnu.org/ml/gcc-patches/2014-01/msg01169.html
Although it seems that the patch was written mainly with the other direction in mind, i.e. that even when
TREE_PUBLIC (tem) && targetm.binds_local_p (tem) (such as when the decl is hidden visibility) we could use reloc & 1
rather than reloc & 2, the weakref case is when !TREE_PUBLIC (tem) && !targetm.binds_local_p (tem) and in that case
it is just local convention that TREE_PUBLIC is clear, because the weakref target might not bind locally and so we need it in
writable or relro section rather than rodata.
So, I think we want to stay on the safe side, we could always patch it to
if (TREE_PUBLIC (tem) || !targetm.binds_local_p (tem))
reloc |= 2;
else
reloc |= 1;