This is the mail archive of the libc-hacker@sourceware.cygnus.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: A static binary patch


>    |> Since the_c_stubs_test is linked statically, it doesn't work. If you
>    |> can find a better way to fix it, I will appreciate it.
> 
>    How about extending the ld.so so that if it is called with a static binary
>    it just execve()s it?
> 
> Or use `ld.so --verify' to find out if it is a dynamic executable or not
> instead of using `file'.
> 

I like it. Here is the new patch.

-- 
H.J. Lu (hjl@gnu.org)
---
Tue Aug 24 09:13:59 1999  H.J. Lu  <hjl@gnu.org>

	* Rules (%.out): Run "ld.so --verify" on the binary before
	running it and don't use the dynamic linker if it is not
	dynamically linked.

Index: Rules
===================================================================
RCS file: /work/cvs/gnu/glibc/Rules,v
retrieving revision 1.1.1.2
diff -u -p -r1.1.1.2 Rules
--- Rules	1999/08/23 16:16:40	1.1.1.2
+++ Rules	1999/08/24 16:12:37
@@ -119,13 +119,33 @@ ifneq "$(strip $(tests) $(test-srcs))" "
 # These are the implicit rules for making test outputs
 # from the test programs and whatever input files are present.
 $(objpfx)%.out: %.args $(objpfx)% %.input
-	$($*-ENV) $(built-program-cmd) `cat $(word 1,$^)` < $(word 3,$^) > $@
+	$(elf-objpfx)$(rtld-installed-name) --verify $(built-program-file) > /dev/null 2>&1; \
+	if [ $$? = 0 ]; then \
+	  $($*-ENV) $(built-program-cmd) `cat $(word 1,$^)` < $(word 3,$^) > $@; \
+	else \
+	  $($*-ENV) $(built-program-file) `cat $(word 1,$^)` < $(word 3,$^) > $@; \
+	fi
 $(objpfx)%.out: %.args $(objpfx)%
-	$($*-ENV) $(built-program-cmd) `cat $(word 1,$^)` > $@
+	$(elf-objpfx)$(rtld-installed-name) --verify $(built-program-file) > /dev/null 2>&1; \
+	if [ $$? = 0 ]; then \
+	  $($*-ENV) $(built-program-cmd) `cat $(word 1,$^)` > $@; \
+	else \
+	  $($*-ENV) $(built-program-file) `cat $(word 1,$^)` > $@; \
+	fi
 $(objpfx)%.out: %.input $(objpfx)%
-	$($*-ENV) $(built-program-cmd) < $(word 1,$^) > $@
+	$(elf-objpfx)$(rtld-installed-name) --verify $(built-program-file) > /dev/null 2>&1; \
+	if [ $$? = 0 ]; then \
+	  $($*-ENV) $(built-program-cmd) < $(word 1,$^) > $@; \
+	else \
+	  $($*-ENV) $(built-program-file) < $(word 1,$^) > $@; \
+	fi
 $(objpfx)%.out: /dev/null $(objpfx)%	# Make it 2nd arg for canned sequence.
-	$($*-ENV) $(built-program-cmd) > $@
+	$(elf-objpfx)$(rtld-installed-name) --verify $(built-program-file) > /dev/null 2>&1; \
+	if [ $$? = 0 ]; then \
+	  $($*-ENV) $(built-program-cmd) > $@; \
+	else \
+	  $($*-ENV) $(built-program-file) > $@; \
+	fi
 endif	# tests
 
 .PHONY: distclean realclean subdir_distclean subdir_realclean \

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]