MacOSX: various changes for assembly files build. Don't use 32-bit assembly code of SHA-512 since it is not compatible with PIE configuration of OSX compiler (absolute addressing used)

This commit is contained in:
Mounir IDRASSI 2017-06-26 16:53:12 +02:00
parent e8bafa6a37
commit 3d8260d3d3
No known key found for this signature in database
GPG Key ID: DD0C382D5FCFB8FC
13 changed files with 36 additions and 42 deletions

View File

@ -833,7 +833,7 @@ _camellia_setup256:
ret; ret;
.ifndef WINABI .ifndef __YASM__
#if defined(__linux__) && defined(__ELF__) #if defined(__linux__) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits .section .note.GNU-stack,"",%progbits
#endif #endif

View File

@ -1,4 +1,4 @@
.ifndef WINABI .ifndef __YASM__
#if defined(__linux__) && defined(__ELF__) #if defined(__linux__) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits .section .note.GNU-stack,"",%progbits
#endif #endif

View File

@ -331,7 +331,7 @@ popq %rsi
ret; ret;
.ifndef WINABI .ifndef __YASM__
#if defined(__linux__) && defined(__ELF__) #if defined(__linux__) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits .section .note.GNU-stack,"",%progbits
#endif #endif

View File

@ -1,4 +1,4 @@
.ifndef WINABI .ifndef __YASM__
#if defined(__linux__) && defined(__ELF__) #if defined(__linux__) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits .section .note.GNU-stack,"",%progbits
#endif #endif

View File

