2 * 9obj.c - identify and parse a PowerPC-64 object file
3 * forsyth@terzarima.net
12 typedef struct Addr Addr;
19 static Addr addr(Biobuf*);
20 static char type2char(int);
21 static void skip(Biobuf*, int);
26 return (s[0]&0377) == ANAME /* ANAME */
27 && (s[1]&0377) == ANAME>>8
28 && s[2] == D_FILE /* type */
29 && s[3] == 1 /* sym */
30 && s[4] == '<'; /* name of file */
34 _read9(Biobuf *bp, Prog *p)
39 as = Bgetc(bp); /* as(low) */
42 c = Bgetc(bp); /* as(high) */
45 as |= ((c & 0xff) << 8);
48 if(as == ANAME || as == ASIGNAME){
50 Bread(bp, &p->sig, 4);
51 p->sig = beswal(p->sig);
54 p->type = type2char(Bgetc(bp)); /* type */
55 p->sym = Bgetc(bp); /* sym */
69 if(Bread(bp, p->id, n) != n)
77 n = Bgetc(bp); /* reg and flag */
78 skip(bp, 4); /* lineno(4) */
83 if(a.type != D_OREG || a.name != D_STATIC && a.name != D_EXTERN)
96 a.type = Bgetc(bp); /* a.type */
98 a.sym = Bgetc(bp); /* sym index */
99 a.name = Bgetc(bp); /* sym type */
102 case D_NONE: case D_REG: case D_FREG: case D_CREG:
103 case D_FPSCR: case D_MSR:
113 l |= Bgetc(bp) << 16;
114 l |= Bgetc(bp) << 24;
116 if(a.type == D_DCONST){
119 l |= Bgetc(bp) << 16;
120 l |= Bgetc(bp) << 24;
121 off = ((vlong)l << 32) | (off & 0xFFFFFFFF);
122 a.type = D_CONST; /* perhaps */
126 if(a.sym && (a.name==D_PARAM || a.name==D_AUTO))
143 case D_EXTERN: return 'U';
144 case D_STATIC: return 'b';
145 case D_AUTO: return 'a';
146 case D_PARAM: return 'p';
147 default: return UNKNOWN;
152 skip(Biobuf *bp, int n)