Skip to content

Commit

Permalink
src/plugins/SHA2Plugin/SHA2Plugin.c as per CryptographyPlugins-eem.24
Browse files Browse the repository at this point in the history
Fix crashes in primitiveSHA256ProcessBufferUpdatingHash when compiling with
Clang on x86_64 due to SSE instructions which require 128-bit stack alignment.
  • Loading branch information
eliotmiranda committed Dec 11, 2021
1 parent 6f2914e commit 97b4903
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions src/plugins/SHA2Plugin/SHA2Plugin.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* Automatically generated by
VMPluginCodeGenerator VMMaker.oscog-eem.3090 uuid: 3e2b8343-01bb-4169-ba4c-aecf82b4dcfc
VMPluginCodeGenerator VMMaker.oscog-eem.3119 uuid: c0b40a55-50ca-4dd9-8b6f-d355a6dd5e1f
from
SHA2Plugin * CryptographyPlugins-eem.23 uuid: bc8a8db4-2e4d-458f-bac9-f007458fdd4d
SHA2Plugin CryptographyPlugins-eem.24 uuid: 7463960c-3baf-413e-b010-ec19e90522b3
*/
static char __buildInfo[] = "SHA2Plugin * CryptographyPlugins-eem.23 uuid: bc8a8db4-2e4d-458f-bac9-f007458fdd4d " __DATE__ ;
static char __buildInfo[] = "SHA2Plugin CryptographyPlugins-eem.24 uuid: 7463960c-3baf-413e-b010-ec19e90522b3 " __DATE__ ;


#include "config.h"
Expand Down Expand Up @@ -65,6 +65,7 @@ static sqInt (*methodReturnReceiver)(void);
static sqInt (*primitiveFailFor)(sqInt reasonCode);
static sqInt (*stSizeOf)(sqInt oop);
static sqInt (*stackObjectValue)(sqInt offset);
static sqInt (*stackValue)(sqInt offset);
#else /* !defined(SQUEAK_BUILTIN_PLUGIN) */
extern sqInt byteSizeOf(sqInt oop);
extern void * firstIndexableField(sqInt oop);
Expand All @@ -77,10 +78,11 @@ extern sqInt methodReturnReceiver(void);
extern sqInt primitiveFailFor(sqInt reasonCode);
extern sqInt stSizeOf(sqInt oop);
extern sqInt stackObjectValue(sqInt offset);
extern sqInt stackValue(sqInt offset);
extern
#endif
struct VirtualMachine* interpreterProxy;
static const char *moduleName = "SHA2Plugin * CryptographyPlugins-eem.23 " INT_EXT;
static const char *moduleName = "SHA2Plugin CryptographyPlugins-eem.24 " INT_EXT;
static const unsigned int sha256k[] = {
/*0*/ 1116352408, 1899447441, 3049323471U, 3921009573U, 961987163, 0x59F111F1, 2453635748U,
/*7*/ 2870763221U, 0xD807AA98U, 310598401, 607225278, 1426881987, 1925078388, 2162078206U,
Expand Down Expand Up @@ -264,14 +266,12 @@ primitiveSHA256ProcessBufferUpdatingHash(void)
if (!((methodArgumentCount()) == 2)) {
return primitiveFailFor(PrimErrBadNumArgs);
}
bufferOop = stackObjectValue(1);
hashOop = stackValue(0);
bufferOop = stackValue(1);
if (!((isBytes(bufferOop))
&& ((stSizeOf(bufferOop)) == 64))) {
return primitiveFailFor(PrimErrBadArgument);
}
hashOop = stackObjectValue(0);
if (!((isWords(hashOop))
&& ((stSizeOf(hashOop)) == 8))) {
&& (((byteSizeOf(bufferOop)) == 64)
&& ((isWords(hashOop))
&& ((stSizeOf(hashOop)) == 8))))) {
return primitiveFailFor(PrimErrBadArgument);
}
buffer = firstIndexableField(bufferOop);
Expand Down Expand Up @@ -462,6 +462,7 @@ setInterpreter(struct VirtualMachine *anInterpreter)
primitiveFailFor = interpreterProxy->primitiveFailFor;
stSizeOf = interpreterProxy->stSizeOf;
stackObjectValue = interpreterProxy->stackObjectValue;
stackValue = interpreterProxy->stackValue;
#endif /* !defined(SQUEAK_BUILTIN_PLUGIN) */
}
return ok;
Expand All @@ -476,7 +477,7 @@ void* SHA2Plugin_exports[][3] = {
{(void*)_m, "primitiveCopyDoubleWordsIntoBytesBigEndian\000\001\001", (void*)primitiveCopyDoubleWordsIntoBytesBigEndian},
{(void*)_m, "primitiveCopyWordsIntoBytesBigEndian\000\001\001", (void*)primitiveCopyWordsIntoBytesBigEndian},
{(void*)_m, "primitiveIsPluginAvailable\000\377\001", (void*)primitiveIsPluginAvailable},
{(void*)_m, "primitiveSHA256ProcessBufferUpdatingHash\000\001\001", (void*)primitiveSHA256ProcessBufferUpdatingHash},
{(void*)_m, "primitiveSHA256ProcessBufferUpdatingHash\000\001\003", (void*)primitiveSHA256ProcessBufferUpdatingHash},
{(void*)_m, "primitiveSHA512ProcessBufferUpdatingHash\000\001\001", (void*)primitiveSHA512ProcessBufferUpdatingHash},
{(void*)_m, "setInterpreter", (void*)setInterpreter},
{NULL, NULL, NULL}
Expand All @@ -488,7 +489,7 @@ void* SHA2Plugin_exports[][3] = {
EXPORT(signed short) primitiveCopyDoubleWordsIntoBytesBigEndianMetadata = 0x101;
EXPORT(signed short) primitiveCopyWordsIntoBytesBigEndianMetadata = 0x101;
EXPORT(signed short) primitiveIsPluginAvailableMetadata = -255;
EXPORT(signed short) primitiveSHA256ProcessBufferUpdatingHashMetadata = 0x101;
EXPORT(signed short) primitiveSHA256ProcessBufferUpdatingHashMetadata = 259;
EXPORT(signed short) primitiveSHA512ProcessBufferUpdatingHashMetadata = 0x101;
#endif // SPURVM

Expand Down

0 comments on commit 97b4903

Please sign in to comment.