github.com/rohankumardubey/syslog-redirector-golang@v0.0.0-20140320174030-4859f03d829a/src/cmd/8l/l.h (about) 1 // Inferno utils/8l/l.h 2 // http://code.google.com/p/inferno-os/source/browse/utils/8l/l.h 3 // 4 // Copyright © 1994-1999 Lucent Technologies Inc. All rights reserved. 5 // Portions Copyright © 1995-1997 C H Forsyth (forsyth@terzarima.net) 6 // Portions Copyright © 1997-1999 Vita Nuova Limited 7 // Portions Copyright © 2000-2007 Vita Nuova Holdings Limited (www.vitanuova.com) 8 // Portions Copyright © 2004,2006 Bruce Ellis 9 // Portions Copyright © 2005-2007 C H Forsyth (forsyth@terzarima.net) 10 // Revisions Copyright © 2000-2007 Lucent Technologies Inc. and others 11 // Portions Copyright © 2009 The Go Authors. All rights reserved. 12 // 13 // Permission is hereby granted, free of charge, to any person obtaining a copy 14 // of this software and associated documentation files (the "Software"), to deal 15 // in the Software without restriction, including without limitation the rights 16 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17 // copies of the Software, and to permit persons to whom the Software is 18 // furnished to do so, subject to the following conditions: 19 // 20 // The above copyright notice and this permission notice shall be included in 21 // all copies or substantial portions of the Software. 22 // 23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 28 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 29 // THE SOFTWARE. 30 31 #include <u.h> 32 #include <libc.h> 33 #include <bio.h> 34 #include "8.out.h" 35 36 #ifndef EXTERN 37 #define EXTERN extern 38 #endif 39 40 enum 41 { 42 thechar = '8', 43 PtrSize = 4, 44 IntSize = 4, 45 MaxAlign = 32, // max data alignment 46 FuncAlign = 16 47 }; 48 49 #define P ((Prog*)0) 50 #define S ((Sym*)0) 51 #define TNAME (cursym?cursym->name:noname) 52 53 typedef struct Adr Adr; 54 typedef struct Prog Prog; 55 typedef struct Sym Sym; 56 typedef struct Auto Auto; 57 typedef struct Optab Optab; 58 typedef struct Reloc Reloc; 59 60 struct Adr 61 { 62 union 63 { 64 int32 u0offset; 65 char u0scon[8]; 66 Prog *u0cond; /* not used, but should be D_BRANCH */ 67 Ieee u0ieee; 68 char *u0sbig; 69 } u0; 70 Sym* sym; 71 short type; 72 uchar index; 73 char scale; 74 int32 offset2; 75 }; 76 77 #define offset u0.u0offset 78 #define scon u0.u0scon 79 #define cond u0.u0cond 80 #define ieee u0.u0ieee 81 #define sbig u0.u0sbig 82 83 struct Reloc 84 { 85 int32 off; 86 uchar siz; 87 uchar done; 88 int32 type; 89 int32 add; 90 int32 xadd; 91 Sym* sym; 92 Sym* xsym; 93 }; 94 95 struct Prog 96 { 97 Adr from; 98 Adr to; 99 Prog* forwd; 100 Prog* comefrom; 101 Prog* link; 102 Prog* pcond; /* work on this */ 103 int32 pc; 104 int32 spadj; 105 int32 line; 106 short as; 107 char width; /* fake for DATA */ 108 char ft; /* oclass cache */ 109 char tt; 110 uchar mark; /* work on these */ 111 uchar back; 112 uchar bigjmp; 113 }; 114 #define datasize from.scale 115 #define textflag from.scale 116 #define iscall(p) ((p)->as == ACALL) 117 118 struct Auto 119 { 120 Sym* asym; 121 Auto* link; 122 int32 aoffset; 123 short type; 124 Sym* gotype; 125 }; 126 struct Sym 127 { 128 char* name; 129 char* extname; // name used in external object files 130 short type; 131 short version; 132 uchar dupok; 133 uchar reachable; 134 uchar cgoexport; 135 uchar special; 136 uchar stkcheck; 137 uchar hide; 138 int32 value; 139 int32 size; 140 int32 sig; 141 int32 dynid; 142 int32 plt; 143 int32 got; 144 int32 align; // if non-zero, required alignment in bytes 145 int32 elfsym; 146 int32 args; // size of stack frame incoming arguments area 147 Sym* hash; // in hash table 148 Sym* allsym; // in all symbol list 149 Sym* next; // in text or data list 150 Sym* sub; // in sub list 151 Sym* outer; // container of sub 152 Sym* gotype; 153 Sym* reachparent; 154 Sym* queue; 155 char* file; 156 char* dynimplib; 157 char* dynimpvers; 158 struct Section* sect; 159 struct Hist* hist; // for ATEXT 160 161 // STEXT 162 Auto* autom; 163 Prog* text; 164 165 // SDATA, SBSS 166 uchar* p; 167 int32 np; 168 int32 maxp; 169 Reloc* r; 170 int32 nr; 171 int32 maxr; 172 }; 173 struct Optab 174 { 175 short as; 176 uchar* ytab; 177 uchar prefix; 178 uchar op[13]; 179 }; 180 181 enum 182 { 183 MINSIZ = 4, 184 STRINGSZ = 200, 185 MINLC = 1, 186 MAXIO = 8192, 187 MAXHIST = 40, /* limit of path elements for history symbols */ 188 189 Yxxx = 0, 190 Ynone, 191 Yi0, 192 Yi1, 193 Yi8, 194 Yi32, 195 Yiauto, 196 Yal, 197 Ycl, 198 Yax, 199 Ycx, 200 Yrb, 201 Yrl, 202 Yrf, 203 Yf0, 204 Yrx, 205 Ymb, 206 Yml, 207 Ym, 208 Ybr, 209 Ycol, 210 211 Ycs, Yss, Yds, Yes, Yfs, Ygs, 212 Ygdtr, Yidtr, Yldtr, Ymsw, Ytask, 213 Ycr0, Ycr1, Ycr2, Ycr3, Ycr4, Ycr5, Ycr6, Ycr7, 214 Ydr0, Ydr1, Ydr2, Ydr3, Ydr4, Ydr5, Ydr6, Ydr7, 215 Ytr0, Ytr1, Ytr2, Ytr3, Ytr4, Ytr5, Ytr6, Ytr7, 216 Ymr, Ymm, 217 Yxr, Yxm, 218 Ymax, 219 220 Zxxx = 0, 221 222 Zlit, 223 Zlitm_r, 224 Z_rp, 225 Zbr, 226 Zcall, 227 Zcallcon, 228 Zcallind, 229 Zib_, 230 Zib_rp, 231 Zibo_m, 232 Zil_, 233 Zil_rp, 234 Zilo_m, 235 Zjmp, 236 Zjmpcon, 237 Zloop, 238 Zm_o, 239 Zm_r, 240 Zm2_r, 241 Zm_r_xm, 242 Zm_r_i_xm, 243 Zaut_r, 244 Zo_m, 245 Zpseudo, 246 Zr_m, 247 Zr_m_xm, 248 Zr_m_i_xm, 249 Zrp_, 250 Z_ib, 251 Z_il, 252 Zm_ibo, 253 Zm_ilo, 254 Zib_rr, 255 Zil_rr, 256 Zclr, 257 Zibm_r, /* mmx1,mmx2/mem64,imm8 */ 258 Zbyte, 259 Zmov, 260 Zmax, 261 262 Px = 0, 263 Pe = 0x66, /* operand escape */ 264 Pm = 0x0f, /* 2byte opcode escape */ 265 Pq = 0xff, /* both escape */ 266 Pb = 0xfe, /* byte operands */ 267 Pf2 = 0xf2, /* xmm escape 1 */ 268 Pf3 = 0xf3, /* xmm escape 2 */ 269 }; 270 271 #pragma varargck type "A" int 272 #pragma varargck type "D" Adr* 273 #pragma varargck type "I" uchar* 274 #pragma varargck type "P" Prog* 275 #pragma varargck type "R" int 276 #pragma varargck type "S" char* 277 #pragma varargck type "Y" Sym* 278 #pragma varargck type "Z" char* 279 #pragma varargck type "i" char* 280 281 EXTERN int32 HEADR; 282 EXTERN int32 HEADTYPE; 283 EXTERN int32 INITRND; 284 EXTERN int32 INITTEXT; 285 EXTERN int32 INITDAT; 286 EXTERN char* INITENTRY; /* entry point */ 287 EXTERN char* pcstr; 288 EXTERN Auto* curauto; 289 EXTERN Auto* curhist; 290 EXTERN Prog* curp; 291 EXTERN Sym* cursym; 292 EXTERN Sym* datap; 293 EXTERN int debug[128]; 294 EXTERN char literal[32]; 295 EXTERN Sym* etextp; 296 EXTERN Prog* firstp; 297 EXTERN uchar ycover[Ymax*Ymax]; 298 EXTERN uchar* andptr; 299 EXTERN uchar and[100]; 300 EXTERN char reg[D_NONE]; 301 EXTERN int32 lcsize; 302 EXTERN int maxop; 303 EXTERN int nerrors; 304 EXTERN char* noname; 305 EXTERN int32 pc; 306 EXTERN char* rpath; 307 EXTERN int32 spsize; 308 EXTERN Sym* symlist; 309 EXTERN int32 symsize; 310 EXTERN Sym* textp; 311 EXTERN int32 textsize; 312 EXTERN Prog zprg; 313 EXTERN int dtype; 314 EXTERN int tlsoffset; 315 EXTERN Sym* adrgotype; // type symbol on last Adr read 316 EXTERN Sym* fromgotype; // type symbol on last p->from read 317 318 extern Optab optab[]; 319 extern char* anames[]; 320 321 int Aconv(Fmt*); 322 int Dconv(Fmt*); 323 int Iconv(Fmt*); 324 int Pconv(Fmt*); 325 int Rconv(Fmt*); 326 int Sconv(Fmt*); 327 void addhist(int32, int); 328 Prog* appendp(Prog*); 329 void asmb(void); 330 void asmdyn(void); 331 void asmins(Prog*); 332 void asmsym(void); 333 int32 atolwhex(char*); 334 Prog* brchain(Prog*); 335 Prog* brloop(Prog*); 336 void cflush(void); 337 Prog* copyp(Prog*); 338 vlong cpos(void); 339 double cputime(void); 340 void diag(char*, ...); 341 void dodata(void); 342 void doelf(void); 343 void doprof1(void); 344 void doprof2(void); 345 void dostkoff(void); 346 int32 entryvalue(void); 347 void follow(void); 348 void instinit(void); 349 void listinit(void); 350 Sym* lookup(char*, int); 351 void lputb(int32); 352 void lputl(int32); 353 void vputl(uint64); 354 void strnput(char*, int); 355 void main(int, char*[]); 356 void* mal(uint32); 357 int opsize(Prog*); 358 void patch(void); 359 Prog* prg(void); 360 int relinv(int); 361 int32 rnd(int32, int32); 362 void s8put(char*); 363 void span(void); 364 void undef(void); 365 int32 symaddr(Sym*); 366 void wput(ushort); 367 void wputl(ushort); 368 void xdefine(char*, int, int32); 369 370 uint32 machheadr(void); 371 vlong addaddr(Sym *s, Sym *t); 372 vlong addsize(Sym *s, Sym *t); 373 vlong addstring(Sym *s, char *str); 374 vlong adduint16(Sym *s, uint16 v); 375 vlong adduint32(Sym *s, uint32 v); 376 vlong adduint64(Sym *s, uint64 v); 377 vlong adduint8(Sym *s, uint8 v); 378 vlong adduintxx(Sym *s, uint64 v, int wid); 379 380 /* 381 * go.c 382 */ 383 void deadcode(void); 384 385 /* Native is little-endian */ 386 #define LPUT(a) lputl(a) 387 #define WPUT(a) wputl(a) 388 #define VPUT(a) vputl(a) 389 390 /* Used by ../ld/dwarf.c */ 391 enum 392 { 393 DWARFREGSP = 4 394 };