about summary refs log tree commit diff
path: root/elf
diff options
context:
space:
mode:
authorRoland McGrath <roland@hack.frob.com>2013-06-13 10:26:44 -0700
committerRoland McGrath <roland@hack.frob.com>2013-06-13 10:26:44 -0700
commitf4a29fba078c48f9d4c78d06d2ed4bbdf95b3763 (patch)
tree251e7987f875cdfb88161aa46186fb35995e8d86 /elf
parentad36ba2bd67398edefe31aa039090912f76bffce (diff)
downloadglibc-f4a29fba078c48f9d4c78d06d2ed4bbdf95b3763.tar.gz
glibc-f4a29fba078c48f9d4c78d06d2ed4bbdf95b3763.tar.xz
glibc-f4a29fba078c48f9d4c78d06d2ed4bbdf95b3763.zip
Don't let ld.so that failed its sanity check land in place.
Diffstat (limited to 'elf')
-rw-r--r--elf/Makefile7
1 files changed, 5 insertions, 2 deletions
diff --git a/elf/Makefile b/elf/Makefile
index 6f40414cbe..3b58649de5 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -318,13 +318,16 @@ generated += librtld.map librtld.mk rtld-libc.a librtld.os.map
 z-now-yes = -Wl,-z,now
 
 $(objpfx)ld.so: $(objpfx)librtld.os $(ld-map)
-	$(LINK.o) -nostdlib -nostartfiles -shared -o $@			\
+# Link into a temporary file so that we don't touch $@ at all
+# if the sanity check below fails.
+	$(LINK.o) -nostdlib -nostartfiles -shared -o $@.new		\
 		  $(LDFLAGS-rtld) -Wl,-z,defs $(z-now-$(bind-now))	\
 		  $(filter-out $(map-file),$^) $(load-map-file)		\
 		  -Wl,-soname=$(rtld-installed-name)			\
 		  -Wl,-defsym=_begin=0
-	$(READELF) -s $@ \
+	$(READELF) -s $@.new \
 	  | $(AWK) '($$7 ~ /^UND(|EF)$$/ && $$1 != "0:" && $$4 != "REGISTER") { print; p=1 } END { exit p != 0 }'
+	mv -f $@.new $@
 
 # interp.c exists just to get this string into the libraries.
 CFLAGS-interp.c = -D'RUNTIME_LINKER="$(rtlddir)/$(rtld-installed-name)"' \