This diff is super hacky and just mailed out for proof-of-concept, but
it's something that's been handy for me while hacking on ld.so.
Basically before installing a new version of ld.so, it just runs a
simple test program to double check that ld.so isn't completely hosed.

There's plenty of issues with this diff as is (e.g., doesn't work for
cross builds, assumes "make obj", "make clean" doesn't work), but I'm
curious what people think of the concept and whether anyone has
suggestions how to improve it.


Index: Makefile
===================================================================
RCS file: /cvs/src/libexec/ld.so/Makefile,v
retrieving revision 1.37
diff -u -p -r1.37 Makefile
--- Makefile    3 Feb 2010 20:49:00 -0000       1.37
+++ Makefile    12 Sep 2012 17:26:32 -0000
@@ -35,4 +35,13 @@ ELF_LDFLAGS+=--shared -Bsymbolic --no-un
 $(PROG):
        $(LD) -x -e _dl_start $(ELF_LDFLAGS) -o $(PROG) $(OBJS) $(LDADD)
 
+# XXX: Only for native builds
+realinstall: sanitycheck
+
+.PHONY: sanitycheck
+sanitycheck: sanitycheckprog $(PROG)
+       ./sanitycheckprog
+sanitycheckprog: sanitycheckprog.o
+       $(CC) -o sanitycheckprog sanitycheckprog.o 
-Wl,--dynamic-linker,${.CURDIR}/obj/$(PROG)
+
 .include <bsd.prog.mk>
Index: sanitycheckprog.c
===================================================================
RCS file: sanitycheckprog.c
diff -N sanitycheckprog.c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ sanitycheckprog.c   12 Sep 2012 17:26:32 -0000
@@ -0,0 +1,7 @@
+#include <stdio.h>
+
+int main()
+{
+       puts("ld.so works");
+       return 0;
+}

Reply via email to