public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/fw/bug25486] elf: Introduce the rtld-weak-symbols variable
@ 2020-02-07 20:35 Florian Weimer
  0 siblings, 0 replies; only message in thread
From: Florian Weimer @ 2020-02-07 20:35 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=68abc629671d07b22882b05426ed719751a71576

commit 68abc629671d07b22882b05426ed719751a71576
Author: Florian Weimer <fweimer@redhat.com>
Date:   Fri Feb 7 20:24:39 2020 +0100

    elf: Introduce the rtld-weak-symbols variable
    
    This allows explicit use of weak symbols in the dynamic loader.
    
    Tested on i686-linux-gnu with out the stack protector, and on
    x86_64-linux-gnu with stack-protector-strong.

Diff:
---
 elf/Makefile | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/elf/Makefile b/elf/Makefile
index 60c8082..0a553c7 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -482,11 +482,19 @@ $(objpfx)dl-allobjs.os: $(all-rtld-routines:%=$(objpfx)%.os)
 # are compiled with special flags, and puts these modules into rtld-libc.a
 # for us.  Then we do the real link using rtld-libc.a instead of libc_pic.a.
 
+# Known weak symbols ignored by the sanity check after the ld.so link.
+rtld-weak-symbols =
+
+# POSIX extended regular expression matching all weak symbols
+define rtld-weak-symbols-regexp
+('"$(shell echo $(sort $(rtld-weak-symbols)) | tr ' ' '|')"')
+endef
+
 # These symbols need to be stubbed out during symbol discovery because
 # their implementation is provided differently in rtld, and the symbol
 # discovery mechanism is not compatible with the libc implementation
 # when compiled for libc.
-rtld-stubbed-symbols =
+rtld-stubbed-symbols = $(rtld-weak-symbols)
 
 # The GCC arguments that implement $(rtld-stubbed-symbols).
 rtld-stubbed-symbols-args = \
@@ -547,6 +555,7 @@ $(objpfx)ld.so: $(objpfx)librtld.os $(ld-map)
 		  -Wl,-defsym=_begin=0
 	$(call after-link,$@.new)
 	$(READELF) -s $@.new \
+	  | grep -vE '\sWEAK\s.*\s$(rtld-weak-symbols-regexp)$$' \
 	  | $(AWK) '($$7 ~ /^UND(|EF)$$/ && $$1 != "0:" && $$4 != "REGISTER") { print; p=1 } END { exit p != 0 }'
 	mv -f $@.new $@


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-02-07 20:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-07 20:35 [glibc/fw/bug25486] elf: Introduce the rtld-weak-symbols variable Florian Weimer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).