Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.82
 
1.83
 
MAIN:gmcgarry:20080630115156
 
local.c
_>5858         return 0;
 5959 }
 6060 
<> 61+#if defined(MACHOABI)
  62+
  63+/*
  64+ *  Keep track of PIC stubs.
  65+ */
  66+
  67+void
  68+addstub(struct stub *list, char *name)
  69+{
  70+        struct stub *s;
  71+
  72+        DLIST_FOREACH(s, list, link) {
  73+                if (strcmp(s->name, name) == 0)
  74+                        return;
  75+        }
  76+
  77+        s = permalloc(sizeof(struct stub));
  78+        s->name = newstring(name, strlen(name));
  79+        DLIST_INSERT_BEFORE(list, s, link);
  80+}
  81+
  82+#endif
  83+
6184 #define IALLOC(sz)      (isinlining ? permalloc(sz) : tmpalloc(sz))
 6285 /*
 6386  * Make a symtab entry for PIC use.
 6487  */
 6588 static struct symtab *
<>66 -picsymtab(char *s, char *s2)
  89+picsymtab(char *p, char *s, char *s2)
6790 {
 6891         struct symtab *sp = IALLOC(sizeof(struct symtab));
<>69 -        size_t len = strlen(s) + strlen(s2) + 1;
  92+        size_t len = strlen(p) + strlen(s) + strlen(s2) + 1;
7093         
 7194         sp->sname = sp->soname = IALLOC(len);
<>72 -        strlcpy(sp->soname, s, len);
  95+        strlcpy(sp->soname, p, len);
  96+        strlcat(sp->soname, s, len);
7397         strlcat(sp->soname, s2, len);
 7498         sp->sclass = EXTERN;
 7599         sp->sflags = sp->slevel = 0;
     
 !
86110         NODE *q, *r;
 87111         struct symtab *sp;
 88112 
<> 113+#if defined(ELFABI)
  114+
89115         q = tempnode(gotnr, PTR|VOID, 0, MKSUE(VOID));
<>90 -        sp = picsymtab(p->n_sp->soname, "@GOT");
  116+        sp = picsymtab("", p->n_sp->soname, "@GOT");
91117         r = xbcon(0, sp, INT);
 92118         q = buildtree(PLUS, q, r);
 93119         q = block(UMUL, q, 0, PTR|VOID, 0, MKSUE(VOID));
<> 120+
  121+#elif defined(MACHOABI)
  122+
  123+        char buf2[64];
  124+
  125+        if (p->n_sp->sclass == EXTDEF) {
  126+                snprintf(buf2, 64, "-L%s$pb", cftnsp->soname);
  127+                sp = picsymtab("", exname(p->n_sp->soname), buf2);
  128+        } else {
  129+                snprintf(buf2, 64, "$non_lazy_ptr-L%s$pb", cftnsp->soname);
  130+                sp = picsymtab("L", p->n_sp->soname, buf2);
  131+                addstub(&nlplist, p->n_sp->soname);
  132+        }
  133+        q = tempnode(gotnr, PTR+VOID, 0, MKSUE(VOID));
  134+        r = xbcon(0, sp, INT);
  135+        q = buildtree(PLUS, q, r);
  136+
  137+        if (p->n_sp->sclass != EXTDEF)
  138+                q = block(UMUL, q, 0, PTR+VOID, 0, MKSUE(VOID));
  139+
  140+#endif
  141+
94142         q = block(UMUL, q, 0, p->n_type, p->n_df, p->n_sue);
 95143         q->n_sp = p->n_sp; /* for init */
 96144         nfree(p);
     
 !
106154         NODE *q, *r;
 107155         struct symtab *sp;
 108156 
<> 157+#if defined(ELFABI)
  158+
109159         q = tempnode(gotnr, PTR|VOID, 0, MKSUE(VOID));
 110160         if (p->n_sp->slevel > 0 || p->n_sp->sclass == ILABEL) {
 111161                 char buf[32];
 112162                 snprintf(buf, 32, LABFMT, (int)p->n_sp->soffset);
<>113 -                sp = picsymtab(buf, "@GOTOFF");
  163+                sp = picsymtab("", buf, "@GOTOFF");
114164         } else
<>115 -                sp = picsymtab(p->n_sp->soname, "@GOTOFF");
  165+                sp = picsymtab("", p->n_sp->soname, "@GOTOFF");
116166         sp->sclass = STATIC;
 117167         sp->stype = p->n_sp->stype;
 118168         r = xbcon(0, sp, INT);
 119169         q = buildtree(PLUS, q, r);
 120170         q = block(UMUL, q, 0, p->n_type, p->n_df, p->n_sue);
 121171         q->n_sp = p->n_sp; /* for init */
 122172         nfree(p);
<> 173+
  174+#elif defined(MACHOABI)
  175+
  176+        char buf2[64];
  177+
  178+        snprintf(buf2, 64, "-L%s$pb", cftnsp->soname);
  179+
  180+        if (p->n_sp->slevel > 0 || p->n_sp->sclass == ILABEL) {
  181+                char buf1[64];
  182+                snprintf(buf1, 64, LABFMT, (int)p->n_sp->soffset);
  183+                sp = picsymtab("", buf1, buf2);
  184+                sp->sflags |= SNOUNDERSCORE;
  185+        } else  {
  186+                sp = picsymtab("", exname(p->n_sp->soname), buf2);
  187+        }
  188+        sp->sclass = STATIC;
  189+        sp->stype = p->n_sp->stype;
  190+        q = tempnode(gotnr, PTR+VOID, 0, MKSUE(VOID));
  191+        r = xbcon(0, sp, INT);
  192+        q = buildtree(PLUS, q, r);
  193+        q = block(UMUL, q, 0, p->n_type, p->n_df, p->n_sue);
  194+        q->n_sp = p->n_sp;
  195+        nfree(p);
  196+
  197+#endif
  198+
123199         return q;
 124200 }
 125201 
     
 !
