diff --git a/examples/elf/Kconfig b/examples/elf/Kconfig index 5346e14d5..87b74dd80 100644 --- a/examples/elf/Kconfig +++ b/examples/elf/Kconfig @@ -11,6 +11,32 @@ config EXAMPLES_ELF if EXAMPLES_ELF +config EXAMPLES_ELF_SYSCALL + bool "Link with SYSCALL library" + default n + depends on LIB_SYSCALL + ---help--- + Link with the SYCALL library. By default, all undefined symbols + must be provided via a symbol table. But if this option is + selected, then each ELF test program will link with the SYSCALL + library and will interface with the OS system calls. In this case, + those symbols will not be undefined. If the SYSCALL library is + available then you probably will want to select this option. + +config EXAMPLES_ELF_LIBC + bool "Link with LIBC" + default n + ---help--- + Link with the C library (and also math library if it was built). + By default, all undefined symbols must be provided via a symbol + table. But if this option is selected, then each ELF test program + will link with the SYSCALL library and will interface with the OS + system calls. You probably will NOT want this option, however, + because it will substantially increase the size of code. For + example, a separate copy of printf() would be linked with every + program greatly increasing the total code size. This option is + primarily intended only for testing. + config EXAMPLES_ELF_DEVMINOR int "ROMFS Minor Device Number" default 0 diff --git a/examples/elf/tests/errno/Makefile b/examples/elf/tests/errno/Makefile index ca2f34bf9..44e50744b 100644 --- a/examples/elf/tests/errno/Makefile +++ b/examples/elf/tests/errno/Makefile @@ -1,7 +1,7 @@ ############################################################################ -# examples/elf/tests/hello/Makefile +# examples/elf/tests/errno/Makefile # -# Copyright (C) 2012 Gregory Nutt. All rights reserved. +# Copyright (C) 2012, 2014 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -35,6 +35,36 @@ -include $(TOPDIR)/Make.defs +ifeq ($(WINTOOL),y) +NUTTXLIB = "${shell cygpath -w $(TOPDIR)$(DELIM)lib}" +else +NUTTXLIB = "$(TOPDIR)$(DELIM)lib" +endif + +LIBPATH = +ifeq ($(CONFIG_EXAMPLES_ELF_SYSCALL),y) +LDELFFLAGS += -Bstatic +LIBPATH += -L $(NUTTXLIB) +else +ifeq ($(CONFIG_EXAMPLES_ELF_LIBC),y) +LDELFFLAGS += -Bstatic +LIBPATH += -L $(NUTTXLIB) +endif +endif + +LIBS = +ifeq ($(CONFIG_EXAMPLES_ELF_LIBC),y) +ifeq ($(CONFIG_NUTTX_KERNEL),y) +LIBS += -luc +else +LIBS += -lc +endif +endif + +ifeq ($(CONFIG_EXAMPLES_ELF_SYSCALL),y) +LIBS += -lproxies +endif + BIN = errno SRCS = $(BIN).c @@ -48,7 +78,7 @@ $(OBJS): %.o: %.c $(BIN): $(OBJS) @echo "LD: $<" - $(Q) $(LD) $(LDELFFLAGS) -o $@ $^ + $(Q) $(LD) $(LDELFFLAGS) $(LIBPATH) -o $@ $^ $(LIBS) clean: $(call DELFILE, $(BIN)) diff --git a/examples/elf/tests/hello/Makefile b/examples/elf/tests/hello/Makefile index 07f97bee9..a5fc71e31 100644 --- a/examples/elf/tests/hello/Makefile +++ b/examples/elf/tests/hello/Makefile @@ -1,7 +1,7 @@ ############################################################################ # examples/elf/tests/hello/Makefile # -# Copyright (C) 2012 Gregory Nutt. All rights reserved. +# Copyright (C) 2012, 2014 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -35,6 +35,36 @@ -include $(TOPDIR)/Make.defs +ifeq ($(WINTOOL),y) +NUTTXLIB = "${shell cygpath -w $(TOPDIR)$(DELIM)lib}" +else +NUTTXLIB = "$(TOPDIR)$(DELIM)lib" +endif + +LIBPATH = +ifeq ($(CONFIG_EXAMPLES_ELF_SYSCALL),y) +LDELFFLAGS += -Bstatic +LIBPATH += -L $(NUTTXLIB) +else +ifeq ($(CONFIG_EXAMPLES_ELF_LIBC),y) +LDELFFLAGS += -Bstatic +LIBPATH += -L $(NUTTXLIB) +endif +endif + +LIBS = +ifeq ($(CONFIG_EXAMPLES_ELF_LIBC),y) +ifeq ($(CONFIG_NUTTX_KERNEL),y) +LIBS += -luc +else +LIBS += -lc +endif +endif + +ifeq ($(CONFIG_EXAMPLES_ELF_SYSCALL),y) +LIBS += -lproxies +endif + BIN = hello SRCS = $(BIN).c @@ -48,7 +78,7 @@ $(OBJS): %.o: %.c $(BIN): $(OBJS) @echo "LD: $<" - $(Q) $(LD) $(LDELFFLAGS) -o $@ $^ + $(Q) $(LD) $(LDELFFLAGS) $(LIBPATH) -o $@ $^ $(LIBS) clean: $(call DELFILE, $(BIN)) diff --git a/examples/elf/tests/helloxx/Makefile b/examples/elf/tests/helloxx/Makefile index 260475c5d..f0b204ca5 100644 --- a/examples/elf/tests/helloxx/Makefile +++ b/examples/elf/tests/helloxx/Makefile @@ -1,7 +1,7 @@ ############################################################################ # examples/elf/tests/helloxx/Makefile # -# Copyright (C) 2012 Gregory Nutt. All rights reserved. +# Copyright (C) 2012, 2014 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -35,6 +35,36 @@ -include $(TOPDIR)/Make.defs +ifeq ($(WINTOOL),y) +NUTTXLIB = "${shell cygpath -w $(TOPDIR)$(DELIM)lib}" +else +NUTTXLIB = "$(TOPDIR)$(DELIM)lib" +endif + +LIBPATH = +ifeq ($(CONFIG_EXAMPLES_ELF_SYSCALL),y) +LDELFFLAGS += -Bstatic +LIBPATH += -L $(NUTTXLIB) +else +ifeq ($(CONFIG_EXAMPLES_ELF_LIBC),y) +LDELFFLAGS += -Bstatic +LIBPATH += -L $(NUTTXLIB) +endif +endif + +LIBS = +ifeq ($(CONFIG_EXAMPLES_ELF_LIBC),y) +ifeq ($(CONFIG_NUTTX_KERNEL),y) +LIBS += -luc +else +LIBS += -lc +endif +endif + +ifeq ($(CONFIG_EXAMPLES_ELF_SYSCALL),y) +LIBS += -lproxies +endif + BIN1 = hello++1 BIN2 = hello++2 ifeq ($(CONFIG_BINFMT_CONSTRUCTORS),y) @@ -82,18 +112,18 @@ $(LIBSTDC_STUBS_LIB): $(BIN1): $(OBJS1) @echo "LD: $<" - $(Q) $(LD) $(LDELFFLAGS) -o $@ $^ + $(Q) $(LD) $(LDELFFLAGS) $(LIBPATH) -o $@ $^ $(LIBS) $(BIN2): $(OBJS2) @echo "LD: $<" - $(Q) $(LD) $(LDELFFLAGS) -o $@ $^ + $(Q) $(LD) $(LDELFFLAGS) $(LIBPATH) -o $@ $^ $(LIBS) # BIN3 is equivalent to BIN2 except that is uses static initializers ifeq ($(CONFIG_BINFMT_CONSTRUCTORS),y) $(BIN3): $(OBJS3) @echo "LD: $<" - $(Q) $(LD) $(LDELFFLAGS) -o $@ $^ + $(Q) $(LD) $(LDELFFLAGS) $(LIBPATH) -o $@ $^ $(LIBS) endif # BIN4 is similar to BIN3 except that it uses the streams code from libstdc++ @@ -102,7 +132,7 @@ endif # #$(BIN4): $(OBJS4) # @echo "LD: $<" -# $(Q) $(LD) $(LDELFFLAGS) -o $@ $^ +# $(Q) $(LD) $(LDELFFLAGS) $(LIBPATH) -o $@ $^ $(LIBS) clean: $(call DELFILE, $(BIN1)) diff --git a/examples/elf/tests/longjmp/Makefile b/examples/elf/tests/longjmp/Makefile index a0100b247..f85f95434 100644 --- a/examples/elf/tests/longjmp/Makefile +++ b/examples/elf/tests/longjmp/Makefile @@ -1,7 +1,7 @@ ############################################################################ # examples/elf/tests/longjmp/Makefile # -# Copyright (C) 2012 Gregory Nutt. All rights reserved. +# Copyright (C) 2012, 2014 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -35,6 +35,36 @@ -include $(TOPDIR)/Make.defs +ifeq ($(WINTOOL),y) +NUTTXLIB = "${shell cygpath -w $(TOPDIR)$(DELIM)lib}" +else +NUTTXLIB = "$(TOPDIR)$(DELIM)lib" +endif + +LIBPATH = +ifeq ($(CONFIG_EXAMPLES_ELF_SYSCALL),y) +LDELFFLAGS += -Bstatic +LIBPATH += -L $(NUTTXLIB) +else +ifeq ($(CONFIG_EXAMPLES_ELF_LIBC),y) +LDELFFLAGS += -Bstatic +LIBPATH += -L $(NUTTXLIB) +endif +endif + +LIBS = +ifeq ($(CONFIG_EXAMPLES_ELF_LIBC),y) +ifeq ($(CONFIG_NUTTX_KERNEL),y) +LIBS += -luc +else +LIBS += -lc +endif +endif + +ifeq ($(CONFIG_EXAMPLES_ELF_SYSCALL),y) +LIBS += -lproxies +endif + BIN = longjmp SRCS = $(BIN).c @@ -48,7 +78,7 @@ $(OBJS): %.o: %.c $(BIN): $(OBJS) @echo "LD: $<" - $(Q) $(LD) $(LDELFFLAGS) -o $@ $^ + $(Q) $(LD) $(LDELFFLAGS) $(LIBPATH) -o $@ $^ $(LIBS) clean: $(call DELFILE, $(BIN)) diff --git a/examples/elf/tests/mutex/Makefile b/examples/elf/tests/mutex/Makefile index e3085ad8e..70848c0f8 100644 --- a/examples/elf/tests/mutex/Makefile +++ b/examples/elf/tests/mutex/Makefile @@ -1,7 +1,7 @@ ############################################################################ # examples/elf/tests/mutex/Makefile # -# Copyright (C) 2012 Gregory Nutt. All rights reserved. +# Copyright (C) 2012, 2014 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -35,6 +35,36 @@ -include $(TOPDIR)/Make.defs +ifeq ($(WINTOOL),y) +NUTTXLIB = "${shell cygpath -w $(TOPDIR)$(DELIM)lib}" +else +NUTTXLIB = "$(TOPDIR)$(DELIM)lib" +endif + +LIBPATH = +ifeq ($(CONFIG_EXAMPLES_ELF_SYSCALL),y) +LDELFFLAGS += -Bstatic +LIBPATH += -L $(NUTTXLIB) +else +ifeq ($(CONFIG_EXAMPLES_ELF_LIBC),y) +LDELFFLAGS += -Bstatic +LIBPATH += -L $(NUTTXLIB) +endif +endif + +LIBS = +ifeq ($(CONFIG_EXAMPLES_ELF_LIBC),y) +ifeq ($(CONFIG_NUTTX_KERNEL),y) +LIBS += -luc +else +LIBS += -lc +endif +endif + +ifeq ($(CONFIG_EXAMPLES_ELF_SYSCALL),y) +LIBS += -lproxies +endif + BIN = mutex SRCS = $(BIN).c @@ -48,7 +78,7 @@ $(OBJS): %.o: %.c $(BIN): $(OBJS) @echo "LD: $<" - $(Q) $(LD) $(LDELFFLAGS) -o $@ $^ + $(Q) $(LD) $(LDELFFLAGS) $(LIBPATH) -o $@ $^ $(LIBS) clean: $(call DELFILE, $(BIN)) diff --git a/examples/elf/tests/pthread/Makefile b/examples/elf/tests/pthread/Makefile index f201b12f5..1b02b017c 100644 --- a/examples/elf/tests/pthread/Makefile +++ b/examples/elf/tests/pthread/Makefile @@ -1,7 +1,7 @@ ############################################################################ # examples/elf/tests/pthread/Makefile # -# Copyright (C) 2012 Gregory Nutt. All rights reserved. +# Copyright (C) 2012, 2014 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -35,6 +35,36 @@ -include $(TOPDIR)/Make.defs +ifeq ($(WINTOOL),y) +NUTTXLIB = "${shell cygpath -w $(TOPDIR)$(DELIM)lib}" +else +NUTTXLIB = "$(TOPDIR)$(DELIM)lib" +endif + +LIBPATH = +ifeq ($(CONFIG_EXAMPLES_ELF_SYSCALL),y) +LDELFFLAGS += -Bstatic +LIBPATH += -L $(NUTTXLIB) +else +ifeq ($(CONFIG_EXAMPLES_ELF_LIBC),y) +LDELFFLAGS += -Bstatic +LIBPATH += -L $(NUTTXLIB) +endif +endif + +LIBS = +ifeq ($(CONFIG_EXAMPLES_ELF_LIBC),y) +ifeq ($(CONFIG_NUTTX_KERNEL),y) +LIBS += -luc +else +LIBS += -lc +endif +endif + +ifeq ($(CONFIG_EXAMPLES_ELF_SYSCALL),y) +LIBS += -lproxies +endif + BIN = pthread SRCS = $(BIN).c @@ -48,7 +78,7 @@ $(OBJS): %.o: %.c $(BIN): $(OBJS) @echo "LD: $<" - $(Q) $(LD) $(LDELFFLAGS) -o $@ $^ + $(Q) $(LD) $(LDELFFLAGS) $(LIBPATH) -o $@ $^ $(LIBS) clean: $(call DELFILE, $(BIN)) diff --git a/examples/elf/tests/signal/Makefile b/examples/elf/tests/signal/Makefile index 53a5d5721..abb596f6c 100644 --- a/examples/elf/tests/signal/Makefile +++ b/examples/elf/tests/signal/Makefile @@ -1,7 +1,7 @@ ############################################################################ # examples/elf/tests/signal/Makefile # -# Copyright (C) 2012 Gregory Nutt. All rights reserved. +# Copyright (C) 2012, 2014 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -35,6 +35,36 @@ -include $(TOPDIR)/Make.defs +ifeq ($(WINTOOL),y) +NUTTXLIB = "${shell cygpath -w $(TOPDIR)$(DELIM)lib}" +else +NUTTXLIB = "$(TOPDIR)$(DELIM)lib" +endif + +LIBPATH = +ifeq ($(CONFIG_EXAMPLES_ELF_SYSCALL),y) +LDELFFLAGS += -Bstatic +LIBPATH += -L $(NUTTXLIB) +else +ifeq ($(CONFIG_EXAMPLES_ELF_LIBC),y) +LDELFFLAGS += -Bstatic +LIBPATH += -L $(NUTTXLIB) +endif +endif + +LIBS = +ifeq ($(CONFIG_EXAMPLES_ELF_LIBC),y) +ifeq ($(CONFIG_NUTTX_KERNEL),y) +LIBS += -luc +else +LIBS += -lc +endif +endif + +ifeq ($(CONFIG_EXAMPLES_ELF_SYSCALL),y) +LIBS += -lproxies +endif + BIN = signal SRCS = $(BIN).c @@ -48,7 +78,7 @@ $(OBJS): %.o: %.c $(BIN): $(OBJS) @echo "LD: $<" - $(Q) $(LD) $(LDELFFLAGS) -o $@ $^ + $(Q) $(LD) $(LDELFFLAGS) $(LIBPATH) -o $@ $^ $(LIBS) clean: $(call DELFILE, $(BIN)) diff --git a/examples/elf/tests/struct/Makefile b/examples/elf/tests/struct/Makefile index 80117a72f..b0fa3e474 100644 --- a/examples/elf/tests/struct/Makefile +++ b/examples/elf/tests/struct/Makefile @@ -1,7 +1,7 @@ ############################################################################ -# examples/elf/tests/hello/Makefile +# examples/elf/tests/struct/Makefile # -# Copyright (C) 2012 Gregory Nutt. All rights reserved. +# Copyright (C) 2012, 2014 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -37,6 +37,36 @@ CELFFLAGS += -I. +ifeq ($(WINTOOL),y) +NUTTXLIB = "${shell cygpath -w $(TOPDIR)$(DELIM)lib}" +else +NUTTXLIB = "$(TOPDIR)$(DELIM)lib" +endif + +LIBPATH = +ifeq ($(CONFIG_EXAMPLES_ELF_SYSCALL),y) +LDELFFLAGS += -Bstatic +LIBPATH += -L $(NUTTXLIB) +else +ifeq ($(CONFIG_EXAMPLES_ELF_LIBC),y) +LDELFFLAGS += -Bstatic +LIBPATH += -L $(NUTTXLIB) +endif +endif + +LIBS = +ifeq ($(CONFIG_EXAMPLES_ELF_LIBC),y) +ifeq ($(CONFIG_NUTTX_KERNEL),y) +LIBS += -luc +else +LIBS += -lc +endif +endif + +ifeq ($(CONFIG_EXAMPLES_ELF_SYSCALL),y) +LIBS += -lproxies +endif + BIN = struct SRCS = struct_main.c struct_dummy.c OBJS = $(SRCS:.c=.o) @@ -49,7 +79,7 @@ $(OBJS): %.o: %.c $(BIN): $(OBJS) @echo "LD: $<" - $(Q) $(LD) $(LDELFFLAGS) -o $@ $^ + $(Q) $(LD) $(LDELFFLAGS) $(LIBPATH) -o $@ $^ $(LIBS) clean: $(call DELFILE, $(BIN)) diff --git a/examples/elf/tests/task/Makefile b/examples/elf/tests/task/Makefile index c30fa8076..dcf758dfd 100644 --- a/examples/elf/tests/task/Makefile +++ b/examples/elf/tests/task/Makefile @@ -1,7 +1,7 @@ ############################################################################ # examples/elf/tests/task/Makefile # -# Copyright (C) 2012 Gregory Nutt. All rights reserved. +# Copyright (C) 2012, 2014 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -35,6 +35,36 @@ -include $(TOPDIR)/Make.defs +ifeq ($(WINTOOL),y) +NUTTXLIB = "${shell cygpath -w $(TOPDIR)$(DELIM)lib}" +else +NUTTXLIB = "$(TOPDIR)$(DELIM)lib" +endif + +LIBPATH = +ifeq ($(CONFIG_EXAMPLES_ELF_SYSCALL),y) +LDELFFLAGS += -Bstatic +LIBPATH += -L $(NUTTXLIB) +else +ifeq ($(CONFIG_EXAMPLES_ELF_LIBC),y) +LDELFFLAGS += -Bstatic +LIBPATH += -L $(NUTTXLIB) +endif +endif + +LIBS = +ifeq ($(CONFIG_EXAMPLES_ELF_LIBC),y) +ifeq ($(CONFIG_NUTTX_KERNEL),y) +LIBS += -luc +else +LIBS += -lc +endif +endif + +ifeq ($(CONFIG_EXAMPLES_ELF_SYSCALL),y) +LIBS += -lproxies +endif + BIN = task SRCS = $(BIN).c @@ -48,7 +78,7 @@ $(OBJS): %.o: %.c $(BIN): $(OBJS) @echo "LD: $<" - $(Q) $(LD) $(LDELFFLAGS) -o $@ $^ + $(Q) $(LD) $(LDELFFLAGS) $(LIBPATH) -o $@ $^ $(LIBS) clean: $(call DELFILE, $(BIN))