Blob Blame History Raw
#
# In rhel-6.x the Makerules are not entirely as mature as they are
# in glibc 2.21 (from which the example link-libc-args is taken from).
# In rhel-6.x the applications are not built like their counterpart
# real applications, and because of that compiling DSOs that use TLS
# will fail with undefined references to __tls_get_addr which resides
# in ld.so and is never included in the link. This patch enhances
# only the build-module and build-module-asneeded targets to include
# a more fully and correct link line as the compiler driver would use
# when constructing an application or DSO. We do not adjust the link
# lines used to build lib* targets.
#
# The rest of this patch is brought in by glibc-rh1292018-0a.patch
# where we need to link against ld.so from libm.so.
#

commit fab7ce3f5b4060bf62659e8b58529de4156b5a2f
Author: Joseph Myers <joseph@codesourcery.com>
Date:   Fri May 31 16:16:33 2013 +0000

    Link extra-libs consistently with libc and ld.so.

diff -urN glibc-2.17-c758a686/Makerules glibc-2.17-c758a686/Makerules
--- glibc-2.17-c758a686/Makerules	2015-02-18 19:53:00.000000000 -0500
+++ glibc-2.17-c758a686/Makerules	2015-02-18 20:08:33.299000028 -0500
@@ -437,6 +437,25 @@
 load-map-file = $(map-file:%=-Wl,--version-script=%)
 endif
 
+# Compiler arguments to use to link a shared object with libc and
+# ld.so.  This is intended to be as similar as possible to a default
+# link with an installed libc.
+link-libc-args = -Wl,--start-group \
+                 $(libc-for-link) \
+                 $(common-objpfx)libc_nonshared.a \
+                 $(as-needed) $(elf-objpfx)ld.so $(no-as-needed) \
+                 -Wl,--end-group
+
+# The corresponding shared libc to use.  This may be modified for a
+# particular target.
+libc-for-link = $(common-objpfx)libc.so
+
+# The corresponding dependencies.  As these are used in dependencies,
+# not just commands, they cannot use target-specific variables so need
+# to name both possible libc.so objects.
+link-libc-deps = $(common-objpfx)libc.so $(common-objpfx)linkobj/libc.so \
+                 $(common-objpfx)libc_nonshared.a $(elf-objpfx)ld.so
+
 # Pattern rule to build a shared object from an archive of PIC objects.
 # This must come after the installation rules so Make doesn't try to
 # build shared libraries in place from the installed *_pic.a files.
@@ -518,12 +537,13 @@
 # not for shared objects
 define build-module
 $(build-module-helper) -o $@ $(shlib-lds-flags) \
-	  $(csu-objpfx)abi-note.o $(build-module-objlist)
+	  $(csu-objpfx)abi-note.o $(build-module-objlist) $(link-libc-args)
 endef
 define build-module-asneeded
 $(build-module-helper) -o $@ $(shlib-lds-flags) \
 	  $(csu-objpfx)abi-note.o \
-	  -Wl,--as-needed $(build-module-objlist) -Wl,--no-as-needed
+	  -Wl,--as-needed $(build-module-objlist) -Wl,--no-as-needed \
+	  $(link-libc-args)
 endef
 
 build-module-helper-objlist = \