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.

Bug 2148469

Summary: gcc: Attribute symver leads to linker failure with multiple symbol versions
Product: Red Hat Enterprise Linux 9 Reporter: Florian Weimer <fweimer>
Component: binutilsAssignee: Nick Clifton <nickc>
binutils sub component: system-version QA Contact: Miloš Prchlík <mprchlik>
Status: CLOSED ERRATA Docs Contact:
Severity: unspecified    
Priority: unspecified CC: ahajkova, berrange, dbelyavs, fweimer, jakub, jdenemar, mcermak, mprchlik, nickc, ohudlick, sipoyare
Version: 9.2Keywords: Bugfix, Triaged
Target Milestone: rcFlags: pm-rhel: mirror+
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: binutils-2.35.2-35.el9 Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-05-09 08:24:17 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 2124466, 2133809    

Description Florian Weimer 2022-11-25 15:17:57 UTC
Package versions:

binutils-2.35.2-24.el9.x86_64
gcc-11.3.1-2.1.el9.x86_64

This script produces a shared object with the expected alias:

cat > t.c <<EOF
int __attribute__ ((symver ("OPENSSL_strcasecmp.1"),
                    symver ("OPENSSL_strcasecmp@@OPENSSL_3.0.3")))
OPENSSL_strcasecmp (const char *a, const char *b)
{
  return 0;
}
EOF
cat > t.lds <<EOF
OPENSSL_3.0.1 {
  global: OPENSSL_strcasecmp;
  local: *;
};
OPENSSL_3.0.3 {
  global: OPENSSL_strcasecmp;
  local: *;
} OPENSSL_3.0.1;
EOF
gcc -Wall -O2 -shared -fpic t.c -Wl,--version-script t.lds

But replacing the final command does not:

gcc -flto -Wall -O2 -shared -fpic t.c -Wl,--version-script t.lds

/usr/bin/ld: /tmp/ccDIqhWD.ltrans0.ltrans.o: in function `OPENSSL_strcasecmp':
<artificial>:(.text+0x0): multiple definition of `OPENSSL_strcasecmp'
/usr/bin/ld: /tmp/ccDIqhWD.ltrans0.ltrans.o:(*IND*+0x0): multiple definition of `OPENSSL_strcasecmp'
collect2: error: ld returned 1 exit status

The assembler difference from LTO non-LTO mode appears to be:

 .LFE0:
 	.size	OPENSSL_strcasecmp, .-OPENSSL_strcasecmp
-	.symver	OPENSSL_strcasecmp, OPENSSL_strcasecmp.1
 	.symver	OPENSSL_strcasecmp, OPENSSL_strcasecmp@@OPENSSL_3.0.3
+	.symver	OPENSSL_strcasecmp, OPENSSL_strcasecmp.1
 	.ident	"GCC: (GNU) 11.3.1 20220421 (Red Hat 11.3.1-2)"
 	.section	.note.GNU-stack,"",@progbits

And the symbol table order is similarly transposed:

     7: 0000000000000000      0 SECTION LOCAL  DEFAULT        4 
     8: 0000000000000000      3 FUNC    GLOBAL DEFAULT        1 OPENSSL_strcasecmp
-    9: 0000000000000000      3 FUNC    GLOBAL DEFAULT        1 OPENSSL_strcasecmp@@OPENSSL_3.0.3
-   10: 0000000000000000      3 FUNC    GLOBAL DEFAULT        1 OPENSSL_strcasecmp.1
+    9: 0000000000000000      3 FUNC    GLOBAL DEFAULT        1 OPENSSL_strcasecmp.1
+   10: 0000000000000000      3 FUNC    GLOBAL DEFAULT        1 OPENSSL_strcasecmp@@OPENSSL_3.0.3

I'm not sure if these are the differences that trigger the linker failure.

Nick, does this look like a binutils issue to you?

Comment 4 Nick Clifton 2022-11-28 12:24:01 UTC
(In reply to Florian Weimer from comment #0)
Hi Florian,
 
> gcc -Wall -O2 -shared -fpic t.c -Wl,--version-script t.lds
> gcc -flto -Wall -O2 -shared -fpic t.c -Wl,--version-script t.lds
 
> /usr/bin/ld: /tmp/ccDIqhWD.ltrans0.ltrans.o: in function
> `OPENSSL_strcasecmp':
> <artificial>:(.text+0x0): multiple definition of `OPENSSL_strcasecmp'
 
> Nick, does this look like a binutils issue to you?

Definitely.  Well 90%.  I suppose that there is a possibility that
this will turn out to be a bug in the lto plugin, rather than the
linker itself.

Would you mind filing this upstream ?

Cheers
  Nick

Comment 5 Nick Clifton 2022-11-28 13:22:33 UTC
Never mind.  I have found that the bug was fixed upstream some time between 2.37 and 2.38.

Reassigning to me...

Comment 6 Nick Clifton 2022-11-28 16:17:00 UTC
Found it: https://sourceware.org/bugzilla/show_bug.cgi?id=28264

Working on a patch...

Comment 7 Nick Clifton 2022-11-30 09:59:01 UTC
Fixed in binutils-2.35.2-26.el9

Comment 12 Miloš Prchlík 2023-01-09 08:33:03 UTC
Verified with binutils-2.35.2-33.el9.

Comment 20 Nick Clifton 2023-01-11 11:00:51 UTC
Right - should be fixed in binutils-2.35.2-35.el9

Comment 21 Miloš Prchlík 2023-01-19 16:04:35 UTC
Verified with binutils-2.35.2-35.el9.

Comment 23 errata-xmlrpc 2023-05-09 08:24:17 UTC
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:2548