[PATCH 1/3] Switch to strong aliases, allows for Windows targets
Michael Haubenwallner
michael.haubenwallner at ssi-schaefer.com
Thu Aug 22 14:55:42 UTC 2019
Windows (Cygwin, MinGW) does not support weak symbols, and
actually there is no good reason to have them weak at all.
Also, inline assembly is not portable in general.
---
src/sha2.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/src/sha2.c b/src/sha2.c
index 849ebbb..8d70fad 100644
--- a/src/sha2.c
+++ b/src/sha2.c
@@ -41,11 +41,8 @@
#include <string.h>
#include <sha2.h>
-#define _C_LABEL_STRING(x) x
-
-#define __weak_alias(alias,sym) \
- __asm(".weak " _C_LABEL_STRING(#alias) "\n" \
- _C_LABEL_STRING(#alias) " = " _C_LABEL_STRING(#sym));
+#define __strong_alias(newsym, sym) \
+ __typeof__ (sym) newsym __attribute__ ((alias (#sym)));
/*
* UNROLLED TRANSFORM LOOP NOTE:
@@ -820,9 +817,9 @@ SHA384Init(SHA2_CTX *context)
context->bitcount[0] = context->bitcount[1] = 0;
}
-__weak_alias(SHA384Transform, SHA512Transform);
-__weak_alias(SHA384Update, SHA512Update);
-__weak_alias(SHA384Pad, SHA512Pad);
+__strong_alias(SHA384Transform, SHA512Transform)
+__strong_alias(SHA384Update, SHA512Update)
+__strong_alias(SHA384Pad, SHA512Pad)
void
SHA384Final(uint8_t digest[SHA384_DIGEST_LENGTH], SHA2_CTX *context)
--
2.21.0
More information about the libbsd
mailing list