blob: ff2e69452e60dcb5c66a95fc541d054de91f0b5d [file] [log] [blame]
Colin Cross7bb052a2015-02-03 12:59:37 -08001// 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
41enum
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
65EXTERN int PtrSize;
66EXTERN int IntSize;
67EXTERN int RegSize;
68
69#define P ((Prog*)0)
70#define S ((LSym*)0)
71enum
72{
73 MINLC = 1,
74};
75
76#pragma varargck type "I" uchar*
77
78EXTERN LSym* datap;
79EXTERN int debug[128];
80EXTERN char literal[32];
81EXTERN int32 lcsize;
82EXTERN char* rpath;
83EXTERN int32 spsize;
84EXTERN LSym* symlist;
85EXTERN int32 symsize;
86
87int Iconv(Fmt *fp);
88void adddynlib(char *lib);
89void adddynrel(LSym *s, Reloc *r);
90void adddynrela(LSym *rela, LSym *s, Reloc *r);
91void adddynsym(Link *ctxt, LSym *s);
92int archreloc(Reloc *r, LSym *s, vlong *val);
93void asmb(void);
94int elfreloc1(Reloc *r, vlong sectoff);
95void elfsetupplt(void);
96void listinit(void);
97int machoreloc1(Reloc *r, vlong sectoff);
98vlong rnd(vlong v, vlong r);
99
100/* Native is little-endian */
101#define LPUT(a) lputl(a)
102#define WPUT(a) wputl(a)
103#define VPUT(a) vputl(a)
104
105/* Used by ../ld/dwarf.c */
106enum
107{
108 DWARFREGSP = 7
109};