github.com/ader1990/go@v0.0.0-20140630135419-8c24447fa791/src/cmd/6l/l.h (about) 1 // Inferno utils/6l/l.h 2 // http://code.google.com/p/inferno-os/source/browse/utils/6l/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 "6.out.h" 36 37 #ifndef EXTERN 38 #define EXTERN extern 39 #endif 40 41 enum 42 { 43 thechar = '6', 44 MaxAlign = 32, // max data alignment 45 46 // Loop alignment constants: 47 // want to align loop entry to LoopAlign-byte boundary, 48 // and willing to insert at most MaxLoopPad bytes of NOP to do so. 49 // We define a loop entry as the target of a backward jump. 50 // 51 // gcc uses MaxLoopPad = 10 for its 'generic x86-64' config, 52 // and it aligns all jump targets, not just backward jump targets. 53 // 54 // As of 6/1/2012, the effect of setting MaxLoopPad = 10 here 55 // is very slight but negative, so the alignment is disabled by 56 // setting MaxLoopPad = 0. The code is here for reference and 57 // for future experiments. 58 // 59 LoopAlign = 16, 60 MaxLoopPad = 0, 61 62 FuncAlign = 16 63 }; 64 65 EXTERN int PtrSize; 66 EXTERN int IntSize; 67 EXTERN int RegSize; 68 69 #define P ((Prog*)0) 70 #define S ((LSym*)0) 71 #define TNAME (ctxt->cursym?ctxt->cursym->name:noname) 72 enum 73 { 74 MINSIZ = 8, 75 STRINGSZ = 200, 76 MINLC = 1, 77 MAXIO = 8192, 78 MAXHIST = 40, /* limit of path elements for history symbols */ 79 }; 80 81 #pragma varargck type "I" uchar* 82 83 EXTERN LSym* datap; 84 EXTERN int debug[128]; 85 EXTERN char literal[32]; 86 EXTERN int32 lcsize; 87 EXTERN char* rpath; 88 EXTERN int32 spsize; 89 EXTERN LSym* symlist; 90 EXTERN int32 symsize; 91 92 EXTERN vlong textstksiz; 93 EXTERN vlong textarg; 94 95 int Iconv(Fmt *fp); 96 void adddynlib(char *lib); 97 void adddynrel(LSym *s, Reloc *r); 98 void adddynrela(LSym *rela, LSym *s, Reloc *r); 99 void adddynsym(Link *ctxt, LSym *s); 100 int archreloc(Reloc *r, LSym *s, vlong *val); 101 void asmb(void); 102 int elfreloc1(Reloc *r, vlong sectoff); 103 void elfsetupplt(void); 104 void listinit(void); 105 int machoreloc1(Reloc *r, vlong sectoff); 106 void main(int argc, char *argv[]); 107 void parsetextconst(vlong arg); 108 vlong rnd(vlong v, vlong r); 109 110 /* Native is little-endian */ 111 #define LPUT(a) lputl(a) 112 #define WPUT(a) wputl(a) 113 #define VPUT(a) vputl(a) 114 115 /* Used by ../ld/dwarf.c */ 116 enum 117 { 118 DWARFREGSP = 7 119 };