]> xenbits.xensource.com Git - rumpuser-xen.git/commitdiff
Build Mini-OS and rump kernel middleware as discrete objects
authorMartin Lucina <martin@lucina.net>
Thu, 6 Nov 2014 16:11:24 +0000 (17:11 +0100)
committerMartin Lucina <martin@lucina.net>
Mon, 10 Nov 2014 14:05:41 +0000 (15:05 +0100)
In order to be able to make Mini-OS symbols local using objcopy we need to
build Mini-OS as a discrete relocatable object. While we're here, put the
various rump kernel middleware (libc stubs, rumphyper implementation)
into its own object file also.

Signed-off-by: Martin Lucina <martin@lucina.net>
Makefile

index f6d625005a58553b1c12f1a0d4bcf9332cee88cb..4e8c495bb22badece5926deca104986c4c5e0b46 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -35,18 +35,17 @@ CFLAGS += -DVIRTIF_BASE=xenif -I$(MINI-OS_ROOT)
 CFLAGS += -no-integrated-cpp
 
 ifeq ($(CONFIG_PCI),y)
-LIBS_PCI = -lrumpdev_pci -lrumpdev_pci_if_wm -lrumpdev_miiphy
+RUMP_LIBS_PCI = -lrumpdev_pci -lrumpdev_pci_if_wm -lrumpdev_miiphy
 endif
 
-LIBS_FS = -lrumpfs_ffs -lrumpdev_disk -lrumpdev -lrumpvfs
-LIBS_NET = -lrumpnet_config -lrumpdev_bpf -lrumpnet_xenif -lrumpnet_netinet
-LIBS_NET+= -lrumpnet_net -lrumpxen_xendev -lrumpnet
+RUMP_LIBS_FS = -lrumpfs_ffs -lrumpdev_disk -lrumpdev -lrumpvfs
+RUMP_LIBS_NET = -lrumpnet_config -lrumpdev_bpf -lrumpnet_xenif -lrumpnet_netinet
+RUMP_LIBS_NET+= -lrumpnet_net -lrumpxen_xendev -lrumpnet
 
 # Define some default flags for linking.
-LDLIBS_FS = --whole-archive ${LIBS_FS} ${LIBS_NET} ${LIBS_PCI} -lrump --no-whole-archive
-LDLIBS := ${LDLIBS_FS} -lpthread -lc
+RUMP_LDLIBS = --whole-archive ${RUMP_LIBS_FS} ${RUMP_LIBS_NET} ${RUMP_LIBS_PCI} -lrump --no-whole-archive
+RUMP_LDLIBS := ${RUMP_LDLIBS} -lpthread -lc
 
-APP_LDLIBS := 
 LDARCHLIB := -l$(ARCH_LIB_NAME)
 LDSCRIPT := xen/$(TARGET_ARCH_DIR)/minios-$(XEN_TARGET_ARCH).lds
 LDFLAGS_FINAL := -T $(LDSCRIPT)
@@ -58,7 +57,7 @@ LDFLAGS := -L$(abspath $(OBJ_DIR)/xen/$(TARGET_ARCH_DIR)) -L$(abspath rump/lib)
 GLOBAL_PREFIX := xenos_
 EXTRA_OBJS =
 
-TARGET := rump-kernel
+TARGET := minios.o
 
 # Subdirectories common to mini-os
 SUBDIRS := lib xen xen/console xen/xenbus
@@ -73,34 +72,33 @@ src-y += xen/mm.c
 src-y += xen/netfront.c
 src-$(CONFIG_PCI) += xen/pcifront.c
 src-y += xen/sched.c
-
-src-y += lib/__errno.c
-src-y += lib/emul.c
-src-y += lib/libc_stubs.c
-src-y += lib/memalloc.c
-src-y += lib/_lwp.c
-
-src-y += rumphyper_base.c
-src-y += rumphyper_net.c
-src-$(CONFIG_PCI) += rumphyper_pci.c
-src-y += rumphyper_synch.c
-src-y += rumphyper_stubs.c
-
-src-y += callmain.c
-src-y += netbsd_init.c
-
 src-$(CONFIG_XENBUS) += xen/xenbus/xenbus.c
-
 src-y += xen/console/console.c
 src-y += xen/console/xencons_ring.c
 src-y += xen/console/xenbus.c
 
+rump-src-y += lib/__errno.c
+rump-src-y += lib/emul.c
+rump-src-y += lib/libc_stubs.c
+rump-src-y += lib/memalloc.c
+rump-src-y += lib/_lwp.c
+
+rump-src-y += rumphyper_base.c
+rump-src-y += rumphyper_net.c
+rump-src-$(CONFIG_PCI) += rumphyper_pci.c
+rump-src-y += rumphyper_synch.c
+rump-src-y += rumphyper_stubs.c
+
+rump-src-y += callmain.c
+rump-src-y += netbsd_init.c
+
 # The common mini-os objects to build.
-APP_OBJS :=
 OBJS := $(patsubst %.c,$(OBJ_DIR)/%.o,$(src-y))
+# Rump kernel middleware objects to build.
+RUMP_OBJS := $(patsubst %.c,$(OBJ_DIR)/%.o,$(rump-src-y))
 
 .PHONY: default