141217 
 142218         /* calc address of var@TLSGD */
 143219         q = tempnode(gotnr, PTR|VOID, 0, MKSUE(VOID));
<>144 -        sp = picsymtab(p->n_sp->soname, "@TLSGD");
  220+        sp = picsymtab("", p->n_sp->soname, "@TLSGD");
145221         r = xbcon(0, sp, INT);
 146222         q = buildtree(PLUS, q, r);
 147223 
     
 !
173249         struct symtab *sp;
 174250         int ext = p->n_sp->sclass;
 175251 
<>176 -        sp = picsymtab(p->n_sp->soname, ext == EXTERN ? "@INDNTPOFF" : "@NTPOFF");
  252+        sp = picsymtab("", p->n_sp->soname,
  253+            ext == EXTERN ? "@INDNTPOFF" : "@NTPOFF");
177254         q = xbcon(0, sp, INT);
 178255         if (ext == EXTERN)
 179256                 q = block(UMUL, q, NIL, PTR|VOID, 0, MKSUE(VOID));
     
 !
560637         sue = q->n_sue;
 561638         if (q->n_op == UMUL)
 562639                 q = q->n_left, isu = 1;
<> 640+
563641         if (q->n_op == PLUS && q->n_left->n_op == TEMP &&
 564642             q->n_right->n_op == ICON) {
 565643                 sp = q->n_right->n_sp;
     
 !
573651                     sp->sclass != EXTDEF)
 574652                         cerror("fixnames");
 575653 
<> 654+#if defined(ELFABI)
  655+
576656                 if ((c = strstr(sp->soname, "@GOT")) == NULL)
 577657                         cerror("fixnames2");
 578658                 if (isu) {
 579659                         memcpy(c, "@PLT", sizeof("@PLT"));
 580660                 } else
 581661                         *c = 0;
