summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1999-10-04 23:46:09 +0000
committerRoland McGrath <roland@gnu.org>1999-10-04 23:46:09 +0000
commit45a709be26e50168c332c27b8331e30be0425b0f (patch)
tree5449a1ef250865e1dc676d90746d6aaf58070eff
parent6c83d0237eb855aa6e74691070efe357e2bb3d56 (diff)
1999-10-04 Roland McGrath <roland@baalperazim.frob.com>
* Makefile.in (clib-routines.o, check-clib-routines, clib-routines.d): Remove these rules, replace with: (kernel.o): New target, relocatable object linked from kernel objects. (kernel-undef, kernel-undef-bad): New targets, glean undefined symbols from kernel.o. (clib-routines.o): New target, use those to select symbols from libc. (clib-routines): Add some symbols; move defn to kernel linking page. This variable is now a list of symbols allowed to be undefined, rather than a prescriptive list of symbols always grabbed from libc. (kernel): Rewrite this rules to just link kernel.o and clib-routines.o together to make the kernel image.
-rw-r--r--Makefile.in66
1 files changed, 24 insertions, 42 deletions
diff --git a/Makefile.in b/Makefile.in
index 5063bf7..80f809b 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -228,43 +228,6 @@ other-mach-headers := mig_support.h mach_traps.h error.h
other-headers := alloca.h
-# We steal routines from the C library and put them here.
-# If we link against the C library directly, then we have to hope that we have
-# correctly found all the dependencies that might bring in C library code.
-# This method is much safer because it's easy to check this one object file
-# for sanity.
-objfiles += clib-routines.o
-
-clib-routines := memcpy memset bcopy bzero htonl htons ntohl ntohs
-ifeq ($(enable_kdb),yes)
-clib-routines += strstr
-endif
-
-Wl-u = -Wl,-u,
-clib-routines.o: Makefile
- $(CC) -o $@ -r -nostartfiles -nostdlib -static -x c /dev/null \
- $(addprefix $(Wl-u),$(clib-routines)) \
- -L`dirname \`$(CC) --print-file-name=libc.a\`` -lc
-
-# This rule checks clib-routines and makes sure it doesn't have any
-# extra symbols.
-kernel: check-clib-routines
-check-clib-routines: clib-routines.o
- $(NM) -g $< | \
- awk '$(foreach sym,$(clib-routines),\
- $$3 == "$(sym)" || $$3 == "__$(sym)" ||) 0 \
- { match_cnt++; total_cnt++; next } \
- $$2 == "W" { weak_cnt++ } \
- { total_cnt++ } \
- END { exit total_cnt - (match_cnt + weak_cnt) }'
- touch check-clib-routines
-
-
-# Empty dependency file
-clib-routines.d:; touch $@
-
-
-
# Automatically generated source
# User stubs
@@ -332,10 +295,30 @@ check:
#
# Kernel Image
#
-# (The newline in this command makes it much easier to read in make output.)
-kernel: $(objfiles)
- $(LD) -o $@ $(LDFLAGS) \
- $(objfiles)
+
+# This is the list of routines we decide is OK to steal from the C library.
+clib-routines := memcpy memmove memset bcopy bzero \
+ strstr \
+ htonl htons ntohl ntohs \
+ etext edata end # actually ld magic, not libc
+
+#kernel.a: $(objfiles)
+# @rm -f $@
+# $(AR) cq $@ $^
+kernel.o: $(objfiles) # kernel.a
+ $(LD) -r -o $@ $^
+kernel-undef: kernel.o
+ $(NM) -u $< | sed 's/^_*//' | sort -u > $@
+kernel-undef-bad: kernel-undef
+ sed '$(foreach r,$(clib-routines),/^$r$$/d;)' $< > $@
+clib-routines.o: kernel-undef kernel-undef-bad
+ if test -s kernel-undef-bad; \
+ then cat kernel-undef-bad; exit 2; else true; fi
+ $(CC) -nostdlib -nostartfiles -r -static \
+ -o $@ \
+ `sed 's/^/-Wl,-u,/' $<` -x c /dev/null -lc
+kernel: kernel.o clib-routines.o
+ $(LD) $(LDFLAGS) -o $@ $^
@@ -500,4 +483,3 @@ endef
# list.
%.d: %.s
echo '$*.o: $<' > $@
-