Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.26
 
1.27
 
MAIN:ragge:20101117195424
 
local.c
_>111111         return q;
 112112 }
 113113 
<> 114+#ifdef notdef
114115 /*
 115116  * Create a reference for a static variable.
 116117  */
     
 !
130131         p->n_sp = sp;
 131132         return p;
 132133 }
<> 134+#endif
133135 
<>134 -#ifdef TLS
  136+static NODE *
  137+cmop(NODE *l, NODE *r)
  138+{
  139+        return block(CM, l, r, INT, 0, MKAP(INT));
  140+}
  141+
  142+static NODE *
  143+mkx(char *s, NODE *p)
  144+{
  145+        p = block(XARG, p, NIL, INT, 0, MKAP(INT));
  146+        p->n_name = s;
  147+        return p;
  148+}
  149+
  150+static char *
  151+mk3str(char *s1, char *s2, char *s3)
  152+{
  153+        int len = strlen(s1) + strlen(s2) + strlen(s3) + 1;
  154+        char *sd;
  155+
  156+        sd = tmpalloc(len);
  157+        strlcpy(sd, s1, len);
  158+        strlcat(sd, s2, len);
  159+        strlcat(sd, s3, len);
  160+        return sd;
  161+}
  162+
135163 /*
 136164  * Create a reference for a TLS variable.
<> 165+ * This is the "General dynamic" version.
137166  */
 138167 static NODE *
 139168 tlspic(NODE *p)
 140169 {
<>141 -        NODE *q, *r;
 142 -        struct symtab *sp, *sp2;
  170+        NODE *q, *r, *s;
  171+        char *s1, *s2;
143172 
 144173         /*
<>145 -         * creates:
 146 -         *   leal var@TLSGD(%ebx),%eax
 147 -         *   call ___tls_get_addr@PLT
  174+         * .byte   0x66
  175+         * leaq x@TLSGD(%rip),%rdi
  176+         * .word   0x6666
  177+         * rex64
  178+         * call __tls_get_addr@PLT
148179          */
 149180 
<>150 -        /* calc address of var@TLSGD */
 151 -        q = tempnode(gotnr, PTR|VOID, 0, MKAP(VOID));
 152 -        sp = picsymtab("", p->n_sp->soname, "@TLSGD");
 153 -        r = xbcon(0, sp, INT);
 154 -        q = buildtree(PLUS, q, r);
  181+        /* Need the .byte stuff around.  Why? */
  182+        /* Use inline assembler */
  183+        q = mkx("%rdx", bcon(0));
  184+        q = cmop(q, mkx("%rcx", bcon(0)));
  185+        q = cmop(q, mkx("%rsi", bcon(0)));
  186+        q = cmop(q, mkx("%rdi", bcon(0)));
  187+        q = cmop(q, mkx("%r8", bcon(0)));
  188+        q = cmop(q, mkx("%r9", bcon(0)));
  189+        q = cmop(q, mkx("%r10", bcon(0)));
  190+        q = cmop(q, mkx("%r11", bcon(0)));
155191 
<>156 -        /* assign to %eax */
 157 -        r = block(REG, NIL, NIL, PTR|VOID, 0, MKAP(VOID));
 158 -        r->n_rval = EAX;
 159 -        q = buildtree(ASSIGN, r, q);
  192+        s = ccopy(r = tempnode(0, INCREF(p->n_type), p->n_df, p->n_ap));
  193+        r = mkx("=a", r);
  194+        r = block(XASM, r, q, INT, 0, MKAP(INT));
160195 
<>161 -        /* call ___tls_get_addr */
 162 -        sp2 = lookup("___tls_get_addr@PLT", 0);
 163 -        sp2->stype = EXTERN|INT|FTN;
 164 -        r = nametree(sp2);
 165 -        r = buildtree(ADDROF, r, NIL);
 166 -        r = block(UCALL, r, NIL, INT, 0, MKAP(INT));
  196+        /* Create the magic string */
  197+        s1 = ".byte 0x66\n\tleaq ";
  198+        s2 = "@TLSGD(%%rip),%%rdi\n"
  199+            "\t.word 0x6666\n\trex64\n\tcall __tls_get_addr@PLT";
  200+        if (p->n_sp->soname == NULL)
  201+                p->n_sp->soname = p->n_sp->sname;
  202+        r->n_name = mk3str(s1, p->n_sp->soname, s2);
167203 
<>168 -        /* fusion both parts together */
 169 -        q = buildtree(COMOP, q, r);
 170 -        q = block(UMUL, q, 0, p->n_type, p->n_df, p->n_ap);
 171 -        q->n_sp = p->n_sp; /* for init */
 172 -
 173 -        nfree(p);
 174 -        return q;
  204+        r = block(COMOP, r, s, INCREF(p->n_type), p->n_df, p->n_ap);
  205+        r = buildtree(UMUL, r, NIL);
  206+        tfree(p);
  207+        return r;
175208 }
 176209 
<> 210+/*
  211+ * The "initial exec" tls model.
  212+ */
177213 static NODE *
<>178 -tlsnonpic(NODE *p)
  214+tlsinitialexec(NODE *p)
