github.com/ader1990/go@v0.0.0-20140630135419-8c24447fa791/src/cmd/5l/l.h (about) 1 // Inferno utils/5l/l.h 2 // http://code.google.com/p/inferno-os/source/browse/utils/5l/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 <link.h> 35 #include "5.out.h" 36 37 enum 38 { 39 thechar = '5', 40 PtrSize = 4, 41 IntSize = 4, 42 RegSize = 4, 43 MaxAlign = 8, // max data alignment 44 FuncAlign = 4 // single-instruction alignment 45 }; 46 47 #ifndef EXTERN 48 #define EXTERN extern 49 #endif 50 51 /* do not undefine this - code will be removed eventually */ 52 #define CALLEEBX 53 54 #define dynptrsize 0 55 56 #define P ((Prog*)0) 57 #define S ((LSym*)0) 58 #define TNAME (ctxt->cursym?ctxt->cursym->name:noname) 59 60 #define SIGNINTERN (1729*325*1729) 61 62 typedef struct Count Count; 63 struct Count 64 { 65 int32 count; 66 int32 outof; 67 }; 68 69 enum 70 { 71 /* mark flags */ 72 FOLL = 1<<0, 73 LABEL = 1<<1, 74 LEAF = 1<<2, 75 76 STRINGSZ = 200, 77 MINSIZ = 64, 78 NENT = 100, 79 MAXIO = 8192, 80 MAXHIST = 40, /* limit of path elements for history symbols */ 81 MINLC = 4, 82 83 C_NONE = 0, 84 C_REG, 85 C_REGREG, 86 C_REGREG2, 87 C_SHIFT, 88 C_FREG, 89 C_PSR, 90 C_FCR, 91 92 C_RCON, /* 0xff rotated */ 93 C_NCON, /* ~RCON */ 94 C_SCON, /* 0xffff */ 95 C_LCON, 96 C_LCONADDR, 97 C_ZFCON, 98 C_SFCON, 99 C_LFCON, 100 101 C_RACON, 102 C_LACON, 103 104 C_SBRA, 105 C_LBRA, 106 107 C_HAUTO, /* halfword insn offset (-0xff to 0xff) */ 108 C_FAUTO, /* float insn offset (0 to 0x3fc, word aligned) */ 109 C_HFAUTO, /* both H and F */ 110 C_SAUTO, /* -0xfff to 0xfff */ 111 C_LAUTO, 112 113 C_HOREG, 114 C_FOREG, 115 C_HFOREG, 116 C_SOREG, 117 C_ROREG, 118 C_SROREG, /* both nil and R */ 119 C_LOREG, 120 121 C_PC, 122 C_SP, 123 C_HREG, 124 125 C_ADDR, /* reference to relocatable address */ 126 127 C_GOK, 128 }; 129 130 #ifndef COFFCVT 131 132 EXTERN int32 autosize; 133 EXTERN LSym* datap; 134 EXTERN int debug[128]; 135 EXTERN char* noname; 136 EXTERN Prog* lastp; 137 EXTERN int32 lcsize; 138 EXTERN char literal[32]; 139 EXTERN int nerrors; 140 EXTERN int32 instoffset; 141 EXTERN char* rpath; 142 EXTERN uint32 stroffset; 143 EXTERN int32 symsize; 144 EXTERN int armsize; 145 146 #pragma varargck type "I" uint32* 147 148 int Iconv(Fmt *fp); 149 void adddynlib(char *lib); 150 void adddynrel(LSym *s, Reloc *r); 151 void adddynrela(LSym *rel, LSym *s, Reloc *r); 152 void adddynsym(Link *ctxt, LSym *s); 153 int archreloc(Reloc *r, LSym *s, vlong *val); 154 void asmb(void); 155 void cput(int32 c); 156 int elfreloc1(Reloc *r, vlong sectoff); 157 void elfsetupplt(void); 158 void hput(int32 l); 159 void listinit(void); 160 void lput(int32 l); 161 int machoreloc1(Reloc *r, vlong sectoff); 162 void main(int argc, char *argv[]); 163 void noops(void); 164 void nopstat(char *f, Count *c); 165 int32 rnd(int32 v, int32 r); 166 void wput(int32 l); 167 168 /* Native is little-endian */ 169 #define LPUT(a) lputl(a) 170 #define WPUT(a) wputl(a) 171 #define VPUT(a) abort() 172 173 #endif 174 175 /* Used by ../ld/dwarf.c */ 176 enum 177 { 178 DWARFREGSP = 13 179 };