aboutsummaryrefslogtreecommitdiff
path: root/makefiles
diff options
context:
space:
mode:
authorLorenz Meier <lorenz@px4.io>2015-03-21 08:10:32 +0100
committerLorenz Meier <lorenz@px4.io>2015-03-21 08:10:32 +0100
commit49834b11cbea6fd0bb69650573cc275f01b0dbc5 (patch)
treecdd5c76f08bf45a5d64ced3e31abb58725313dbe /makefiles
parentecec2d76d9217713c800a48f1be0a886af5bb517 (diff)
parent631e518c45b054441cbe9eba5167d3075d5d2a9d (diff)
downloadpx4-firmware-49834b11cbea6fd0bb69650573cc275f01b0dbc5.tar.gz
px4-firmware-49834b11cbea6fd0bb69650573cc275f01b0dbc5.tar.bz2
px4-firmware-49834b11cbea6fd0bb69650573cc275f01b0dbc5.zip
Merge pull request #1938 from Grawp/master
Fix generating $3_len in BIN_TO_OBJ makefile function
Diffstat (limited to 'makefiles')
-rw-r--r--makefiles/toolchain_gnu-arm-eabi.mk12
1 files changed, 9 insertions, 3 deletions
diff --git a/makefiles/toolchain_gnu-arm-eabi.mk b/makefiles/toolchain_gnu-arm-eabi.mk
index 2c5302812..3b9fefb3e 100644
--- a/makefiles/toolchain_gnu-arm-eabi.mk
+++ b/makefiles/toolchain_gnu-arm-eabi.mk
@@ -296,6 +296,9 @@ endef
#
# - compile an empty file to generate a suitable object file
# - relink the object and insert the binary file
+# - extract the length
+# - create const unsigned $3_len with the extracted length as its value and compile it to an object file
+# - link the two generated object files together
# - edit symbol names to suit
#
# NOTE: exercise caution using this with absolute pathnames; it looks
@@ -320,11 +323,14 @@ define BIN_TO_OBJ
@$(MKDIR) -p $(dir $2)
$(Q) $(ECHO) > $2.c
$(call COMPILE,$2.c,$2.c.o)
- $(Q) $(LD) -r -o $2 $2.c.o -b binary $1
+ $(Q) $(LD) -r -o $2.bin.o $2.c.o -b binary $1
+ $(Q) $(ECHO) "const unsigned int $3_len = 0x`$(NM) -p --radix=x $2.bin.o | $(GREP) $(call BIN_SYM_PREFIX,$1)_size$$ | $(GREP) -o ^[0-9a-fA-F]*`;" > $2.c
+ $(call COMPILE,$2.c,$2.c.o)
+ $(Q) $(LD) -r -o $2 $2.c.o $2.bin.o
$(Q) $(OBJCOPY) $2 \
--redefine-sym $(call BIN_SYM_PREFIX,$1)_start=$3 \
- --redefine-sym $(call BIN_SYM_PREFIX,$1)_size=$3_len \
+ --strip-symbol $(call BIN_SYM_PREFIX,$1)_size \
--strip-symbol $(call BIN_SYM_PREFIX,$1)_end \
--rename-section .data=.rodata
- $(Q) $(REMOVE) $2.c $2.c.o
+ $(Q) $(REMOVE) $2.c $2.c.o $2.bin.o
endef