From 5951322f72b9d336ca7a3f2888ca1c248756ef4c Mon Sep 17 00:00:00 2001 From: jsteube Date: Wed, 3 Apr 2019 15:37:29 +0200 Subject: [PATCH] Testcommit using ar tool in Makefile --- src/Makefile | 81 +++++++++++++++++++++++----------------------------- 1 file changed, 36 insertions(+), 45 deletions(-) diff --git a/src/Makefile b/src/Makefile index 6d869b633..c6e98b20f 100644 --- a/src/Makefile +++ b/src/Makefile @@ -55,6 +55,7 @@ MODULE_INTERFACE_VERSION := 520 ## CC := gcc +AR := ar FIND := find INSTALL := install RM := rm @@ -222,7 +223,9 @@ endif ifeq ($(UNAME),Linux) CFLAGS_NATIVE := $(CFLAGS) CFLAGS_NATIVE += -DWITH_HWMON +CFLAGS_NATIVE += -ffunction-sections -fdata-sections LFLAGS_NATIVE := $(LFLAGS) +LFLAGS_NATIVE += -Wl,--gc-sections LFLAGS_NATIVE += -lpthread LFLAGS_NATIVE += -ldl LFLAGS_NATIVE += -lrt @@ -278,7 +281,7 @@ endif # MSYS2 ## EMU_OBJS_ALL := emu_general emu_inc_common emu_inc_scalar emu_inc_simd -EMU_OBJS_ALL += emu_inc_rp emu_inc_rp_optimized +EMU_OBJS_ALL += emu_inc_rp emu_inc_rp_optimized EMU_OBJS_ALL += emu_inc_truecrypt_crc32 emu_inc_truecrypt_keyfile emu_inc_truecrypt_xts emu_inc_veracrypt_xts EMU_OBJS_ALL += emu_inc_hash_md4 emu_inc_hash_md5 emu_inc_hash_ripemd160 emu_inc_hash_sha1 emu_inc_hash_sha256 emu_inc_hash_sha384 emu_inc_hash_sha512 emu_inc_hash_streebog256 emu_inc_hash_streebog512 EMU_OBJS_ALL += emu_inc_cipher_aes emu_inc_cipher_camellia emu_inc_cipher_des emu_inc_cipher_kuznyechik emu_inc_cipher_serpent emu_inc_cipher_twofish @@ -289,18 +292,14 @@ ifeq ($(ENABLE_BRAIN),1) OBJS_ALL += brain endif -NATIVE_STATIC_OBJS := $(foreach OBJ,$(OBJS_ALL),obj/$(OBJ).NATIVE.STATIC.o) -NATIVE_SHARED_OBJS := $(foreach OBJ,$(OBJS_ALL),obj/$(OBJ).NATIVE.SHARED.o) - +NATIVE_OBJS := $(foreach OBJ,$(OBJS_ALL),obj/$(OBJ).NATIVE.o) LINUX_OBJS := $(foreach OBJ,$(OBJS_ALL),obj/$(OBJ).LINUX.o) WIN_OBJS := $(foreach OBJ,$(OBJS_ALL),obj/$(OBJ).WIN.o) ifeq ($(USE_SYSTEM_LZMA),0) OBJS_LZMA := Alloc Lzma2Dec LzmaDec -NATIVE_STATIC_OBJS += $(foreach OBJ,$(OBJS_LZMA),obj/$(OBJ).NATIVE.STATIC.o) -NATIVE_SHARED_OBJS += $(foreach OBJ,$(OBJS_LZMA),obj/$(OBJ).NATIVE.SHARED.o) - +NATIVE_OBJS += $(foreach OBJ,$(OBJS_LZMA),obj/$(OBJ).NATIVE.o) LINUX_OBJS += $(foreach OBJ,$(OBJS_LZMA),obj/$(OBJ).LINUX.o) WIN_OBJS += $(foreach OBJ,$(OBJS_LZMA),obj/$(OBJ).WIN.o) endif @@ -309,28 +308,12 @@ ifeq ($(USE_SYSTEM_XXHASH),0) ifeq ($(ENABLE_BRAIN),1) OBJS_XXHASH := xxhash -NATIVE_STATIC_OBJS += $(foreach OBJ,$(OBJS_XXHASH),obj/$(OBJ).NATIVE.STATIC.o) -NATIVE_SHARED_OBJS += $(foreach OBJ,$(OBJS_XXHASH),obj/$(OBJ).NATIVE.SHARED.o) - +NATIVE_OBJS += $(foreach OBJ,$(OBJS_XXHASH),obj/$(OBJ).NATIVE.o) LINUX_OBJS += $(foreach OBJ,$(OBJS_XXHASH),obj/$(OBJ).LINUX.o) WIN_OBJS += $(foreach OBJ,$(OBJS_XXHASH),obj/$(OBJ).WIN.o) endif endif -EMU_MODULE_OBJS_ALL := emu_general emu_inc_common emu_inc_cipher_aes emu_inc_cipher_des emu_inc_hash_md4 emu_inc_hash_md5 emu_inc_hash_sha1 emu_inc_hash_sha256 emu_inc_hash_sha512 - -MODULE_OBJS_ALL := bitops convert cpu_crc32 ext_lzma filehandling keyboard_layout memory shared $(EMU_MODULE_OBJS_ALL) - -ifeq ($(USE_SYSTEM_LZMA),0) -MODULE_OBJS_ALL += Alloc Lzma2Dec LzmaDec -endif - -MODULE_NATIVE_STATIC_OBJS := $(foreach OBJ,$(MODULE_OBJS_ALL),obj/$(OBJ).NATIVE.STATIC.o) -MODULE_NATIVE_SHARED_OBJS := $(foreach OBJ,$(MODULE_OBJS_ALL),obj/$(OBJ).NATIVE.SHARED.o) - -MODULE_LINUX_OBJS := $(foreach OBJ,$(MODULE_OBJS_ALL),obj/$(OBJ).LINUX.o) -MODULE_WIN_OBJS := $(foreach OBJ,$(MODULE_OBJS_ALL),obj/$(OBJ).WIN.o) - ## ## Targets: Native Compilation ## @@ -461,35 +444,29 @@ uninstall: ## native compiled hashcat library and frontend ## -obj/%.NATIVE.STATIC.o: src/%.c - $(CC) -c $(CFLAGS_NATIVE) $< -o $@ - -obj/%.NATIVE.SHARED.o: src/%.c +obj/%.NATIVE.o: src/%.c $(CC) -c $(CFLAGS_NATIVE) $< -o $@ -fpic ifeq ($(USE_SYSTEM_LZMA),0) -obj/%.NATIVE.STATIC.o: $(DEPS_LZMA_PATH)/%.c - $(CC) -c $(CFLAGS_NATIVE) $< -o $@ - -obj/%.NATIVE.SHARED.o: $(DEPS_LZMA_PATH)/%.c +obj/%.NATIVE.o: $(DEPS_LZMA_PATH)/%.c $(CC) -c $(CFLAGS_NATIVE) $< -o $@ -fpic endif ifeq ($(USE_SYSTEM_XXHASH),0) ifeq ($(ENABLE_BRAIN),1) -obj/%.NATIVE.STATIC.o: $(DEPS_XXHASH_PATH)/%.c - $(CC) -c $(CFLAGS_NATIVE) $< -o $@ - -obj/%.NATIVE.SHARED.o: $(DEPS_XXHASH_PATH)/%.c +obj/%.NATIVE.o: $(DEPS_XXHASH_PATH)/%.c $(CC) -c $(CFLAGS_NATIVE) $< -o $@ -fpic endif endif +obj/combined.NATIVE.a: $(NATIVE_OBJS) + $(AR) rcs $@ $^ + ifeq ($(UNAME),Darwin) -$(HASHCAT_LIBRARY): $(NATIVE_SHARED_OBJS) +$(HASHCAT_LIBRARY): $(NATIVE_OBJS) $(CC) $^ -o $@ $(LFLAGS_NATIVE) -shared -install_name $(DESTDIR)$(LIBRARY_FOLDER)/$(HASHCAT_LIBRARY) -current_version $(VERSION_PURE) -compatibility_version $(VERSION_PURE) else -$(HASHCAT_LIBRARY): $(NATIVE_SHARED_OBJS) +$(HASHCAT_LIBRARY): $(NATIVE_OBJS) $(CC) $^ -o $@ $(LFLAGS_NATIVE) -shared -Wl,-soname,$(HASHCAT_LIBRARY) endif @@ -497,7 +474,7 @@ ifeq ($(SHARED),1) $(HASHCAT_FRONTEND): src/main.c $(HASHCAT_LIBRARY) $(CC) $(CFLAGS_NATIVE) $^ -o $@ $(HASHCAT_LIBRARY) $(LFLAGS_NATIVE) -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\" -DINSTALL_FOLDER=\"$(INSTALL_FOLDER)\" -DSHARED_FOLDER=\"$(SHARED_FOLDER)\" -DDOCUMENT_FOLDER=\"$(DOCUMENT_FOLDER)\" else -$(HASHCAT_FRONTEND): src/main.c $(NATIVE_STATIC_OBJS) +$(HASHCAT_FRONTEND): src/main.c obj/combined.NATIVE.a $(CC) $(CFLAGS_NATIVE) $^ -o $@ $(LFLAGS_NATIVE) -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\" -DINSTALL_FOLDER=\"$(INSTALL_FOLDER)\" -DSHARED_FOLDER=\"$(SHARED_FOLDER)\" -DDOCUMENT_FOLDER=\"$(DOCUMENT_FOLDER)\" endif @@ -518,8 +495,13 @@ endif MODULES_SRC := $(wildcard src/modules/*.c) MODULES_LIB := $(patsubst src/modules/module_%.c, modules/module_%.$(MODULE_SUFFIX), $(MODULES_SRC)) -modules/module_%.$(MODULE_SUFFIX): src/modules/module_%.c $(MODULE_NATIVE_SHARED_OBJS) +ifeq ($(SHARED),1) +modules/module_%.$(MODULE_SUFFIX): src/modules/module_%.c $(HASHCAT_LIBRARY) $(CC) $(CFLAGS_NATIVE) $^ -o $@ $(LFLAGS_NATIVE) -shared -fPIC -D MODULE_INTERFACE_VERSION_CURRENT=$(MODULE_INTERFACE_VERSION) +else +modules/module_%.$(MODULE_SUFFIX): src/modules/module_%.c obj/combined.NATIVE.a + $(CC) $(CFLAGS_NATIVE) $^ -o $@ $(LFLAGS_NATIVE) -shared -fPIC -D MODULE_INTERFACE_VERSION_CURRENT=$(MODULE_INTERFACE_VERSION) +endif modules: $(MODULES_LIB) @@ -536,6 +518,9 @@ ifeq ($(UNAME),Linux) CC_LINUX := gcc CC_WIN := x86_64-w64-mingw32-gcc +AR_LINUX := ar +AR_WIN := x86_64-w64-mingw32-ar + ## To compile win-iconv with mingw clone from here: https://github.com/win-iconv/win-iconv ## ## Then patch the makefile with the patches from tools/win-iconv-64.diff and run make install @@ -587,10 +572,10 @@ MODULES_LIB_WIN := $(patsubst src/modules/module_%.c, modules/module_%.dll, modules_linux: $(MODULES_LIB_LINUX) modules_win: $(MODULES_LIB_WIN) -modules/module_%.so: src/modules/module_%.c $(MODULE_LINUX_OBJS) +modules/module_%.so: src/modules/module_%.c obj/combined.LINUX.a $(CC_LINUX) $(CFLAGS_CROSS_LINUX) $^ -o $@ $(LFLAGS_CROSS_LINUX) -shared -fPIC -D MODULE_INTERFACE_VERSION_CURRENT=$(MODULE_INTERFACE_VERSION) -modules/module_%.dll: src/modules/module_%.c $(MODULE_WIN_OBJS) +modules/module_%.dll: src/modules/module_%.c obj/combined.WIN.a $(CC_WIN) $(CFLAGS_CROSS_WIN) $^ -o $@ $(LFLAGS_CROSS_WIN) -shared -fPIC -D MODULE_INTERFACE_VERSION_CURRENT=$(MODULE_INTERFACE_VERSION) ## @@ -621,13 +606,19 @@ obj/%.WIN.o: $(DEPS_XXHASH_PATH)/%.c endif endif -hashcat.bin: src/main.c $(LINUX_OBJS) +obj/combined.LINUX.a: $(LINUX_OBJS) + $(AR_LINUX) rcs $@ $^ + +obj/combined.WIN.a: $(WIN_OBJS) + $(AR_WIN) rcs $@ $^ + +hashcat.bin: src/main.c obj/combined.LINUX.a $(CC_LINUX) $(CFLAGS_CROSS_LINUX) -o $@ $^ $(LFLAGS_CROSS_LINUX) -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\" -DINSTALL_FOLDER=\"$(INSTALL_FOLDER)\" -DSHARED_FOLDER=\"$(SHARED_FOLDER)\" -DDOCUMENT_FOLDER=\"$(DOCUMENT_FOLDER)\" -hashcat.exe: src/main.c $(WIN_OBJS) $(WIN_ICONV)/lib/libiconv.a +hashcat.exe: src/main.c obj/combined.WIN.a $(WIN_ICONV)/lib/libiconv.a $(CC_WIN) $(CFLAGS_CROSS_WIN) -o $@ $^ $(LFLAGS_CROSS_WIN) -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\" -hashcat.dll: src/main.c $(WIN_OBJS) $(WIN_ICONV)/lib/libiconv.a +hashcat.dll: src/main.c obj/combined.WIN.a $(WIN_ICONV)/lib/libiconv.a $(CC_WIN) $(CFLAGS_CROSS_WIN) -o $@ $^ $(LFLAGS_CROSS_WIN) -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\" -shared endif