Shared library, hardening

This commit is contained in:
flamingcow
2019-05-09 21:29:53 -07:00
parent 4d9486e281
commit 944483d13f
2 changed files with 10 additions and 4 deletions

1
.gitignore vendored
View File

@@ -1,2 +1,3 @@
*.a *.a
*.o *.o
*.so

View File

@@ -1,7 +1,9 @@
FIRE_CXX ?= clang++ FIRE_CXX ?= clang++
FIRE_CXXFLAGS ?= -O3 -std=gnu++2a -Wall -Werror FIRE_CXXFLAGS ?= -O3 -std=gnu++2a -Wall -Werror -Wextra -fPIE -fPIC -fstack-protector-strong -fsanitize=safe-stack -fsanitize=safe-stack
FIRE_LDFLAGS ?= -fuse-ld=gold -flto -Wl,-z,relro -Wl,-z,now
FIRE_LDLIBS ?= -lglog
all: firebuf.a firebuf.o all: firebuf.a firebuf.o firebuf.so
objects = stream_buffer.o buffer.o objects = stream_buffer.o buffer.o
@@ -9,13 +11,16 @@ firebuf.a: $(objects)
ar rcs $@ $^ ar rcs $@ $^
firebuf.o: $(objects) firebuf.o: $(objects)
ld --relocatable --output=$@ $+ gold -z relro -z now -r --output=$@ $+
firebuf.so: $(objects)
$(FIRE_CXX) $(FIRE_CXXFLAGS) $(FIRE_LDFLAGS) -shared -o $@ $+ $(FIRE_LDFLIBS)
%.o: %.cc *.h Makefile %.o: %.cc *.h Makefile
$(FIRE_CXX) $(FIRE_CXXFLAGS) -c -o $@ $< $(FIRE_CXX) $(FIRE_CXXFLAGS) -c -o $@ $<
clean: clean:
rm --force *.o *.a rm --force *.so *.o *.a
asan: asan:
$(MAKE) clean $(MAKE) clean