From c1aaa2b5f9bec573a5aea433a955e0b183927f4f Mon Sep 17 00:00:00 2001 From: Camilo Viecco Date: Mon, 18 Mar 2013 19:49:38 -0700 Subject: [PATCH] Bug 832942: work around an ARMv6 code generation bug in gcc 4.6. r=wtc. --HG-- extra : source : f37f4a6ba90b8add8792fa15812ba25d176b96b7 --- security/nss/lib/softoken/pkcs11.c | 13 +++++++++++- security/patches/README | 1 + security/patches/bug-832942.patch | 33 ++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 security/patches/bug-832942.patch diff --git a/security/nss/lib/softoken/pkcs11.c b/security/nss/lib/softoken/pkcs11.c index f91d15a3d87..f7205889c97 100644 --- a/security/nss/lib/softoken/pkcs11.c +++ b/security/nss/lib/softoken/pkcs11.c @@ -1894,7 +1894,18 @@ sftk_mkPrivKey(SFTKObject *object, CK_KEY_TYPE key_type, CK_RV *crvp) } rv = DER_SetUInteger(privKey->arena, &privKey->u.ec.version, NSSLOWKEY_EC_PRIVATE_KEY_VERSION); - if (rv != SECSuccess) crv = CKR_HOST_MEMORY; + if (rv != SECSuccess) { + crv = CKR_HOST_MEMORY; + /* The following ifdef is needed for Linux arm distros and + * Android as gcc 4.6 has a bug when targeting arm (but not + * thumb). The bug has been fixed in gcc 4.7. + * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56561 + */ +#if defined (__arm__) && !defined(__thumb__) && defined (__GNUC__) + *crvp = CKR_HOST_MEMORY; + break; +#endif + } break; #endif /* NSS_ENABLE_ECC */ diff --git a/security/patches/README b/security/patches/README index bbc519c902c..0e5c108a551 100644 --- a/security/patches/README +++ b/security/patches/README @@ -4,3 +4,4 @@ on top of the NSS release. bug-834091.patch: Add SEC_PKCS7VerifyDetachedSignatureAtTime, which is needed for B2G 1.0. This patch is probably going to be modified before it can land in upstream NSS. +bug-832942.patch: work around an ARMv6 code generation bug in gcc 4.6. \ No newline at end of file diff --git a/security/patches/bug-832942.patch b/security/patches/bug-832942.patch new file mode 100644 index 00000000000..d0b5bf1aa36 --- /dev/null +++ b/security/patches/bug-832942.patch @@ -0,0 +1,33 @@ +diff --git a/lib/softoken/pkcs11.c b/lib/softoken/pkcs11.c +--- a/lib/softoken/pkcs11.c ++++ b/lib/softoken/pkcs11.c +@@ -1889,17 +1889,28 @@ sftk_mkPrivKey(SFTKObject *object, CK_KE + crv = sftk_Attribute2SSecItem(arena, &privKey->u.ec.publicValue, + object, CKA_NETSCAPE_DB); + if (crv != CKR_OK) break; + /* privKey was zero'd so public value is already set to NULL, 0 + * if we don't set it explicitly */ + } + rv = DER_SetUInteger(privKey->arena, &privKey->u.ec.version, + NSSLOWKEY_EC_PRIVATE_KEY_VERSION); +- if (rv != SECSuccess) crv = CKR_HOST_MEMORY; ++ if (rv != SECSuccess) { ++ crv = CKR_HOST_MEMORY; ++ /* The following ifdef is needed for Linux arm distros and ++ * Android as gcc 4.6 has a bug when targeting arm (but not ++ * thumb). The bug has been fixed in gcc 4.7. ++ * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56561 ++ */ ++#if defined (__arm__) && !defined(__thumb__) && defined (__GNUC__) ++ *crvp = CKR_HOST_MEMORY; ++ break; ++#endif ++ } + break; + #endif /* NSS_ENABLE_ECC */ + + default: + crv = CKR_KEY_TYPE_INCONSISTENT; + break; + } + if (crv == CKR_OK && itemTemplateCount != 0) {