Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.85
 
1.86
 
MAIN:gmcgarry:20080808124857
 
local.c
_>7575         }
 7676 
 7777         s = permalloc(sizeof(struct stub));
<>78 -        s->name = newstring(name, strlen(name));
  78+        s->name = permalloc(strlen(name) + 1);
  79+        strcpy(s->name, name);
7980         DLIST_INSERT_BEFORE(list, s, link);
 8081 }
 8182 
 8283 #endif
 8384 
 8485 #define IALLOC(sz)      (isinlining ? permalloc(sz) : tmpalloc(sz))
<> 86+
  87+#ifndef os_win32
8588 /*
 8689  * Make a symtab entry for PIC use.
 8790  */
     
 !
99102         sp->sflags = sp->slevel = 0;
 100103         return sp;
 101104 }
<> 105+#endif
102106 
 103107 int gotnr; /* tempnum for GOT register */
<> 108+int argstacksize;
  109+
104110 /*
 105111  * Create a reference for an extern variable.
 106112  */
 107113 static NODE *
 108114 picext(NODE *p)
 109115 {
<>110 -        NODE *q, *r;
 111 -        struct symtab *sp;
112116 
 113117 #if defined(ELFABI)
 114118 
<> 119+        NODE *q, *r;
  120+        struct symtab *sp;
  121+
115122         q = tempnode(gotnr, PTR|VOID, 0, MKSUE(VOID));
 116123         sp = picsymtab("", p->n_sp->soname, "@GOT");
 117124         r = xbcon(0, sp, INT);
 118125         q = buildtree(PLUS, q, r);
 119126         q = block(UMUL, q, 0, PTR|VOID, 0, MKSUE(VOID));
<> 127+        q = block(UMUL, q, 0, p->n_type, p->n_df, p->n_sue);
  128+        q->n_sp = p->n_sp; /* for init */
  129+        nfree(p);
  130+        return q;
120131 
 121132 #elif defined(MACHOABI)
 122133 
<> 134+        NODE *q, *r;
  135+        struct symtab *sp;
123136         char buf2[64];
 124137 
 125138         if (p->n_sp->sclass == EXTDEF) {
     
 !
136149 
 137150         if (p->n_sp->sclass != EXTDEF)
 138151                 q = block(UMUL, q, 0, PTR+VOID, 0, MKSUE(VOID));
<>139 -
 140 -#endif
 141 -
142152         q = block(UMUL, q, 0, p->n_type, p->n_df, p->n_sue);
 143153         q->n_sp = p->n_sp; /* for init */
 144154         nfree(p);
 145155         return q;
<> 156+
  157+#elif defined(PECOFFABI)
  158+
  159+        return p;
  160+
  161+#endif
  162+
146163 }
 147164 
 148165 /*
     
 !
151168 static NODE *
 152169 picstatic(NODE *p)
 153170 {
<>154 -        NODE *q, *r;
 155 -        struct symtab *sp;
156171 
 157172 #if defined(ELFABI)
 158173 
<> 174+        NODE *q, *r;
  175+        struct symtab *sp;
  176+
159177         q = tempnode(gotnr, PTR|VOID, 0, MKSUE(VOID));
 160178         if (p->n_sp->slevel > 0 || p->n_sp->sclass == ILABEL) {
 161179                 char buf[32];
     
 !
170188         q = block(UMUL, q, 0, p->n_type, p->n_df, p->n_sue);
 171189         q->n_sp = p->n_sp; /* for init */
 172190         nfree(p);
<> 191+        return q;
173192 
 174193 #elif defined(MACHOABI)
 175194 
<> 195+        NODE *q, *r;
  196+        struct symtab *sp;
176197         char buf2[64];
 177198 
 178199         snprintf(buf2, 64, "-L%s$pb", cftnsp->soname);
     
 !
193214         q = block(UMUL, q, 0, p->n_type, p->n_df, p->n_sue);
 194215         q->n_sp = p->n_sp;
 195216         nfree(p);
<> 217+        return q;
196218 
<> 219+#elif defined(PECOFFABI)
  220+
  221+        return p;
  222+
197223 #endif
 198224 
<>199 -        return q;
200225 }
 201226 
 202227 #ifdef TLS
     
 !
