Some link improvements

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2895 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2010-08-28 19:46:58 +00:00
parent 0c22971606
commit 8ff4e26a23
2 changed files with 28 additions and 13 deletions

View File

@ -33,38 +33,58 @@
#
############################################################################
-include $(TOPDIR)/.config
-include $(TOPDIR)/Make.defs
# Remove the application library (libapp) from the list of libraries.
PASS1_LIBAPP = $(CONFIG_APP_DIR)/libapp$(LIBEXT)
PASS1_LINKLIBS = $(filter-out $(PASS1_LIBAPP),$(LINKLIBS))
# Get the paths to the libraries and the links script path in format that
# is appropriate for the host OS
ifeq ($(WINTOOL),y)
# Windows-native toolchains
PASS1_LIBPATHS = ${shell for path in $(LINKLIBS); do dir=`dirname $(TOPDIR)/$$path`;echo "-L\"`cygpath -w $$dir`\"";done}
PASS1_LIBPATHS = ${shell for path in $(PASS1_LINKLIBS); do dir=`dirname $(TOPDIR)/$$path`;echo "-L\"`cygpath -w $$dir`\"";done}
PASS1_LDSCRIPT = -T "${shell cygpath -w $(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/locked/ld-locked.inc}"
else
# Linux/Cygwin-native toolchain
PASS1_LIBPATHS = $(addprefix -L$(TOPDIR)/,$(dir $(LINKLIBS)))
PASS1_LIBPATHS = $(addprefix -L$(TOPDIR)/,$(dir $(PASS1_LINKLIBS)))
PASS1_LDSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/locked/ld-locked.inc
endif
PASS1_LDFLAGS = -r $(PASS1_LDSCRIPT)
PASS1_LDLIBS = $(patsubst lib%,-l%,$(basename $(notdir $(LINKLIBS))))
PASS1_LDLIBS = $(patsubst lib%,-l%,$(basename $(notdir $(PASS1_LINKLIBS))))
PASS1_LIBGCC = "${shell $(CC) -print-libgcc-file-name}"
all: locked.r
# Create include-able linker script that specifies all of the symbols to be
# resolved in the locked.r file.
ld-locked.inc: mklocked.sh $(TOPDIR)/.config
@echo "MK: ld-locked.inc"
@./mklocked.sh "$(TOPDIR)"
locked.r: ld-locked.inc $(OBJS)
# Create the locked.r file containing all of the code (except the start-up code)
# that needs to lie in the locked text region.
locked.r: ld-locked.inc
@echo "LD: locked.r"
@$(LD) -o $@ $(PASS1_LDFLAGS) $(PASS1_LIBPATHS) --start-group $(PASS1_LDLIBS) --end-group -u os_start $(PASS1_LIBGCC)
@$(LD) -o $@ $(PASS1_LDFLAGS) $(PASS1_LIBPATHS) --start-group $(PASS1_LDLIBS) --end-group $(PASS1_LIBGCC)
@echo "NM: locked.map"
@$(NM) $@ > locked.map
@fgrep " U " locked.map | grep -v os_start
@echo "SZ:"
@$(CROSSDEV)size $@
.depend:
depend: .depend
clean:
@rm -f locked.r *~ .*.swp
@rm -f locked.r locked.map *~ .*.swp
distclean: clean
@rm -f ld-locked.inc

View File

@ -117,13 +117,9 @@ fi
# Idle Loop
############################################################################
#
# The IDLE loop must be forced to lie in the locked .text region. NOTE that
# most of the IDLE loop is is os_start.c, but we don't we want to handle
# that differently so that it does not draw in a lot of things that we do
# not need in the locked region. However, we do need to bring in all of
# the things called by os_start up to the point where the page fill worker
# thread is started.
# The IDLE loop must be forced to lie in the locked .text region.
echo "EXTERN(os_start)" >>ld-locked.inc
echo "EXTERN(up_idle)" >>ld-locked.inc
############################################################################
@ -133,4 +129,3 @@ echo "EXTERN(up_idle)" >>ld-locked.inc
# All of the page fill worker thread must be in the locked .text region.
echo "EXTERN(pg_worker)" >>ld-locked.inc