github.com/bgentry/go@v0.0.0-20150121062915-6cf5a733d54d/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  enum
    72  {
    73  	MINLC		= 1,
    74  };
    75  
    76  #pragma	varargck	type	"I"	uchar*
    77  
    78  EXTERN	LSym*	datap;
    79  EXTERN	int	debug[128];
    80  EXTERN	char	literal[32];
    81  EXTERN	int32	lcsize;
    82  EXTERN	char*	rpath;
    83  EXTERN	int32	spsize;
    84  EXTERN	LSym*	symlist;
    85  EXTERN	int32	symsize;
    86  
    87  int	Iconv(Fmt *fp);
    88  void	adddynlib(char *lib);
    89  void	adddynrel(LSym *s, Reloc *r);
    90  void	adddynrela(LSym *rela, LSym *s, Reloc *r);
    91  void	adddynsym(Link *ctxt, LSym *s);
    92  int	archreloc(Reloc *r, LSym *s, vlong *val);
    93  vlong	archrelocvariant(Reloc *r, LSym *s, vlong t);
    94  void	asmb(void);
    95  int	elfreloc1(Reloc *r, vlong sectoff);
    96  void	elfsetupplt(void);
    97  void	listinit(void);
    98  int	machoreloc1(Reloc *r, vlong sectoff);
    99  vlong	rnd(vlong v, vlong r);
   100  
   101  /* Native is little-endian */
   102  #define	LPUT(a)	lputl(a)
   103  #define	WPUT(a)	wputl(a)
   104  #define	VPUT(a)	vputl(a)
   105  
   106  /* Used by ../ld/dwarf.c */
   107  enum
   108  {
   109  	DWARFREGSP = 7
   110  };