<> 662+
  663+#elif defined(MACHOABI)
  664+
  665+                if ((c = strstr(sp->soname, "$non_lazy_ptr")) == NULL &&
  666+                    (c = strstr(sp->soname, "-L")) == NULL)
  667+                                cerror("fixnames2");
  668+                if (isu) {
  669+                        *c = 0;
  670+                        addstub(&stublist, sp->soname+1);
  671+                        strcpy(c, "$stub");
  672+                } else
  673+                        *c = 0;
  674+
  675+#endif
  676+
582677                 nfree(q->n_left);
 583678                 q = q->n_right;
 584679                 if (isu)
     
 !
710805 void
 711806 instring(struct symtab *sp)
 712807 {
<>713 -        char *s, *str;
  808+        char *s, *str = sp->sname;
714809 
<> 810+#if defined(ELFABI)
  811+
715812         defloc(sp);
<>716 -        str = sp->sname;
717813 
<> 814+#elif defined(MACHOABI)
  815+
  816+        extern int lastloc;
  817+        if (lastloc != STRNG)
  818+                printf("        .cstring\n");
  819+        lastloc = STRNG;
  820+        printf("\t.p2align 2\n");
  821+        printf(LABFMT ":\n", sp->soffset);
  822+
  823+#endif
  824+
718825         /* be kind to assemblers and avoid long strings */
 719826         printf("\t.ascii \"");
 720827         for (s = str; *s != 0; ) {
     
 !
839946                         p = p->n_left;
 840947                 p = p->n_right;
 841948                 q = p->n_sp;
<> 949+
  950+#if defined(ELFABI)
  951+
842952                 if ((c = strstr(q->soname, "@GOT")) != NULL)
 843953                         *c = 0; /* ignore GOT ref here */
<> 954+
  955+#else
  956+
  957+                if  ((c = strstr(q->soname, "$non_lazy_ptr")) != NULL) {
  958+                        q->soname++;    /* skip "L" */
  959+                        *c = 0; /* ignore GOT ref here */
  960+                }
  961+                else if ((c = strstr(q->soname, "-L")) != NULL)
  962+                        *c = 0; /* ignore GOT ref here */
  963+
  964+#endif
844965         }
 845966         if (p->n_op != ICON && p->n_op != FCON)
 846967                 cerror("ninval: init node not constant");
     
 !
865986                         if ((q->sclass == STATIC && q->slevel > 0) ||
 866987                             q->sclass == ILABEL) {
 867988                                 printf("+" LABFMT, q->soffset);
<>868 -                        } else
 869 -                                printf("+%s", exname(q->soname));
  989+                        } else {
  990+#if defined(MACHOABI)
  991+                                if ((q->sflags & SNOUNDERSCORE) != 0)
  992+                                        printf("+%s", q->soname);
  993+                                else
  994+#endif
  995+                                        printf("+%s", exname(q->soname));
  996+                        }
870997                 }
 871998                 printf("\n");
 872999                 break;
     
 !
10281155                 destructor = 1;
 10291156                 return 1;
 10301157         }
<>1031 -
10321158         if (strcmp(ary[1], "section") == 0 && ary[2] != NULL) {
 10331159                 nextsect = section2string(ary[2], strlen(ary[2]));
 10341160                 return 1;
     
 !
10501176         gottls = 0;
 10511177 #endif
 10521178         if ((constructor || destructor) && (sp->sclass != PARAM)) {
<> 1179+#if defined(ELFABI)
10531180                 printf("\t.section .%ctors,\"aw\",@progbits\n",
 10541181                     constructor ? 'c' : 'd');
<> 1182+#elif defined(MACHOABI)
  1183+                if (kflag) {
  1184+                        if (constructor)
  1185+                                printf("\t.mod_init_func\n");
  1186+                        else
  1187+                                printf("\t.mod_term_func\n");
  1188+                } else {
  1189+                        if (constructor)
  1190+                                printf("\t.constructor\n");
  1191+                        else
  1192+                                printf("\t.destructor\n");
  1193+                }
  1194+#endif
<_10551195                 printf("\t.p2align 2\n");
 10561196                 printf("\t.long %s\n", exname(sp->sname));
 10571197                 constructor = destructor = 0;
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-10-31 16:46 +0100