diff --git a/common.mk b/common.mk index b35dbd9..4ece70a 100644 --- a/common.mk +++ b/common.mk @@ -160,6 +160,26 @@ endif -include $$($(1)_OBJ_FILES:.o=.d) endef +# Remove comment lines from libgcc.remove file +$(BUILD_DIR)libgcc.remove: $(ROOT)lib/libgcc.remove | $(BUILD_DIR) + $(Q) grep -v "^#" $< | cat > $@ + +# Remove unwanted object files listed in libgcc.remove +$(BUILD_DIR)libgcc.a: $(ROOT)lib/libgcc.a $(BUILD_DIR)libgcc.remove | $(BUILD_DIR) + @echo "Removing unwanted objects from $<" + $(Q) cat $< > $@ + $(Q) $(AR) d $@ @$(word 2,$^) + +# Remove comment lines from libc.remove file +$(BUILD_DIR)libc.remove: $(ROOT)libc/libc.remove | $(BUILD_DIR) + $(Q) grep -v "^#" $< | cat > $@ + +# Remove unwanted object files listed in libgcc.remove +$(BUILD_DIR)libc.a: $(ROOT)libc/xtensa-lx106-elf/lib/libc.a $(BUILD_DIR)libc.remove | $(BUILD_DIR) + @echo "Removing unwanted objects from $<" + $(Q) cat $< > $@ + $(Q) $(AR) d $@ @$(word 2,$^) + ## Linking rules for SDK libraries ## SDK libraries are preprocessed to: # - remove object files named in .remove @@ -208,9 +228,9 @@ $(foreach component,$(COMPONENTS), \ ) # final linking step to produce .elf -$(PROGRAM_OUT): $(WHOLE_ARCHIVES) $(COMPONENT_ARS) $(SDK_PROCESSED_LIBS) $(LINKER_SCRIPTS) +$(PROGRAM_OUT): $(WHOLE_ARCHIVES) $(COMPONENT_ARS) $(BUILD_DIR)libgcc.a $(BUILD_DIR)libc.a $(SDK_PROCESSED_LIBS) $(LINKER_SCRIPTS) $(vecho) "LD $@" - $(Q) $(LD) $(LDFLAGS) -Wl,--whole-archive $(WHOLE_ARCHIVES) -Wl,--no-whole-archive -Wl,--start-group $(COMPONENT_ARS) $(LIB_ARGS) $(SDK_LIB_ARGS) -Wl,--end-group -o $@ + $(Q) $(LD) $(LDFLAGS) -Wl,--whole-archive $(WHOLE_ARCHIVES) -Wl,--no-whole-archive -Wl,--start-group $(COMPONENT_ARS) $(BUILD_DIR)libgcc.a $(BUILD_DIR)libc.a $(LIB_ARGS) $(SDK_LIB_ARGS) -Wl,--end-group -o $@ $(BUILD_DIR) $(FIRMWARE_DIR) $(BUILD_DIR)sdklib: $(Q) mkdir -p $@ diff --git a/lib/libgcc.a b/lib/libgcc.a new file mode 100644 index 0000000..b981970 Binary files /dev/null and b/lib/libgcc.a differ diff --git a/lib/libgcc.remove b/lib/libgcc.remove new file mode 100644 index 0000000..f573074 --- /dev/null +++ b/lib/libgcc.remove @@ -0,0 +1,24 @@ +# Object files to be removed from libgcc +# These are provided by the ROM. +_addsubdf3.o +_addsubsf3.o +_divdf3.o +_divdi3.o +_divsi3.o +_extendsfdf2.o +_fixdfsi.o +_fixunssfsi.o +_floatsidf.o +_floatsisf.o +_floatunsidf.o +_floatunsisf.o +_muldf3.o +_muldi3.o +_mulsf3.o +_subdf3.o +_subsf3.o +_truncdfsf2.o +_udivdi3.o +_umoddi3.o +_umodsi3.o +_umulsidi3.o diff --git a/libc/libc.remove b/libc/libc.remove new file mode 100644 index 0000000..ddf65ba --- /dev/null +++ b/libc/libc.remove @@ -0,0 +1,13 @@ +# Object files to remove from libc.a +# These are provided by the ROM. +lib_a-bzero.o +lib_a-memcmp.o +lib_a-memcpy.o +lib_a-memmove.o +lib_a-memset.o +lib_a-strcmp.o +lib_a-strcpy.o +lib_a-strlen.o +lib_a-strncmp.o +lib_a-strncpy.o +lib_a-strstr.o diff --git a/parameters.mk b/parameters.mk index 8c6a8a3..e1f019e 100644 --- a/parameters.mk +++ b/parameters.mk @@ -66,7 +66,7 @@ COMPONENTS ?= $(EXTRA_COMPONENTS) FreeRTOS lwip core open_esplibs SDK_LIBS ?= main net80211 phy pp wpa # open source libraries linked in -LIBS ?= hal gcc c +LIBS ?= hal # set to 0 if you want to use the toolchain libc instead of esp-open-rtos newlib OWN_LIBC ?= 1