ce426f
#
ce426f
# In rhel-6.x the Makerules are not entirely as mature as they are
ce426f
# in glibc 2.21 (from which the example link-libc-args is taken from).
ce426f
# In rhel-6.x the applications are not built like their counterpart
ce426f
# real applications, and because of that compiling DSOs that use TLS
ce426f
# will fail with undefined references to __tls_get_addr which resides
ce426f
# in ld.so and is never included in the link. This patch enhances
ce426f
# only the build-module and build-module-asneeded targets to include
ce426f
# a more fully and correct link line as the compiler driver would use
ce426f
# when constructing an application or DSO. We do not adjust the link
ce426f
# lines used to build lib* targets.
ce426f
#
ce426f
# The rest of this patch is brought in by glibc-rh1292018-0a.patch
ce426f
# where we need to link against ld.so from libm.so.
ce426f
#
ce426f
ce426f
commit fab7ce3f5b4060bf62659e8b58529de4156b5a2f
ce426f
Author: Joseph Myers <joseph@codesourcery.com>
ce426f
Date:   Fri May 31 16:16:33 2013 +0000
ce426f
ce426f
    Link extra-libs consistently with libc and ld.so.
ce426f
ce426f
diff -urN glibc-2.17-c758a686/Makerules glibc-2.17-c758a686/Makerules
ce426f
--- glibc-2.17-c758a686/Makerules	2015-02-18 19:53:00.000000000 -0500
ce426f
+++ glibc-2.17-c758a686/Makerules	2015-02-18 20:08:33.299000028 -0500
ce426f
@@ -437,6 +437,25 @@
ce426f
 load-map-file = $(map-file:%=-Wl,--version-script=%)
ce426f
 endif
ce426f
 
ce426f
+# Compiler arguments to use to link a shared object with libc and
ce426f
+# ld.so.  This is intended to be as similar as possible to a default
ce426f
+# link with an installed libc.
ce426f
+link-libc-args = -Wl,--start-group \
ce426f
+                 $(libc-for-link) \
ce426f
+                 $(common-objpfx)libc_nonshared.a \
ce426f
+                 $(as-needed) $(elf-objpfx)ld.so $(no-as-needed) \
ce426f
+                 -Wl,--end-group
ce426f
+
ce426f
+# The corresponding shared libc to use.  This may be modified for a
ce426f
+# particular target.
ce426f
+libc-for-link = $(common-objpfx)libc.so
ce426f
+
ce426f
+# The corresponding dependencies.  As these are used in dependencies,
ce426f
+# not just commands, they cannot use target-specific variables so need
ce426f
+# to name both possible libc.so objects.
ce426f
+link-libc-deps = $(common-objpfx)libc.so $(common-objpfx)linkobj/libc.so \
ce426f
+                 $(common-objpfx)libc_nonshared.a $(elf-objpfx)ld.so
ce426f
+
ce426f
 # Pattern rule to build a shared object from an archive of PIC objects.
ce426f
 # This must come after the installation rules so Make doesn't try to
ce426f
 # build shared libraries in place from the installed *_pic.a files.
ce426f
@@ -518,12 +537,13 @@
ce426f
 # not for shared objects
ce426f
 define build-module
ce426f
 $(build-module-helper) -o $@ $(shlib-lds-flags) \
ce426f
-	  $(csu-objpfx)abi-note.o $(build-module-objlist)
ce426f
+	  $(csu-objpfx)abi-note.o $(build-module-objlist) $(link-libc-args)
ce426f
 endef
ce426f
 define build-module-asneeded
ce426f
 $(build-module-helper) -o $@ $(shlib-lds-flags) \
ce426f
 	  $(csu-objpfx)abi-note.o \
ce426f
-	  -Wl,--as-needed $(build-module-objlist) -Wl,--no-as-needed
ce426f
+	  -Wl,--as-needed $(build-module-objlist) -Wl,--no-as-needed \
ce426f
+	  $(link-libc-args)
ce426f
 endef
ce426f
 
ce426f
 build-module-helper-objlist = \