]> Cypherpunks repositories - gostls13.git/commitdiff
liblink, runtime: make nacl/386 binaries valid.
authorRémy Oudompheng <oudomphe@phare.normalesup.org>
Fri, 14 Mar 2014 20:33:55 +0000 (21:33 +0100)
committerRémy Oudompheng <oudomphe@phare.normalesup.org>
Fri, 14 Mar 2014 20:33:55 +0000 (21:33 +0100)
They were rejected by NaCl due to AES instructions and
accesses to %gs:0x8, caused by wrong tlsoffset value.

LGTM=iant
R=rsc, dave, iant
CC=golang-codereviews
https://golang.org/cl/76050044

src/liblink/sym.c
src/pkg/runtime/alg.goc

index 0c7aae00a191db9e4e0ea54033943b370b41a3f9..3990f7200ef823db3267283ddb597b5f642ba1d2 100644 (file)
@@ -139,9 +139,18 @@ linknew(LinkArch *arch)
                 */
                ctxt->tlsoffset = -2*ctxt->arch->ptrsize;
                break;
-       
+
        case Hnacl:
-               ctxt->tlsoffset = 0;
+               switch(ctxt->arch->thechar) {
+               default:
+                       sysfatal("unknown thread-local storage offset for nacl/%s", ctxt->arch->name);
+               case '6':
+                       ctxt->tlsoffset = 0;
+                       break;
+               case '8':
+                       ctxt->tlsoffset = -8;
+                       break;
+               }
                break;
 
        case Hdarwin:
index 81eb1664a9800de5c42365083ef89f33e9edd8ec..9fb54cac3ff00fcbe0f01e7275c53468a79b0f7f 100644 (file)
@@ -21,7 +21,7 @@ runtime·memhash(uintptr *h, uintptr s, void *a)
 {
        byte *b;
        uintptr hash;
-       if(use_aeshash) {
+       if(!NaCl && use_aeshash) {
                runtime·aeshash(h, s, a);
                return;
        }
@@ -470,6 +470,9 @@ byte runtime·aeskeysched[HashRandomBytes];
 void
 runtime·hashinit(void)
 {
+        if(NaCl)
+                return;
+
        // Install aes hash algorithm if we have the instructions we need
        if((runtime·cpuid_ecx & (1 << 25)) != 0 &&  // aes (aesenc)
           (runtime·cpuid_ecx & (1 << 9)) != 0 &&   // sse3 (pshufb)