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 1716785

Summary: relocation R_X86_64_PC32 against undefined hidden symbol `__dso_handle'
Product: Red Hat Enterprise Linux 8 Reporter: Prabhanjan Gururaj <prabhanjan.gururaj>
Component: gccAssignee: Marek Polacek <mpolacek>
gcc sub component: system-version QA Contact: qe-baseos-tools-bugs
Status: CLOSED NOTABUG Docs Contact:
Severity: high    
Priority: unspecified CC: ahajkova, fweimer, jakub, ohudlick
Version: 8.2   
Target Milestone: rc   
Target Release: 8.0   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-06-04 21:20:15 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:

Description Prabhanjan Gururaj 2019-06-04 06:03:03 UTC
Description of problem:
ld fails as below:
ld: /usr/lib64/libc_nonshared.a(pthread_atfork.oS): relocation R_X86_64_PC32 against undefined hidden symbol `__dso_handle' can not be used when making a shared object
ld: final link failed: Bad valu

Version-Release number of selected component (if applicable):
Red Hat Enterprise Linux 8.0 Beta (Ootpa)
kernel-4.18.0-74.el8.x86_64
gcc-c++-8.2.1-3.5.el8.x86_64
gcc-8.2.1-3.5.el8.x86_64



Details:

cc -w  -DLINUX -D_GNU_SOURCE -Werror -DNO_DLPI -D_REENTRANT  -DFLIGHT_RECORDER -DLIC_ENABLE -DRH8 -DLIBNL3 -DUSE_SYSTEMD -fpic  -I/usr/include/libnl3 -I/usr/include -Ih/linux -Ih -Iobjs/product -Ideadman_module -DSACTO -DQS -DENABLE_ENHANCED_SECURITY  -DOM_USE_TLS -o objs/product/libptmalloc_ws.o -c objs/product/libptmalloc_ws.c
Putting child 0x55b4f28faae0 (objs/product/libptmalloc_ws.o) PID 14489 on the chain.
Live child 0x55b4f28faae0 (objs/product/libptmalloc_ws.o) PID 14489
Reaping winning child 0x55b4f28faae0 PID 14489
Removing child 0x55b4f28faae0 PID 14489 from chain.
               Successfully remade target file 'objs/product/libptmalloc_ws.o'.
               Finished prerequisites of target file 'objs/product/libptmalloc.so'.
              Must remake target 'objs/product/libptmalloc.so'.


ld    -shared -o objs/product/libptmalloc.so objs/product/libptmalloc_ws.o objs/product/ptmalloc.o -lm -lc

Putting child 0x55b4f28faae0 (objs/product/libptmalloc.so) PID 14493 on the chain.
Live child 0x55b4f28faae0 (objs/product/libptmalloc.so) PID 14493
/usr/lib64/libc_nonshared.a(pthread_atfork.oS): In function `__pthread_atfork':
(.text+0x7): undefined reference to `__dso_handle'

ld: /usr/lib64/libc_nonshared.a(pthread_atfork.oS): relocation R_X86_64_PC32 against undefined hidden symbol `__dso_handle' can not be used when making a shared object

ld: final link failed: Bad value
Reaping losing child 0x55b4f28faae0 PID 14493
make: *** [build/platform_targets_linux.mk:132: objs/product/libptmalloc.so] Error 1



Expected results:
The same piece of code is getting built successfully on gcc 4.8. I am seeing this issue only after moving to gcc8.2 with rhel8.

Comment 1 Jakub Jelinek 2019-06-04 06:31:11 UTC
ld    -shared -o objs/product/libptmalloc.so objs/product/libptmalloc_ws.o objs/product/ptmalloc.o -lm -lc

This is the bug, you should never invoke ld directly unless you know exactly what you need to specify to get the linking right.
Instead, you should be using the gcc driver to do the linking, i.e.
gcc    -shared -o objs/product/libptmalloc.so objs/product/libptmalloc_ws.o objs/product/ptmalloc.o -lm

Comment 2 Marek Polacek 2019-06-04 21:20:15 UTC
Not a GCC bug.