179215 {
<>180 -        NODE *q, *r;
 181 -        struct symtab *sp, *sp2;
 182 -        int ext = p->n_sp->sclass;
  216+        NODE *q, *r, *s;
  217+        char *s1, *s2;
183218 
<>184 -        sp = picsymtab("", p->n_sp->soname,
 185 -            ext == EXTERN ? "@INDNTPOFF" : "@NTPOFF");
 186 -        q = xbcon(0, sp, INT);
 187 -        if (ext == EXTERN)
 188 -                q = block(UMUL, q, NIL, PTR|VOID, 0, MKAP(VOID));
  219+        /*
  220+         * movq %fs:0,%rax
  221+         * addq x@GOTTPOFF(%rip),%rax
  222+         */
189223 
<>190 -        sp2 = lookup("%gs:0", 0);
 191 -        sp2->stype = EXTERN|INT;
 192 -        r = nametree(sp2);
  224+        q = bcon(0);
  225+        q->n_type = STRTY;
193226 
<>194 -        q = buildtree(PLUS, q, r);
 195 -        q = block(UMUL, q, 0, p->n_type, p->n_df, p->n_ap);
 196 -        q->n_sp = p->n_sp; /* for init */
  227+        s = ccopy(r = tempnode(0, INCREF(p->n_type), p->n_df, p->n_ap));
  228+        r = mkx("=r", r);
  229+        r = block(XASM, r, q, INT, 0, MKAP(INT));
197230 
<>198 -        nfree(p);
 199 -        return q;
  231+        s1 = "movq %%fs:0,%0\n\taddq ";
  232+        s2 = "@GOTTPOFF(%%rip),%0";
  233+        if (p->n_sp->soname == NULL)
  234+                p->n_sp->soname = p->n_sp->sname;
  235+        r->n_name = mk3str(s1, p->n_sp->soname, s2);
  236+
  237+        r = block(COMOP, r, s, INCREF(p->n_type), p->n_df, p->n_ap);
  238+        r = buildtree(UMUL, r, NIL);
  239+        tfree(p);
  240+        return r;
200241 }
 201242 
 202243 static NODE *
 203244 tlsref(NODE *p)
 204245 {
<>205 -        if (kflag)
 206 -                return (tlspic(p));
 207 -        else
 208 -                return (tlsnonpic(p));
  246+        struct symtab *sp = p->n_sp;
  247+        struct attr *ga;
  248+        char *c;
  249+
  250+        if ((ga = attr_find(sp->sap, GCC_ATYP_TLSMODEL)) != NULL) {
  251+                c = ga->sarg(0);
  252+                if (strcmp(c, "initial-exec") == 0)
  253+                        return tlsinitialexec(p);
  254+                else if (strcmp(c, "global-dynamic") == 0)
  255+                        ;
  256+                else
  257+                        werror("unsupported tls model '%s'", c);
  258+        }
  259+        return tlspic(p);
209260 }
<>210 -#endif
211261 
 212262 static NODE *
 213263 stkblk(TWORD t)
     
 !
308358 
 309359                 case EXTERN:
 310360                 case EXTDEF:
<>311 -#ifdef TLS
312361                         if (q->sflags & STLS) {
 313362                                 p = tlsref(p);
 314363                                 break;
 315364                         }
<>316 -#endif
317365                         if (kflag == 0)
 318366                                 break;
 319367                         if (blevel > 0)
     
 !
322370                 }
 323371                 break;
 324372 
<> 373+#if 0
325374         case ADDROF:
 326375                 if (kflag == 0 || blevel == 0)
 327376                         break;
     
 !
339388                 p = p->n_left;
 340389                 nfree(l);
 341390                 break;
<> 391+#endif
342392 
 343393         case UCALL:
 344394         case USTCALL:
     
 !
935985 {
 936986 }
 937987 
<> 988+int tbss;
  989+
938990 /* make a common declaration for id, if reasonable */
 939991 void
 940992 defzero(struct symtab *sp)
 941993 {
 942994         int off;
 943995         char *name;
 944996 
<>945 -#ifdef TLS
946997         if (sp->sflags & STLS) {
 947998                 if (sp->sclass == EXTERN)
 948999                         sp->sclass = EXTDEF;
<> 1000+                tbss = 1;
9491001                 simpleinit(sp, bcon(0));
 9501002                 return;
 9511003         }
<>952 -#endif
9531004 
 9541005         if ((name = sp->soname) == NULL)
 9551006                 name = exname(sp->sname);
     
 !
9891040 }
 9901041 
 9911042 char *nextsect;
<>992 -#ifdef TLS
9931043 static int gottls;
<>994 -#endif
9951044 static char *alias;
 9961045 static int constructor;
 9971046 static int destructor;
     
 !
10021051 int
 10031052 mypragma(char **ary)
 10041053 {
<>1005 -#ifdef TLS
10061054         if (strcmp(ary[1], "tls") == 0 && ary[2] == NULL) {
 10071055                 gottls = 1;
 10081056                 return 1;
 10091057         }
<>1010 -#endif
10111058         if (strcmp(ary[1], "constructor") == 0 || strcmp(ary[1], "init") == 0) {
 10121059                 constructor = 1;
 10131060                 return 1;
     
 !
10361083 {
 10371084         struct attr *ga;
 10381085 
<>1039 -#ifdef TLS
10401086         /* may have sanity checks here */
 10411087         if (gottls)
 10421088                 sp->sflags |= STLS;
 10431089         gottls = 0;
<>1044 -#endif
  1090+
<_10451091 #ifdef HAVE_WEAKREF
 10461092         /* not many as'es have this directive */
 10471093         if ((ga = gcc_get_attr(sp->sap, GCC_ATYP_WEAKREF)) != NULL) {
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-08-23 13:27 +0200