@ -26,7 +26,7 @@ extern "C"
void sha512_avx(const void* M, void* D, uint_64t l); void sha512_avx(const void* M, void* D, uint_64t l);
#endif #endif
#if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64 #if CRYPTOPP_BOOL_X64 || ((CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32) && !defined (TC_MACOSX))
void sha512_compress_nayuki(uint_64t state[8], const uint_8t block[128]); void sha512_compress_nayuki(uint_64t state[8], const uint_8t block[128]);
#endif #endif
#if defined(__cplusplus) #if defined(__cplusplus)
@ -173,7 +173,7 @@ void SSE4Transform(sha512_ctx* ctx, void* mp, uint_64t num_blks)
} }
#endif #endif
#if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64 #if CRYPTOPP_BOOL_X64 || ((CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32) && !defined (TC_MACOSX))
void SSE2Transform(sha512_ctx* ctx, void* mp, uint_64t num_blks) void SSE2Transform(sha512_ctx* ctx, void* mp, uint_64t num_blks)
{ {
@ -216,7 +216,7 @@ void sha512_begin(sha512_ctx* ctx)
else else
#endif #endif
#if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64 #if CRYPTOPP_BOOL_X64 || ((CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32) && !defined (TC_MACOSX))
if (HasSSE2() && HasMMX()) if (HasSSE2() && HasMMX())
transfunc = SSE2Transform; transfunc = SSE2Transform;
else else

View File

@ -312,7 +312,7 @@ movq %r8, %rdx;
.endif .endif
ret; ret;
.ifndef WINABI .ifndef __YASM__
#if defined(__linux__) && defined(__ELF__) #if defined(__linux__) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits .section .note.GNU-stack,"",%progbits
#endif #endif

View File

@ -1,11 +1,5 @@
.ifndef WINABI .ifndef __YASM__
%ifidn __OUTPUT_FORMAT__,elf #if defined(__linux__) && defined(__ELF__)
section .note.GNU-stack noalloc noexec nowrite progbits .section .note.GNU-stack,"",%progbits
%endif #endif
%ifidn __OUTPUT_FORMAT__,elf32
section .note.GNU-stack noalloc noexec nowrite progbits
%endif
%ifidn __OUTPUT_FORMAT__,elf64
section .note.GNU-stack noalloc noexec nowrite progbits
%endif
.endif .endif

View File

@ -1,6 +1,6 @@
.ifndef WINABI .ifndef __YASM__
#if defined(__linux__) && defined(__ELF__) #if defined(__linux__) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits .section .note.GNU-stack,"",%progbits
#endif #endif
.endif .endif

View File

@ -161,8 +161,8 @@
retl retl
.endif .endif
.ifndef WINABI .ifndef __YASM__
#if defined(__linux__) && defined(__ELF__) #if defined(__linux__) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits .section .note.GNU-stack,"",%progbits
#endif #endif
.endif .endif

View File

@ -195,8 +195,8 @@ _sha512_compress_nayuki:
retq retq
.ifndef WINABI .ifndef __YASM__
#if defined(__linux__) && defined(__ELF__) #if defined(__linux__) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits .section .note.GNU-stack,"",%progbits
#endif #endif
.endif .endif

View File

@ -173,7 +173,7 @@
.quad 0x28DB77F523047D84, 0x32CAAB7B40C72493, 0x3C9EBE0A15C9BEBC, 0x431D67C49C100D4C .quad 0x28DB77F523047D84, 0x32CAAB7B40C72493, 0x3C9EBE0A15C9BEBC, 0x431D67C49C100D4C
.quad 0x4CC5D4BECB3E42B6, 0x597F299CFC657E2A, 0x5FCB6FAB3AD6FAEC, 0x6C44198C4A475817 .quad 0x4CC5D4BECB3E42B6, 0x597F299CFC657E2A, 0x5FCB6FAB3AD6FAEC, 0x6C44198C4A475817
.ifndef WINABI .ifndef __YASM__
#if defined(__linux__) && defined(__ELF__) #if defined(__linux__) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits .section .note.GNU-stack,"",%progbits
#endif #endif

View File

@ -44,7 +44,7 @@ export RANLIB ?= ranlib
export CFLAGS := -Wall export CFLAGS := -Wall
export CXXFLAGS := -Wall -Wno-unused-parameter export CXXFLAGS := -Wall -Wno-unused-parameter
C_CXX_FLAGS := -MMD -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGE_FILES -I$(BASE_DIR) -I$(BASE_DIR)/Crypto C_CXX_FLAGS := -MMD -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGE_FILES -I$(BASE_DIR) -I$(BASE_DIR)/Crypto
export ASFLAGS := -D __GNUC__ export ASFLAGS := -D __GNUC__ -D __YASM__
export LFLAGS := export LFLAGS :=
export PKG_CONFIG_PATH ?= /usr/local/lib/pkgconfig export PKG_CONFIG_PATH ?= /usr/local/lib/pkgconfig
@ -251,8 +251,8 @@ ifeq "$(shell uname -s)" "Darwin"
endif endif
AS := $(BASE_DIR)/Build/Tools/MacOSX/yasm AS := $(BASE_DIR)/Build/Tools/MacOSX/yasm
export ASFLAGS32 := -D __GNUC__ -D __BITS__=32 --prefix _ -f macho32 export ASFLAGS32 := -D __GNUC__ -D __YASM__ -D __BITS__=32 --prefix=_ -f macho32
export ASFLAGS64 := -D __GNUC__ -D __BITS__=64 --prefix _ -f macho64 export ASFLAGS64 := -D __GNUC__ -D __YASM__ -D __BITS__=64 --prefix=_ -f macho64
ifeq "$(TC_BUILD_CONFIG)" "Release" ifeq "$(TC_BUILD_CONFIG)" "Release"

View File

@ -36,14 +36,14 @@ ifeq "$(PLATFORM)" "MacOSX"
OBJSEX += ../Crypto/Twofish_asm.oo OBJSEX += ../Crypto/Twofish_asm.oo
OBJSEX += ../Crypto/Camellia_asm.oo OBJSEX += ../Crypto/Camellia_asm.oo
OBJSEX += ../Crypto/Camellia_aesni_asm.oo OBJSEX += ../Crypto/Camellia_aesni_asm.oo
OBJS += ../Crypto/sha256-nayuki.oo OBJSEX += ../Crypto/sha256-nayuki.oo
OBJS += ../Crypto/sha512-nayuki.oo OBJSEX += ../Crypto/sha512-nayuki.oo
OBJS += ../Crypto/sha256_avx1.oo OBJSEX += ../Crypto/sha256_avx1.oo
OBJS += ../Crypto/sha256_avx2.oo OBJSEX += ../Crypto/sha256_avx2.oo
OBJS += ../Crypto/sha256_sse4.oo OBJSEX += ../Crypto/sha256_sse4.oo
OBJS += ../Crypto/sha512_avx1.oo OBJSEX += ../Crypto/sha512_avx1.oo
OBJS += ../Crypto/sha512_avx2.oo OBJSEX += ../Crypto/sha512_avx2.oo
OBJS += ../Crypto/sha512_sse4.oo OBJSEX += ../Crypto/sha512_sse4.oo
else ifeq "$(CPU_ARCH)" "x86" else ifeq "$(CPU_ARCH)" "x86"
OBJS += ../Crypto/Aes_x86.o OBJS += ../Crypto/Aes_x86.o
OBJS += ../Crypto/Aes_hw_cpu.o OBJS += ../Crypto/Aes_hw_cpu.o
@ -106,7 +106,10 @@ ifeq "$(PLATFORM)" "MacOSX"
$(AS) $(ASFLAGS64) -p gas -o ../Crypto/Camellia_aesni_asm.oo ../Crypto/Camellia_aesni_x64.S $(AS) $(ASFLAGS64) -p gas -o ../Crypto/Camellia_aesni_asm.oo ../Crypto/Camellia_aesni_x64.S
../Crypto/sha256-nayuki.oo: ../Crypto/sha256-x86-nayuki.S ../Crypto/sha256-nayuki.oo: ../Crypto/sha256-x86-nayuki.S
@echo Assembling $(<F) @echo Assembling $(<F)
$(AS) $(ASFLAGS32) -p gas -o ../Crypto/sha256-nayuki.oo ../Crypto/sha256-x86-nayuki.S $(AS) $(ASFLAGS32) -p gas -o ../Crypto/sha256-x86-nayuki.o ../Crypto/sha256-x86-nayuki.S
$(AS) $(ASFLAGS64) -p gas -o ../Crypto/sha256-x64-nayuki.o ../Crypto/sha256-x64-nayuki.S
lipo -create ../Crypto/sha256-x86-nayuki.o ../Crypto/sha256-x64-nayuki.o -output ../Crypto/sha256-nayuki.oo
rm -fr ../Crypto/sha256-x86-nayuki.o ../Crypto/sha256-x64-nayuki.o
../Crypto/sha256_avx1.oo: ../Crypto/sha256_avx1_x64.asm ../Crypto/sha256_avx1.oo: ../Crypto/sha256_avx1_x64.asm
@echo Assembling $(<F) @echo Assembling $(<F)
$(AS) $(ASFLAGS64) -o ../Crypto/sha256_avx1.oo ../Crypto/sha256_avx1_x64.asm $(AS) $(ASFLAGS64) -o ../Crypto/sha256_avx1.oo ../Crypto/sha256_avx1_x64.asm
@ -116,12 +119,9 @@ ifeq "$(PLATFORM)" "MacOSX"
../Crypto/sha256_sse4.oo: ../Crypto/sha256_sse4_x64.asm ../Crypto/sha256_sse4.oo: ../Crypto/sha256_sse4_x64.asm
@echo Assembling $(<F) @echo Assembling $(<F)
$(AS) $(ASFLAGS64) -o ../Crypto/sha256_sse4.oo ../Crypto/sha256_sse4_x64.asm $(AS) $(ASFLAGS64) -o ../Crypto/sha256_sse4.oo ../Crypto/sha256_sse4_x64.asm
../Crypto/sha512-nayuki.oo: ../Crypto/sha512-x86-nayuki.S ../Crypto/sha512-x64-nayuki.S ../Crypto/sha512-nayuki.oo: ../Crypto/sha512-x64-nayuki.S
@echo Assembling $(<F) @echo Assembling $(<F)
$(AS) -p gas $(ASFLAGS32) -o ../Crypto/sha512-x86-nayuki.o ../Crypto/sha512-x86-nayuki.S $(AS) -p gas $(ASFLAGS64) -o ../Crypto/sha512-nayuki.oo ../Crypto/sha512-x64-nayuki.S
$(AS) -p gas $(ASFLAGS64) -o ../Crypto/sha512-x64-nayuki.o ../Crypto/sha512-x64-nayuki.S
lipo -create ../Crypto/sha512-x86-nayuki.o ../Crypto/sha512-x64-nayuki.o -output ../Crypto/sha512-nayuki.oo
rm -fr ../Crypto/sha512-x86-nayuki.o ../Crypto/sha512-x64-nayuki.o
../Crypto/sha512_avx1.oo: ../Crypto/sha512_avx1_x64.asm ../Crypto/sha512_avx1.oo: ../Crypto/sha512_avx1_x64.asm
@echo Assembling $(<F) @echo Assembling $(<F)
$(AS) $(ASFLAGS64) -o ../Crypto/sha512_avx1.oo ../Crypto/sha512_avx1_x64.asm $(AS) $(ASFLAGS64) -o ../Crypto/sha512_avx1.oo ../Crypto/sha512_avx1_x64.asm