Quick Search:

Mode

Context

Displaying 3 lines of context. None | Less | More | Full

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.72
 
1.73
 
MAIN:ragge:20080210100824
 
local.c
_>123123         return q;
 124124 }
 125125 
<> 126+#ifdef TLS
  127+/*
  128+ * Create a reference for a TLS variable.
  129+ */
  130+static NODE *
  131+tlspic(NODE *p)
  132+{
  133+        NODE *q, *r;
  134+        struct symtab *sp;
  135+
  136+        /*
  137+         * creates:
  138+         *   leal var@TLSGD(%ebx),%eax
  139+         *   call ___tls_get_addr@PLT
  140+         */
  141+
  142+        /* calc address of var@TLSGD */
  143+        q = tempnode(gotnr, PTR|VOID, 0, MKSUE(VOID));
  144+        sp = picsymtab(p->n_sp->soname, "@TLSGD");
  145+        r = xbcon(0, sp, INT);
  146+        q = buildtree(PLUS, q, r);
  147+
  148+        /* assign to %eax */
  149+        r = block(REG, NIL, NIL, PTR|VOID, 0, MKSUE(VOID));
  150+        r->n_rval = EAX;
  151+        q = buildtree(ASSIGN, r, q);
  152+
  153+        /* call ___tls_get_addr */
  154+        spname = lookup("___tls_get_addr@PLT", 0);
  155+        spname->stype = EXTERN|INT|FTN;
  156+        r = buildtree(NAME, NIL, NIL);
  157+        r = buildtree(ADDROF, r, NIL);
  158+        r = block(UCALL, r, NIL, INT, 0, MKSUE(INT));
  159+
  160+        /* fusion both parts together */
  161+        q = buildtree(COMOP, q, r);
  162+        q = block(UMUL, q, 0, p->n_type, p->n_df, p->n_sue);
  163+        q->n_sp = p->n_sp; /* for init */
  164+
  165+        nfree(p);
  166+        return q;
  167+}
  168+
  169+static NODE *
  170+tlsnonpic(NODE *p)
  171+{
  172+        NODE *q, *r;
  173+        struct symtab *sp;
  174+        int ext = p->n_sp->sclass;
  175+
  176+        sp = picsymtab(p->n_sp->soname, ext == EXTERN ? "@INDNTPOFF" : "@NTPOFF");
  177+        q = xbcon(0, sp, INT);
  178+        if (ext == EXTERN)
  179+                q = block(UMUL, q, NIL, PTR|VOID, 0, MKSUE(VOID));
  180+
  181+        spname = lookup("%gs:0", 0);
  182+        spname->stype = EXTERN|INT;
  183+        r = buildtree(NAME, NIL, NIL);
  184+
  185+        q = buildtree(PLUS, q, r);
  186+        q = block(UMUL, q, 0, p->n_type, p->n_df, p->n_sue);
  187+        q->n_sp = p->n_sp; /* for init */
  188+
  189+        nfree(p);
  190+        return q;
  191+}
  192+
  193+static NODE *
  194+tlsref(NODE *p)
  195+{
  196+        if (kflag)
  197+                return (tlspic(p));
  198+        else
  199+                return (tlsnonpic(p));
  200+}
  201+#endif
  202+
126203 /* clocal() is called to do local transformations on
 127204  * an expression tree preparitory to its being
 128205  * written out in intermediate code.
     
 !
172249                                 break;
 173250                         /* FALLTHROUGH */
 174251                 case STATIC:
<> 252+#ifdef TLS
  253+                        if (q->sflags & STLS) {
  254+                                p = tlsref(p);
  255+                                break;
  256+                        }
  257+#endif
175258                         if (kflag == 0) {
 176259                                 if (q->slevel == 0)
 177260                                         break;
     
 !
188271 
 189272                 case EXTERN:
 190273                 case EXTDEF:
<> 274+#ifdef TLS
  275+                        if (q->sflags & STLS) {
  276+                                p = tlsref(p);
  277+                                break;
  278+                        }
  279+#endif
191280                         if (kflag == 0)
 192281                                 break;
 193282                         if (blevel > 0)
     
 !
854943 {
 855944         int off;
 856945 
<> 946+#ifdef TLS
  947+        if (sp->sflags & STLS) {
  948+                if (sp->sclass == EXTERN)
  949+                        sp->sclass = EXTDEF;
  950+                simpleinit(sp, bcon(0));
  951+                return;
  952+        }
  953+#endif
  954+
857955         off = tsize(sp->stype, sp->sdf, sp->ssue);
 858956         off = (off+(SZCHAR-1))/SZCHAR;
 859957         printf("        .%scomm ", sp->sclass == STATIC ? "l" : "");
     
 !
864962 }
 865963 
 866964 char *nextsect;
<> 965+#ifdef TLS
  966+static int gottls;
  967+#endif
867968 
<>868 -#define SSECTION        010000
 869 -
870969 /* * Give target the opportunity of handling pragmas.
 871970  */
 872971 int
 873972 mypragma(char **ary)
 874973 {
<> 974+#ifdef TLS
  975+        if (strcmp(ary[1], "tls") == 0 && ary[2] == NULL) {
  976+                gottls = 1;
  977+                return 1;
  978+        }
  979+#endif
875980         if (strcmp(ary[1], "section") || ary[2] == NULL)
 876981                 return 0;
 877982         nextsect = newstring(ary[2], strlen(ary[2]));
     
 !
884989 void
 885990 fixdef(struct symtab *sp)
 886991 {
<> 992+#ifdef TLS
  993+        /* may have sanity checks here */
  994+        if (gottls)
  995+                sp->sflags |= STLS;
  996+        gottls = 0;
  997+#endif
<_887998 }
FishEye: Open Source License registered to PCC.
Your maintenance has expired. You can renew your license at http://www.atlassian.com/fisheye/renew
Atlassian FishEye, CVS analysis. (Version:1.6.3 Build:build-336 2008-11-04) - Administration - Page generated 2014-09-22 00:12 +0200