-default: objs app-tools $(TARGET) tests/hello/hello
+default: objs app-tools minios.o rumprun.o tests/hello/hello
 
 objs:
        mkdir -p $(OBJ_DIR)/lib $(OBJ_DIR)/xen/$(TARGET_ARCH_DIR)
@@ -122,20 +120,13 @@ links: $(ARCH_LINKS)
 arch_lib:
        $(MAKE) --directory=xen/$(TARGET_ARCH_DIR) OBJ_DIR=$(OBJ_DIR)/xen/$(TARGET_ARCH_DIR) || exit 1;
 
-$(OBJ_DIR)/$(TARGET)_app.o: $(APP_OBJS) app.lds
-       $(LD) -r -d $(LDFLAGS) -\( $^ -\) $(APP_LDLIBS) --undefined main -o $@
-
-ifneq ($(APP_OBJS),)
-APP_O=$(OBJ_DIR)/$(TARGET)_app.o 
-endif
-
-.PHONY: $(TARGET)
-$(TARGET): links $(OBJS) $(APP_O) arch_lib
-#      $(LD) -r $(LDFLAGS) $(HEAD_OBJ) $(APP_O) $(OBJS) $(LDARCHLIB) $(LDLIBS) -o $@.o
-#      $(OBJCOPY) -w -G $(GLOBAL_PREFIX)* -G _start $@.o $@.o
+minios.o: links $(OBJS) arch_lib
+       $(LD) -r $(LDFLAGS) $(HEAD_OBJ) $(OBJS) $(LDARCHLIB) $(LDLIBS) -o $@
+#      $(OBJCOPY) -w -G $(GLOBAL_PREFIX)* -G _start $@ $@
 #      $(LD) $(LDFLAGS) $(LDFLAGS_FINAL) $@.o $(EXTRA_OBJS) -o $@
-#      gzip -f -9 -c $@ >$@.gz
 
+rumprun.o: $(RUMP_OBJS)
+       $(LD) -r $(LDFLAGS) $(RUMP_OBJS) -o $@
 
 APP_TOOLS += rumpapp-xen-cc rumpapp-xen-cc.configure specs specs.configure
 APP_TOOLS += rumpapp-xen-configure rumpapp-xen-make rumpapp-xen-gmake
@@ -143,11 +134,11 @@ APP_TOOLS += rumpapp-xen-configure rumpapp-xen-make rumpapp-xen-gmake
 .PHONY: app-tools
 app-tools: $(addprefix app-tools/, $(APP_TOOLS))
 
-APP_TOOLS_LDLIBS := $(LDLIBS)
+APP_TOOLS_LDLIBS := $(RUMP_LDLIBS)
 # XXX: LDARCHLIB isn't really a linker flag, but it needs to
 # be always included anyway
 APP_TOOLS_LDFLAGS := $(LDFLAGS) $(LDARCHLIB)
-APP_TOOLS_OBJS := $(OBJS)
+APP_TOOLS_OBJS := $(abspath rumprun.o)
 
 APP_TOOLS_ARCH := $(subst x86_32,i386, \
                   $(subst x86_64,amd64, \
@@ -165,7 +156,7 @@ app-tools/%: app-tools/%.in Makefile Config.mk
                -e 's#!OBJS!#$(APP_TOOLS_OBJS)#g;' \
                -e 's#!LDLIBS!#$(APP_TOOLS_LDLIBS)#g;' \
                -e 's#!LDFLAGS!#$(APP_TOOLS_LDFLAGS)#g;' \
-               -e 's#!HEAD_OBJ!#$(abspath $(HEAD_OBJ))#g;' \
+               -e 's#!HEAD_OBJ!#$(abspath minios.o)#g;' \
                -e 's#!LDSCRIPT!#$(abspath $(LDSCRIPT))#g;'
        if test -x $<; then chmod +x $@.tmp; fi
        mv -f $@.tmp $@
@@ -173,7 +164,7 @@ app-tools/%: app-tools/%.in Makefile Config.mk
 app-tools_clean:
        rm -f $(addprefix app-tools/, $(APP_TOOLS))
 
-tests/hello/hello: tests/hello/hello.c
+tests/hello/hello: tests/hello/hello.c app-tools minios.o rumprun.o
        app-tools/rumpapp-xen-cc -o $@ $<
 
 .PHONY: clean arch_clean app-tools_clean
@@ -185,7 +176,7 @@ clean:      arch_clean app-tools_clean
        for dir in $(addprefix $(OBJ_DIR)/,$(SUBDIRS)); do \
                rm -f $$dir/*.o; \
        done
-       rm -f $(OBJ_DIR)/*.o *~ $(OBJ_DIR)/core $(OBJ_DIR)/$(TARGET).elf $(OBJ_DIR)/$(TARGET).raw $(TARGET) $(TARGET).o
+       rm -f $(OBJ_DIR)/*.o *~ $(OBJ_DIR)/core minios.o rumprun.o
        rm -f include/xen include/mini-os/machine
        rm -f tags TAGS
        rm -f tests/hello/hello