commit d7cd9c5fc63efd6603b207715806a2367e96b1a6
parent dba5f3b6f3374051871282fff81b05a5ee629fb0
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Wed, 11 Oct 2023 15:11:51 +0200
Partially link static library object files
Make hidden symbols local to the relocatable object to avoid conflicts
with internal symbols in another static library. In release mode, delete
all symbols not required for relocation processing, but keep them in
debug mode for... debugging purposes.
Diffstat:
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
@@ -42,10 +42,14 @@ $(DEP) $(OBJ): config.mk
$(LIBNAME_SHARED): $(OBJ)
$(CC) $(CFLAGS) $(RSYS_CFLAGS) -o $@ $(OBJ) $(LDFLAGS) $(SOFLAGS) $(RSYS_LIBS)
-$(LIBNAME_STATIC): $(OBJ)
+$(LIBNAME_STATIC): libmrumtl.o
$(AR) -rc $@ $?
$(RANLIB) $@
+libmrumtl.o: $(OBJ)
+ $(LD) -r $(OBJ) -o $@
+ $(OBJCOPY) $(OCPFLAGS) $@
+
.config: config.mk
@if ! $(PKG_CONFIG) --atleast-version $(RSYS_VERSION) rsys; then \
echo "rsys $(RSYS_VERSION) not found" >&2; exit 1; fi
diff --git a/config.mk b/config.mk
@@ -12,7 +12,9 @@ BUILD_TYPE = RELEASE
################################################################################
AR = ar
CC = cc
+LD = ld
PKG_CONFIG = pkg-config
+OBJCOPY = objcopy
RANLIB = ranlib
################################################################################
@@ -58,3 +60,7 @@ SOFLAGS = -shared -Wl,--no-undefined
LDFLAGS_DEBUG =
LDFLAGS_RELEASE = -s
LDFLAGS = $(LDFLAGS_$(BUILD_TYPE))
+
+OCPFLAGS_DEBUG = --localize-hidden
+OCPFLAGS_RELEASE = --localize-hidden --strip-unneeded
+OCPFLAGS = $(OCPFLAGS_$(BUILD_TYPE))