htcp

Properties of water suspended in clouds
git clone git://git.meso-star.fr/htcp.git
Log | Files | Refs | README | LICENSE

commit c8d626a0aa798946088ecbaaf3aa189073a7b9d1
parent 0a06be7452c204e8cc76f8c2e60e4e659399518b
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Mon, 30 Oct 2023 14:27:44 +0100

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.

Diffstat:
MMakefile | 9+++++++--
Mconfig.mk | 12+++++++++---
2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile @@ -49,10 +49,14 @@ $(DEP) $(OBJ): config.mk $(LIBNAME_SHARED): $(OBJ) $(CC) $(CFLAGS_SO) $(RSYS_CFLAGS) -o $@ $(OBJ) $(LDFLAGS_SO) $(RSYS_LIBS) -$(LIBNAME_STATIC): $(OBJ) +$(LIBNAME_STATIC): libhtcp.o $(AR) -rc $@ $? $(RANLIB) $@ +libhtcp.o: $(OBJ) + $(LD) -r $(OBJ) -o $@ + $(OBJCOPY) $(OCPFLAGS) $@ + src/les2htcp.d src/les2htcp.o: config.mk src/les2htcp.c: src/les2htcp.h @@ -129,7 +133,8 @@ uninstall: all: build_library build_program build_tests clean: clean_test - rm -f $(OBJ) src/les2htcp.o $(TEST_OBJ) $(LIBNAME) les2htcp .config .test htcp.pc htcp-local.pc + rm -f $(OBJ) src/les2htcp.o $(TEST_OBJ) $(LIBNAME) les2htcp + rm -f .config .test libhtcp·o htcp.pc htcp-local.pc distclean: clean rm -f $(DEP) src/les2htcp.d src/les2htcp.h $(TEST_DEP) diff --git a/config.mk b/config.mk @@ -15,6 +15,8 @@ BUILD_TYPE = RELEASE ################################################################################ AR = ar CC = cc +LD = ld +OBJCOPY = objcopy PKG_CONFIG = pkg-config RANLIB = ranlib @@ -68,9 +70,13 @@ CFLAGS_EXE = $(CFLAGS_$(BUILD_TYPE)) -fPIE ################################################################################ # Linker options ################################################################################ -LDFLAGS_COMMON = -Wl,-z,relro,-z,now -LDFLAGS_DEBUG = $(LDFLAGS_COMMON) -LDFLAGS_RELEASE = -s $(LDFLAGS_COMMON) +LDFLAGS_HARDENED = -Wl,-z,relro,-z,now +LDFLAGS_DEBUG = $(LDFLAGS_HARDENED) +LDFLAGS_RELEASE = -s $(LDFLAGS_HARDENED) LDFLAGS_SO = $(LDFLAGS_$(BUILD_TYPE)) -shared -Wl,--no-undefined LDFLAGS_EXE = $(LDFLAGS_$(BUILD_TYPE)) -pie + +OCPFLAGS_DEBUG = --localize-hidden +OCPFLAGS_RELEASE = --localize-hidden --strip-unneeded +OCPFLAGS = $(OCPFLAGS_$(BUILD_TYPE))