Bug 1716785 - relocation R_X86_64_PC32 against undefined hidden symbol `__dso_handle'
Summary: relocation R_X86_64_PC32 against undefined hidden symbol `__dso_handle'
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: gcc
Version: 8.2
Hardware: x86_64
OS: Linux
unspecified
high
Target Milestone: rc
: 8.0
Assignee: Marek Polacek
QA Contact: qe-baseos-tools-bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-06-04 06:03 UTC by Prabhanjan Gururaj
Modified: 2023-07-18 14:19 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-06-04 21:20:15 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

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.


Note You need to log in before you can comment on or make changes to this bug.