389414         case USTCALL:
 390415                 if (kflag == 0)
 391416                         break;
<> 417+#if defined(ELFABI)
392418                 /* Change to CALL node with ebx as argument */
 393419                 l = block(REG, NIL, NIL, INT, 0, MKSUE(INT));
 394420                 l->n_rval = EBX;
 395421                 p->n_right = buildtree(ASSIGN, l,
 396422                     tempnode(gotnr, INT, 0, MKSUE(INT)));
 397423                 p->n_op -= (UCALL-CALL);
<> 424+#endif
398425                 break;
 399426 
 400427         case CBRANCH:
     
 !
624651 static void
 625652 fixnames(NODE *p)
 626653 {
<> 654+#if !defined(PECOFFABI)
  655+
627656         struct symtab *sp;
 628657         struct suedef *sue;
 629658         NODE *q;
     
 !
682711                 p->n_left = q;
 683712                 q->n_sue = sue;
 684713         }
<> 714+#endif
685715 }
 686716 
 687717 void
     
 !
807837 {
 808838         char *s, *str = sp->sname;
 809839 
<>810 -#if defined(ELFABI)
  840+#if defined(ELFABI) || defined(PECOFFABI)
811841 
 812842         defloc(sp);
 813843 
     
 !
927957 {
 928958         union { float f; double d; long double l; int i[3]; } u;
 929959         struct symtab *q;
<> 960+#if defined(ELFABI) || defined(MACHOABI)
930961         char *c;
<> 962+#endif
931963         TWORD t;
 932964         int i;
 933965 
     
 !
952984                 if ((c = strstr(q->soname, "@GOT")) != NULL)
 953985                         *c = 0; /* ignore GOT ref here */
 954986 
<>955 -#else
  987+#elif defined(MACHOABI)
956988 
 957989                 if  ((c = strstr(q->soname, "$non_lazy_ptr")) != NULL) {
 958990                         q->soname++;    /* skip "L" */
     
 !
11111143 static char *
 11121144 section2string(char *name, int len)
 11131145 {
<> 1146+#if defined(ELFABI)
11141147         char *s;
 11151148         int n;
 11161149 
<>1117 -#if defined(ELFABI)
11181150         if (strncmp(name, "link_set", 8) == 0) {
 11191151                 const char *postfix = ",\"aw\",@progbits";
 11201152                 n = len + strlen(postfix) + 1;
     
 !
11321164 #ifdef TLS
 11331165 static int gottls;
 11341166 #endif
<> 1167+#ifdef os_win32
  1168+static int stdcall;
  1169+static int dllindirect;
  1170+#endif
  1171+static char *alias;
11351172 static int constructor;
 11361173 static int destructor;
 11371174 
     
 !
11471184                 return 1;
 11481185         }
 11491186 #endif
<> 1187+#ifdef os_win32
  1188+        if (strcmp(ary[1], "stdcall") == 0) {
  1189+                stdcall = 1;
  1190+                return 1;
  1191+        }
  1192+        if (strcmp(ary[1], "cdecl") == 0) {
  1193+                stdcall = 0;
  1194+                return 1;
  1195+        }
  1196+        if (strcmp(ary[1], "fastcall") == 0) {
  1197+                stdcall = 2;
  1198+                return 1;
  1199+        }
  1200+        if (strcmp(ary[1], "dllimport") == 0) {
  1201+                dllindirect = 1;
  1202+                return 1;
  1203+        }
  1204+        if (strcmp(ary[1], "dllexport") == 0) {
  1205+                dllindirect = 1;
  1206+                return 1;
  1207+        }
  1208+#endif
11501209         if (strcmp(ary[1], "constructor") == 0 || strcmp(ary[1], "init") == 0) {
 11511210                 constructor = 1;
 11521211                 return 1;
     
 !
11591218                 nextsect = section2string(ary[2], strlen(ary[2]));
 11601219                 return 1;
 11611220         }
<> 1221+        if (strcmp(ary[1], "alias") == 0 && ary[2] != NULL) {
  1222+                alias = tmpstrdup(ary[2]);
  1223+                return 1;
  1224+        }
11621225 
 11631226         return 0;
 11641227 }
     
 !
11751238                 sp->sflags |= STLS;
 11761239         gottls = 0;
 11771240 #endif
<> 1241+        if (alias != NULL && (sp->sclass != PARAM)) {
  1242+                printf("\t.globl %s\n", exname(sp->soname));
  1243+                printf("%s = ", exname(sp->soname));
  1244+                printf("%s\n", exname(alias));
  1245+                alias = NULL;
  1246+        }
11781247         if ((constructor || destructor) && (sp->sclass != PARAM)) {
 11791248 #if defined(ELFABI)
 11801249                 printf("\t.section .%ctors,\"aw\",@progbits\n",
     
 !
11961265                 printf("\t.long %s\n", exname(sp->sname));
 11971266                 constructor = destructor = 0;
 11981267         }
<> 1268+#ifdef os_win32
  1269+        if (stdcall && (sp->sclass != PARAM)) {
  1270+                sp->sflags |= SSTDCALL;
  1271+                stdcall = 0;
  1272+        }
  1273+        if (dllindirect && (sp->sclass != PARAM)) {
  1274+                sp->sflags |= SDLLINDIRECT;
  1275+                dllindirect = 0;
  1276+        }
  1277+#endif
11991278 }
 12001279 
 12011280 NODE *
     
 !
12501329         uerror("bad argument to __builtin_frame_address");
 12511330         return bcon(0);
 12521331 }
<_ 1332+
  1333+#ifdef os_win32
  1334+/*
  1335+ *  Postfix external functions with the arguments size.
  1336+ */
  1337+static void
  1338+mangle(NODE *p)
  1339+{
  1340+        NODE *l, *r;
  1341+        TWORD t;
  1342+        int size = 0;
  1343+        char buf[64];
  1344+
  1345+        if ((p->n_op == NAME || p->n_op == ICON) &&
  1346+            p->n_sp && (p->n_sp->sflags & SDLLINDIRECT) && p->n_name) {
  1347+                snprintf(buf, 64, "__imp_%s", p->n_name);
  1348+                p->n_name = IALLOC(strlen(buf) + 1);
  1349+                strcpy(p->n_name, buf);
  1350+                return;
  1351+        }
  1352+
  1353+        if (p->n_op != CALL && p->n_op != STCALL &&
  1354+            p->n_op != UCALL && p->n_op != USTCALL)
  1355+                return;
  1356+
  1357+        l = p->n_left;
  1358+        if (l->n_op == ADDROF)
  1359+                l = l->n_left;
  1360+        if (l->n_sp == NULL)
  1361+                return;
  1362+        if (l->n_sp->sflags & SSTDCALL) {
  1363+                if (strchr(l->n_name, '@') == NULL) {
  1364+                        if (p->n_op == CALL || p->n_op == STCALL) {
  1365+                                for (r = p->n_right;    
  1366+                                    r->n_op == CM; r = r->n_left) {
  1367+                                        t = r->n_type;
  1368+                                        if (t == STRTY || t == UNIONTY)
  1369+                                                size += r->n_sue->suesize;
  1370+                                        else
  1371+                                                size += szty(t) * SZINT / SZCHAR;
  1372+                                }
  1373+                                t = r->n_type;
  1374+                                if (t == STRTY || t == UNIONTY)
  1375+                                        size += r->n_sue->suesize;
  1376+                                else
  1377+                                        size += szty(t) * SZINT / SZCHAR;
  1378+                        }
  1379+                        snprintf(buf, 64, "%s@%d", l->n_name, size);
  1380+                        l->n_name = IALLOC(strlen(buf) + 1);
  1381+                        strcpy(l->n_name, buf);
  1382+                }
  1383+
  1384+                l->n_flags = FSTDCALL;
  1385+        }
  1386+}
  1387+#endif
  1388+
  1389+void
  1390+pass1_lastchance(struct interpass *ip)
  1391+{
  1392+#ifdef os_win32
  1393+        if (ip->type == IP_EPILOG) {
  1394+                struct interpass_prolog *ipp = (struct interpass_prolog *)ip;
  1395+                ipp->ipp_argstacksize = argstacksize;
  1396+        }
  1397+
  1398+        if (ip->type == IP_NODE)
  1399+                walkf(ip->ip_node, mangle);
  1400+#endif
  1401+}
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-11-01 04:49 +0100