Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/elf/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/Kconfig
8 changes: 2 additions & 6 deletions examples/elf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,5 @@
#
# ##############################################################################

if(CONFIG_EXAMPLES_ELF)
nuttx_add_application(NAME elf SRCS elf_main.c)

# TODO: tests

endif()
nuttx_add_subdirectory()
nuttx_generate_kconfig(MENUDESC "Elf")
4 changes: 1 addition & 3 deletions examples/elf/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,4 @@
#
############################################################################

ifneq ($(CONFIG_EXAMPLES_ELF),)
CONFIGURED_APPS += $(APPDIR)/examples/elf
endif
include $(wildcard $(APPDIR)/examples/elf/*/Make.defs)
45 changes: 2 additions & 43 deletions examples/elf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,47 +20,6 @@
#
############################################################################

include $(APPDIR)/Make.defs
MENUDESC = "Elf example"

# ELF Example

ifeq ($(CONFIG_EXAMPLES_ELF_ROMFS),y)
CSRCS = romfs.c
endif
ifeq ($(CONFIG_EXAMPLES_ELF_CROMFS),y)
CSRCS = cromfs.c
endif
CSRCS += dirlist.c
CSRCS += symtab.c
tests$(DELIM)symtab.c_CFLAGS = -fno-builtin
tests$(DELIM)symtab.c_CELFFLAGS = -fno-builtin
MAINSRC = elf_main.c

PROGNAME = elf
PRIORITY = SCHED_PRIORITY_DEFAULT
STACKSIZE = $(CONFIG_DEFAULT_TASK_STACKSIZE)
MODULE = $(CONFIG_EXAMPLES_ELF)

DEPPATH := --dep-path tests

# Build targets

VPATH += :tests

ifeq ($(CONFIG_EXAMPLES_ELF_ROMFS),y)
tests/romfs.c: build
endif
ifeq ($(CONFIG_EXAMPLES_ELF_CROMFS),y)
tests/cromfs.c: build
endif
tests/dirlist.c: build
tests/symtab.c: build

.PHONY: build
build:
+$(Q) $(MAKE) -C tests TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" CROSSDEV=$(CROSSDEV)

clean::
+$(Q) $(MAKE) -C tests TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" CROSSDEV=$(CROSSDEV) clean

include $(APPDIR)/Application.mk
include $(APPDIR)/Directory.mk
4 changes: 4 additions & 0 deletions examples/elf/main/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/elf_romfs.c
/elf_romfs.img
/cromfs.c
/test_symtab.c
26 changes: 26 additions & 0 deletions examples/elf/main/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# ##############################################################################
# apps/examples/elf/main/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################

if(CONFIG_EXAMPLES_ELF)
nuttx_add_application(NAME elf SRCS elf_main.c)

# TODO: tests

endif()
File renamed without changes.
23 changes: 23 additions & 0 deletions examples/elf/main/Make.defs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
############################################################################
# apps/examples/elf/main/Make.defs
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################

ifneq ($(CONFIG_EXAMPLES_ELF),)
CONFIGURED_APPS += $(APPDIR)/examples/elf/main
endif
112 changes: 112 additions & 0 deletions examples/elf/main/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
############################################################################
# apps/examples/elf/main/Makefile
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################

include $(APPDIR)/Make.defs

# Module example built-in application info

PROGNAME = elf
PRIORITY = SCHED_PRIORITY_DEFAULT
STACKSIZE = $(CONFIG_DEFAULT_TASK_STACKSIZE)
MODULE = $(CONFIG_EXAMPLES_ELF)

MAINSRC = elf_main.c

SYMTABSRC = test_symtab.c
SYMTABOBJ = $(SYMTABSRC:.c=$(OBJEXT))

ELFNAME_BASE = errno hello
ifneq ($(CONFIG_DISABLE_SIGNALS),y)
ELFNAME_BASE += signal
endif

ifeq ($(CONFIG_HAVE_CXX),y)
ELFNAME_BASE += hello++1 hello++2
ifeq ($(CONFIG_HAVE_CXXINITIALIZE),y)
ELFNAME_BASE += hello++3
endif
ifeq ($(CONFIG_EXAMPLES_ELF_CXX),y)
ELFNAME_BASE += hello++4 hello++5
endif
endif
ifeq ($(CONFIG_EXAMPLES_ELF_LONGJMP),y)
ELFNAME_BASE += longjmp
endif
ifneq ($(CONFIG_DISABLE_PTHREAD),y)
ELFNAME_BASE += pthread mutex
endif
ifneq ($(CONFIG_ARCH_ADDRENV),y)
ELFNAME_BASE += task
endif

ELFNAME = $(addprefix $(BINDIR)$(DELIM),$(ELFNAME_BASE))

$(SYMTABSRC):
$(Q) $(APPDIR)$(DELIM)tools$(DELIM)mksymtab.sh $(ELFNAME) g_elf >[email protected]
$(Q) $(call TESTANDREPLACEFILE, [email protected], $@)


$(SYMTABOBJ): %$(OBJEXT): %.c
$(call COMPILE, $<, $@, -fno-lto -fno-builtin)

ifeq ($(CONFIG_EXAMPLES_ELF_ROMFS),y)

ROMFSIMG = elf_romfs.img
ROMFSSRC = elf_romfs.c
ROMFSOBJ = $(ROMFSSRC:.c=$(OBJEXT))

$(ROMFSIMG):
$(Q) genromfs -d $(BINDIR) -f $@

$(ROMFSSRC): $(ROMFSIMG)
$(Q) (echo "#include <nuttx/compiler.h>" >$@ && \
xxd -i $(ROMFSIMG) | sed -e "s/^unsigned char/const unsigned char aligned_data(4)/g" >>$@)

$(ROMFSOBJ): %$(OBJEXT): %.c
$(call COMPILE, $<, $@, -fno-lto -fno-builtin)

else ifeq ($(CONFIG_EXAMPLES_ELF_CROMFS),y)
NXTOOLDIR = $(TOPDIR)/tools
GENCROMFSSRC = gencromfs.c
GENCROMFSEXE = gencromfs$(HOSTEXEEXT)

FSIMG_SRC = cromfs.c
FSIMG_OBJ = $(FSIMG_SRC:.c=$(OBJEXT))

$(NXTOOLDIR)/$(GENCROMFSEXE): $(NXTOOLDIR)/$(GENCROMFSSRC)
$(Q) $(MAKE) -C $(NXTOOLDIR) -f Makefile.host $(GENCROMFSEXE)

# Create the cromfs.c file from the populated cromfs directory

$(FSIMG_SRC):$(NXTOOLDIR)/$(GENCROMFSEXE)
$(Q) $(NXTOOLDIR)/$(GENCROMFSEXE) $(BINDIR) [email protected]
$(Q) $(call TESTANDREPLACEFILE, [email protected], $@)

$(FSIMG_OBJ): %$(OBJEXT): %.c
$(call COMPILE, $<, $@, -fno-lto -fno-builtin)

endif

postinstall:: $(ROMFSOBJ) $(SYMTABOBJ) $(FSIMG_OBJ)
$(call ARLOCK, $(call CONVERT_PATH,$(BIN)), $^)

distclean::
$(Q) $(call DELFILE, $(SYMTABSRC) $(SYMTABOBJ) $(ROMFSSRC) $(ROMFSIMG) $(ROMFSOBJ) $(MODLUE_NAME))


include $(APPDIR)/Application.mk
35 changes: 32 additions & 3 deletions examples/elf/elf_main.c → examples/elf/main/elf_main.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/****************************************************************************
* apps/examples/elf/elf_main.c
* apps/examples/elf/main/elf_main.c
*
* SPDX-License-Identifier: Apache-2.0
*
Expand Down Expand Up @@ -132,8 +132,37 @@ extern const unsigned int elf_romfs_img_len;
# error "No file system selected"
#endif

extern const char *dirlist[];

const char *dirlist[] =
{
"errno",
"hello",
#ifndef CONFIG_DISABLE_SIGNALS
"signal",
#endif
"struct",
#ifdef CONFIG_HAVE_CXX
"hello++1",
"hello++2",
# ifdef CONFIG_HAVE_CXXINITIALIZE
"hello++3",
# endif
# ifdef CONFIG_EXAMPLES_ELF_CXX
"hello++4",
"hello++5",
# endif
#endif
#ifdef CONFIG_EXAMPLES_ELF_LONGJMP
"longjmp"
#endif
#ifndef CONFIG_DISABLE_PTHREAD
"mutex",
"pthread",
#endif
#ifndef CONFIG_ARCH_ADDRENV
"task",
#endif
NULL
};
extern const struct symtab_s g_elf_exports[];
extern const int g_elf_nexports;

Expand Down
1 change: 1 addition & 0 deletions examples/elf/tests/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
/dirlist.c
/extfs
/symtab.c
/Kconfig
41 changes: 41 additions & 0 deletions examples/elf/tests/Make.defs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
############################################################################
# apps/examples/elf/tests/Make.defs
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################

ifeq ($(CONFIG_EXAMPLES_ELF),y)
CONFIGURED_APPS += $(APPDIR)/examples/elf/tests/errno
CONFIGURED_APPS += $(APPDIR)/examples/elf/tests/hello
ifneq ($(CONFIG_DISABLE_SIGNALS),y)
CONFIGURED_APPS += $(APPDIR)/examples/elf/tests/signal
endif
CONFIGURED_APPS += $(APPDIR)/examples/elf/tests/struct
ifeq ($(CONFIG_HAVE_CXX),y)
CONFIGURED_APPS += $(APPDIR)/examples/elf/tests/helloxx
endif
ifeq ($(CONFIG_EXAMPLES_ELF_LONGJMP),y)
CONFIGURED_APPS += $(APPDIR)/examples/elf/tests/longjmp
endif
ifneq ($(CONFIG_DISABLE_PTHREAD),y)
CONFIGURED_APPS += $(APPDIR)/examples/elf/tests/mutex
CONFIGURED_APPS += $(APPDIR)/examples/elf/tests/pthread
endif
ifneq ($(CONFIG_ARCH_ADDRENV),y)
CONFIGURED_APPS += $(APPDIR)/examples/elf/tests/task
endif
endif
Loading
Loading