Use a version script to restrict symbols in the .so
We want to stop aes_* and sha_* functions leaking out of our .so, as well as internal _olm_* symbols. This also means we need to link the unit tests against the objects. Possibly we should distinguish between unit tests and integration tests.
This commit is contained in:
parent
d4c8aae803
commit
488567a45f
2 changed files with 17 additions and 9 deletions
17
Makefile
17
Makefile
|
@ -45,7 +45,6 @@ $(OBJECTS): CXXFLAGS += $(OPTIMIZE_FLAGS)
|
||||||
$(TARGET): LDFLAGS += $(OPTIMIZE_FLAGS)
|
$(TARGET): LDFLAGS += $(OPTIMIZE_FLAGS)
|
||||||
|
|
||||||
$(TEST_BINARIES): CPPFLAGS += -Itests/include
|
$(TEST_BINARIES): CPPFLAGS += -Itests/include
|
||||||
$(TEST_BINARIES): LDLIBS += -lolm
|
|
||||||
$(TEST_BINARIES): LDFLAGS += $(TEST_OPTIMIZE_FLAGS) -L$(BUILD_DIR)
|
$(TEST_BINARIES): LDFLAGS += $(TEST_OPTIMIZE_FLAGS) -L$(BUILD_DIR)
|
||||||
|
|
||||||
$(JS_OBJECTS): CFLAGS += $(JS_OPTIMIZE_FLAGS)
|
$(JS_OBJECTS): CFLAGS += $(JS_OPTIMIZE_FLAGS)
|
||||||
|
@ -55,7 +54,9 @@ $(JS_TARGET): LDFLAGS += $(JS_OPTIMIZE_FLAGS)
|
||||||
### top-level targets
|
### top-level targets
|
||||||
|
|
||||||
$(TARGET): $(OBJECTS)
|
$(TARGET): $(OBJECTS)
|
||||||
$(CXX) $(LDFLAGS) --shared -fPIC $^ $(OUTPUT_OPTION)
|
$(CXX) $(LDFLAGS) --shared -fPIC \
|
||||||
|
-Wl,--version-script,version_script.ver \
|
||||||
|
$(OUTPUT_OPTION) $(OBJECTS)
|
||||||
|
|
||||||
js: $(JS_TARGET)
|
js: $(JS_TARGET)
|
||||||
.PHONY: js
|
.PHONY: js
|
||||||
|
@ -78,7 +79,7 @@ build_tests: $(TEST_BINARIES)
|
||||||
test: build_tests
|
test: build_tests
|
||||||
for i in $(TEST_BINARIES); do \
|
for i in $(TEST_BINARIES); do \
|
||||||
echo $$i; \
|
echo $$i; \
|
||||||
LD_LIBRARY_PATH=$(BUILD_DIR) $$i || exit $$?; \
|
$$i || exit $$?; \
|
||||||
done
|
done
|
||||||
|
|
||||||
$(JS_EXPORTED_FUNCTIONS): $(PUBLIC_HEADERS)
|
$(JS_EXPORTED_FUNCTIONS): $(PUBLIC_HEADERS)
|
||||||
|
@ -98,17 +99,15 @@ $(BUILD_DIR)/%.js.bc: src/%.c
|
||||||
$(BUILD_DIR)/%.js.bc: src/%.cpp
|
$(BUILD_DIR)/%.js.bc: src/%.cpp
|
||||||
$(EMCC.cc) $(OUTPUT_OPTION) $<
|
$(EMCC.cc) $(OUTPUT_OPTION) $<
|
||||||
|
|
||||||
$(BUILD_DIR)/%: tests/%.c
|
$(BUILD_DIR)/%: tests/%.c $(OBJECTS)
|
||||||
$(LINK.c) $< $(LOADLIBES) $(LDLIBS) -o $@
|
$(LINK.c) $< $(OBJECTS) $(LOADLIBES) $(LDLIBS) -o $@
|
||||||
|
|
||||||
$(BUILD_DIR)/%: tests/%.cpp
|
$(BUILD_DIR)/%: tests/%.cpp $(OBJECTS)
|
||||||
$(LINK.cc) $< $(LOADLIBES) $(LDLIBS) -o $@
|
$(LINK.cc) $< $(OBJECTS) $(LOADLIBES) $(LDLIBS) -o $@
|
||||||
|
|
||||||
|
|
||||||
### dependencies
|
### dependencies
|
||||||
|
|
||||||
$(TEST_BINARIES): $(TARGET)
|
|
||||||
|
|
||||||
-include $(OBJECTS:.o=.d)
|
-include $(OBJECTS:.o=.d)
|
||||||
-include $(JS_OBJECTS:.bc=.d)
|
-include $(JS_OBJECTS:.bc=.d)
|
||||||
-include $(TEST_BINARIES:=.d)
|
-include $(TEST_BINARIES:=.d)
|
||||||
|
|
9
version_script.ver
Normal file
9
version_script.ver
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
# this is a 'version script' for the linker which tells it to only export
|
||||||
|
# symbols starting 'olm_'.
|
||||||
|
|
||||||
|
{
|
||||||
|
global:
|
||||||
|
olm_*;
|
||||||
|
local:
|
||||||
|
*;
|
||||||
|
};
|
Loading…
Reference in a new issue