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.
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
Not a GCC bug.