Linux/MacOSX: Better approach to avoid that jitterentropy code is optimized by the compiler

This commit is contained in:
Mounir IDRASSI 2019-10-24 19:20:05 +02:00
parent 6b90e02624
commit 96c90d18c2
No known key found for this signature in database
GPG Key ID: 02C30AE90FAE4A6F
3 changed files with 16 additions and 6 deletions

View File

@ -14,12 +14,16 @@ $(NAME): $(NAME).a
clean:
@echo Cleaning $(NAME)
rm -f $(APPNAME) $(NAME).a $(OBJS) $(OBJSEX) $(OBJS:.o=.d) *.gch
rm -f $(APPNAME) $(NAME).a $(OBJS) $(OBJSEX) $(OBJSNOOPT) $(OBJS:.o=.d) $(OBJSEX:.oo=.d) $(OBJSNOOPT:.o0=.d) *.gch
%.o: %.c
@echo Compiling $(<F)
$(CC) $(CFLAGS) -c $< -o $@
%.o0: %.c
@echo Compiling $(<F)
$(CC) $(CFLAGS) -O0 -c $< -o $@
%.o: %.cpp
@echo Compiling $(<F)
$(CXX) $(CXXFLAGS) -c $< -o $@
@ -64,10 +68,10 @@ TR_SED_BIN := tr '\n' ' ' | tr -s ' ' ',' | sed -e 's/^,//g' -e 's/,$$/n/' | tr
# Dependencies
-include $(OBJS:.o=.d) $(OBJSEX:.oo=.d)
-include $(OBJS:.o=.d) $(OBJSEX:.oo=.d) $(OBJSNOOPT:.o0=.d)
$(NAME).a: $(OBJS) $(OBJSEX)
$(NAME).a: $(OBJS) $(OBJSEX) $(OBJSNOOPT)
@echo Updating library $@
$(AR) $(AFLAGS) -rcu $@ $(OBJS) $(OBJSEX)
$(AR) $(AFLAGS) -rcu $@ $(OBJS) $(OBJSEX) $(OBJSNOOPT)
$(RANLIB) $@

View File

@ -57,7 +57,11 @@
#pragma optimize( "", off )
#pragma warning(disable:4242 4244 4334) /* disable warnings on the original code */
#else
#pragma GCC optimize ("O0")
#if defined(__clang__)
#pragma clang optimize off
#elif defined (__GNUC__)
#pragma GCC optimize ("O0")
#endif
#endif
#include "jitterentropy.h"

View File

@ -12,6 +12,7 @@
OBJS :=
OBJSEX :=
OBJSNOOPT :=
OBJS += Cipher.o
OBJS += EncryptionAlgorithm.o
OBJS += EncryptionMode.o
@ -80,7 +81,8 @@ OBJS += ../Crypto/GostCipher.o
OBJS += ../Crypto/Streebog.o
OBJS += ../Crypto/kuznyechik.o
OBJS += ../Crypto/kuznyechik_simd.o
OBJS += ../Crypto/jitterentropy-base.o
OBJSNOOPT += ../Crypto/jitterentropy-base.o0
OBJS += ../Common/Crc.o
OBJS += ../Common/Endian.o