Commit c2874976 authored by Russ Cox's avatar Russ Cox

factor portable object+library bits out of 5l/6l/8l into ld

R=r
DELTA=3214  (904 added, 2260 deleted, 50 changed)
OCL=35425
CL=35427
parent cfdb3a56
......@@ -9,8 +9,8 @@ TARG=\
OFILES=\
asm.$O\
compat.$O\
enam.$O\
lib.$O\
list.$O\
noop.$O\
obj.$O\
......@@ -24,7 +24,6 @@ HFILES=\
l.h\
../5l/5.out.h\
$(TARG): $(OFILES)
$(LD) -o $(TARG) -L$(GOROOT)/lib $(OFILES) -lbio -l9
......@@ -38,3 +37,6 @@ clean:
install: $(TARG)
cp $(TARG) $(GOBIN)/$(TARG)
%.$O: ../ld/%.c
$(CC) $(CFLAGS) -c -I. ../ld/$*.c
......@@ -29,6 +29,7 @@
// THE SOFTWARE.
#include "l.h"
#include "../ld/lib.h"
int32 OFFSET;
......
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include "l.h"
#include "compat.h"
enum
{
PtrSize = 4
};
#define pcond cond
#include "../ld/go.c"
......@@ -33,6 +33,11 @@
#include <bio.h>
#include "../5l/5.out.h"
enum
{
PtrSize = 4
};
#ifndef EXTERN
#define EXTERN extern
#endif
......@@ -119,7 +124,6 @@ struct Sym
short frame;
uchar subtype;
uchar reachable;
ushort file;
int32 value;
int32 sig;
uchar used;
......@@ -131,6 +135,7 @@ struct Sym
Prog* text;
Prog* data;
Sym* gotype;
char* file;
char* dynldname;
char* dynldlib;
};
......@@ -313,20 +318,8 @@ EXTERN char debug[128];
EXTERN Prog* edatap;
EXTERN Prog* etextp;
EXTERN Prog* firstp;
EXTERN uchar fnuxi4[4];
EXTERN uchar fnuxi8[8];
EXTERN char* noname;
EXTERN Sym* hash[NHASH];
EXTERN Sym* histfrog[MAXHIST];
EXTERN int histfrogp;
EXTERN int histgen;
EXTERN char* library[50];
EXTERN char* libraryobj[50];
EXTERN int libraryp;
EXTERN int xrefresolv;
EXTERN uchar inuxi1[1];
EXTERN uchar inuxi2[2];
EXTERN uchar inuxi4[4];
EXTERN Prog* lastp;
EXTERN int32 lcsize;
EXTERN char literal[32];
......@@ -342,7 +335,6 @@ EXTERN uint32 stroffset;
EXTERN int32 symsize;
EXTERN Prog* textp;
EXTERN int32 textsize;
EXTERN int32 thunk;
EXTERN int version;
EXTERN char xcmp[C_GOK+1][C_GOK+1];
EXTERN Prog zprg;
......@@ -418,19 +410,12 @@ void doprof1(void);
void doprof2(void);
void dynreloc(Sym*, int32, int);
int32 entryvalue(void);
void errorexit(void);
void exchange(Prog*);
void export(void);
int find1(int32, int);
void follow(void);
void histtoauto(void);
void hputl(int);
double ieeedtod(Ieee*);
int32 ieeedtof(Ieee*);
void import(void);
int isnop(Prog*);
void ldobj(Biobuf*, int32, char*);
void loadlib(void);
void listinit(void);
Sym* lookup(char*, int);
void cput(int);
......@@ -442,8 +427,6 @@ void* mysbrk(uint32);
void names(void);
Prog* newdata(Sym *s, int o, int w, int t);
void nocache(Prog*);
void nuxiinit(void);
void objfile(char*);
int ocmp(const void*, const void*);
int32 opirr(int);
Optab* oplook(Prog*);
......@@ -464,19 +447,16 @@ void prepend(Prog*, Prog*);
Prog* prg(void);
int pseudo(Prog*);
void putsymb(char*, int, int32, int);
void readundefs(char*, int);
int32 regoff(Adr*);
int relinv(int);
int32 rnd(int32, int32);
void span(void);
void strnput(char*, int);
void undef(void);
void undefsym(Sym*);
void wput(int32);
void wputl(ushort w);
void xdefine(char*, int, int32);
void xfol(Prog*);
void zerosig(char*);
void noops(void);
int32 immrot(uint32);
int32 immaddr(int32);
......
......@@ -29,6 +29,7 @@
// THE SOFTWARE.
#include "l.h"
#include "../ld/lib.h"
void
listinit(void)
......
This diff is collapsed.
......@@ -29,6 +29,7 @@
// THE SOFTWARE.
#include "l.h"
#include "../ld/lib.h"
void
dodata(void)
......
......@@ -29,6 +29,7 @@
// THE SOFTWARE.
#include "l.h"
#include "../ld/lib.h"
static struct {
uint32 start;
......
......@@ -9,10 +9,10 @@ TARG=\
OFILES=\
asm.$O\
compat.$O\
elf.$O\
enam.$O\
go.$O\
lib.$O\
list.$O\
macho.$O\
obj.$O\
......@@ -23,10 +23,9 @@ OFILES=\
HFILES=\
l.h\
../6l/6.out.h\
../ld/lib.h\
../ld/elf.h\
../ld/macho.h\
../6l/compat.h\
$(TARG): $(OFILES)
$(LD) -o $(TARG) -L$(GOROOT)/lib $(OFILES) -lbio -l9
......@@ -42,6 +41,5 @@ clean:
install: $(TARG)
cp $(TARG) $(GOBIN)/$(TARG)
go.o: ../ld/go.c
elf.o: ../ld/elf.c
macho.o: ../ld/macho.c
%.$O: ../ld/%.c
$(CC) $(CFLAGS) -c -I. ../ld/$*.c
......@@ -29,6 +29,7 @@
// THE SOFTWARE.
#include "l.h"
#include "../ld/lib.h"
#include "../ld/elf.h"
#include "../ld/macho.h"
......
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include "l.h"
#include "../ld/elf.c"
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include "l.h"
enum
{
PtrSize = 8
};
#include "../ld/go.c"
......@@ -32,12 +32,16 @@
#include <libc.h>
#include <bio.h>
#include "../6l/6.out.h"
#include "compat.h"
#ifndef EXTERN
#define EXTERN extern
#endif
enum
{
PtrSize = 8
};
#define P ((Prog*)0)
#define S ((Sym*)0)
#define TNAME (curtext?curtext->from.sym->name:noname)
......@@ -115,7 +119,6 @@ struct Sym
short version;
short become;
short frame;
ushort file;
uchar subtype;
uchar dupok;
uchar reachable;
......@@ -126,6 +129,7 @@ struct Sym
Prog* text;
Prog* data;
Sym* gotype;
char* file;
char* dynldname;
char* dynldlib;
};
......@@ -301,7 +305,6 @@ EXTERN int32 bsssize;
EXTERN int cbc;
EXTERN char* cbp;
EXTERN char* pcstr;
EXTERN int cout;
EXTERN Auto* curauto;
EXTERN Auto* curhist;
EXTERN Prog* curp;
......@@ -313,21 +316,7 @@ EXTERN char debug[128];
EXTERN char literal[32];
EXTERN Prog* etextp;
EXTERN Prog* firstp;
EXTERN uchar fnuxi8[8];
EXTERN uchar fnuxi4[4];
EXTERN Sym* hash[NHASH];
EXTERN Sym* histfrog[MAXHIST];
EXTERN int histfrogp;
EXTERN int histgen;
EXTERN char* library[50];
EXTERN char* libraryobj[50];
EXTERN int libraryp;
EXTERN int xrefresolv;
EXTERN char* hunk;
EXTERN uchar inuxi1[1];
EXTERN uchar inuxi2[2];
EXTERN uchar inuxi4[4];
EXTERN uchar inuxi8[8];
EXTERN char ycover[Ymax*Ymax];
EXTERN uchar* andptr;
EXTERN uchar* rexptr;
......@@ -337,8 +326,6 @@ EXTERN int regrex[D_NONE+1];
EXTERN Prog* lastp;
EXTERN int32 lcsize;
EXTERN int nerrors;
EXTERN int32 nhunk;
EXTERN int32 nsymbol;
EXTERN char* noname;
EXTERN char* outfile;
EXTERN vlong pc;
......@@ -347,7 +334,6 @@ EXTERN Sym* symlist;
EXTERN int32 symsize;
EXTERN Prog* textp;
EXTERN vlong textsize;
EXTERN int32 thunk;
EXTERN int version;
EXTERN Prog zprg;
EXTERN int dtype;
......@@ -411,21 +397,11 @@ void doprof2(void);
void dostkoff(void);
void dynreloc(Sym*, uint32, int);
vlong entryvalue(void);
void errorexit(void);
void export(void);
int find1(int32, int);
int find2(int32, int);
void follow(void);
void addstachmark(void);
void gethunk(void);
void gotypestrings(void);
void histtoauto(void);
double ieeedtod(Ieee*);
int32 ieeedtof(Ieee*);
void import(void);
void ldobj(Biobuf*, int64, char*);
void ldpkg(Biobuf*, int64, char*);
void loadlib(void);
void listinit(void);
Sym* lookup(char*, int);
void lputb(int32);
......@@ -436,20 +412,16 @@ void* mysbrk(uint32);
Prog* newdata(Sym*, int, int, int);
Prog* newtext(Prog*, Sym*);
void nopout(Prog*);
void nuxiinit(void);
void objfile(char*);
int opsize(Prog*);
void patch(void);
Prog* prg(void);
void parsetextconst(vlong);
void readundefs(char*, int);
int relinv(int);
int32 reuse(Prog*, Sym*);
vlong rnd(vlong, vlong);
void span(void);
void strnput(char*, int);
void undef(void);
void undefsym(Sym*);
vlong vaddr(Adr*);
vlong symaddr(Sym*);
void vputl(uint64);
......@@ -458,7 +430,6 @@ void wputl(uint16);
void xdefine(char*, int, vlong);
void xfol(Prog*);
void zaddr(Biobuf*, Adr*, Sym*[]);
void zerosig(char*);
void machseg(char*, vlong, vlong, vlong, vlong, uint32, uint32, uint32, uint32);
void machsymseg(uint32, uint32);
......
......@@ -29,6 +29,7 @@
// THE SOFTWARE.
#include "l.h"
#include "../ld/lib.h"
static Prog* bigP;
......
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include "l.h"
#include "../ld/macho.c"
This diff is collapsed.
......@@ -29,6 +29,7 @@
// THE SOFTWARE.
#include "l.h"
#include "../ld/lib.h"
// see ../../runtime/proc.c:/StackGuard
enum
......
......@@ -29,6 +29,7 @@
// THE SOFTWARE.
#include "l.h"
#include "../ld/lib.h"
static int rexflag;
static int asmode;
......
......@@ -9,9 +9,9 @@ TARG=\
OFILES=\
asm.$O\
compat.$O\
elf.$O\
enam.$O\
lib.$O\
list.$O\
macho.$O\
obj.$O\
......@@ -41,6 +41,5 @@ clean:
install: $(TARG)
cp $(TARG) $(GOBIN)/$(TARG)
go.o: ../ld/go.c
elf.o: ../ld/elf.c
macho.o: ../ld/macho.c
%.$O: ../ld/%.c
$(CC) $(CFLAGS) -c -I. ../ld/$*.c
......@@ -29,6 +29,7 @@
// THE SOFTWARE.
#include "l.h"
#include "../ld/lib.h"
#include "../ld/elf.h"
#include "../ld/macho.h"
......@@ -414,18 +415,13 @@ asmb(void)
{
Prog *p;
int32 v, magic;
int a, i, dynsym;
int a, dynsym;
uint32 va, fo, w, symo, startva, machlink;
uchar *op1;
ulong expectpc;
ElfEhdr *eh;
ElfPhdr *ph, *pph;
ElfShdr *sh;
MachoHdr *mh;
MachoSect *msect;
MachoSeg *ms;
MachoDebug *md;
MachoLoad *ml;
if(debug['v'])
Bprint(&bso, "%5.2f asmb\n", cputime());
......
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include "l.h"
#include "../ld/elf.c"
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include "l.h"
enum
{
PtrSize = 4
};
#include "../ld/go.c"
......@@ -37,6 +37,11 @@
#define EXTERN extern
#endif
enum
{
PtrSize = 4
};
#define P ((Prog*)0)
#define S ((Sym*)0)
#define TNAME (curtext?curtext->from.sym->name:noname)
......@@ -116,7 +121,6 @@ struct Sym
uchar subtype;
uchar dupok;
uchar reachable;
ushort file;
int32 value;
int32 size;
int32 sig;
......@@ -124,6 +128,7 @@ struct Sym
Prog* text;
Prog* data;
Sym* gotype;
char* file;
char* dynldname;
char* dynldlib;
};
......@@ -265,7 +270,6 @@ EXTERN int32 casepc;
EXTERN int cbc;
EXTERN char* cbp;
EXTERN char* pcstr;
EXTERN int cout;
EXTERN Auto* curauto;
EXTERN Auto* curhist;
EXTERN Prog* curp;
......@@ -278,19 +282,7 @@ EXTERN char debug[128];
EXTERN char literal[32];
EXTERN Prog* etextp;
EXTERN Prog* firstp;
EXTERN uchar fnuxi8[8];
EXTERN uchar fnuxi4[4];
EXTERN Sym* hash[NHASH];
EXTERN Sym* histfrog[MAXHIST];
EXTERN int histfrogp;
EXTERN int histgen;
EXTERN char* library[50];
EXTERN char* libraryobj[50];
EXTERN int libraryp;
EXTERN int xrefresolv;
EXTERN uchar inuxi1[1];
EXTERN uchar inuxi2[2];
EXTERN uchar inuxi4[4];
EXTERN uchar ycover[Ymax*Ymax];
EXTERN uchar* andptr;
EXTERN uchar and[100];
......@@ -299,20 +291,16 @@ EXTERN Prog* lastp;
EXTERN int32 lcsize;
EXTERN int maxop;
EXTERN int nerrors;
EXTERN int32 nsymbol;
EXTERN char* noname;
EXTERN char* outfile;
EXTERN int32 pc;
EXTERN int32 spsize;
EXTERN Sym* symlist;
EXTERN int32 symsize;
EXTERN Prog* textp;
EXTERN int32 textsize;
EXTERN int32 thunk;
EXTERN int version;
EXTERN Prog zprg;
EXTERN int dtype;
EXTERN char thechar;
EXTERN int tlsoffset;
EXTERN Adr* reloca;
......@@ -357,18 +345,9 @@ void doprof2(void);
void dostkoff(void);
void dynreloc(Sym*, uint32, int);
int32 entryvalue(void);
void errorexit(void);
void export(void);
int find1(int32, int);
int find2(int32, int);
void follow(void);
void gethunk(void);
void histtoauto(void);
double ieeedtod(Ieee*);
int32 ieeedtof(Ieee*);
void import(void);
void ldobj(Biobuf*, int32, char*);
void loadlib(void);
void listinit(void);
Sym* lookup(char*, int);
void lput(int32);
......@@ -380,19 +359,15 @@ void mkfwd(void);
void* mal(uint32);
Prog* newdata(Sym*, int, int, int);
Prog* newtext(Prog*, Sym*);
void nuxiinit(void);
void objfile(char*);
int opsize(Prog*);
void patch(void);
Prog* prg(void);
void readundefs(char*, int);
int relinv(int);
int32 reuse(Prog*, Sym*);
int32 rnd(int32, int32);
void s8put(char*);
void span(void);
void undef(void);
void undefsym(Sym*);
int32 vaddr(Adr*);
int32 symaddr(Sym*);
void wput(ushort);
......@@ -400,9 +375,7 @@ void wputl(ushort);
void xdefine(char*, int, int32);
void xfol(Prog*);
void zaddr(Biobuf*, Adr*, Sym*[]);
void zerosig(char*);
uint32 machheadr(void);
void whatsys(void);
vlong addaddr(Sym *s, Sym *t);
vlong addsize(Sym *s, Sym *t);
vlong addstring(Sym *s, char *str);
......@@ -416,13 +389,6 @@ vlong adduintxx(Sym *s, uint64 v, int wid);
* go.c
*/
void deadcode(void);
void ldpkg(Biobuf *f, int64 len, char *filename);
/* set by call to whatsys() */
extern char* goroot;
extern char* goarch;
extern char* goos;
/* Native is little-endian */
#define LPUT(a) lputl(a)
......
......@@ -29,6 +29,7 @@
// THE SOFTWARE.
#include "l.h"
#include "../ld/lib.h"
void
listinit(void)
......
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include "l.h"
#include "../ld/macho.c"
This diff is collapsed.
......@@ -29,6 +29,7 @@
// THE SOFTWARE.
#include "l.h"
#include "../ld/lib.h"
// see ../../pkg/runtime/proc.c:/StackGuard
enum
......
......@@ -29,6 +29,7 @@
// THE SOFTWARE.
#include "l.h"
#include "../ld/lib.h"
void
span(void)
......
......@@ -2,7 +2,9 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include "../ld/elf.h"
#include "l.h"
#include "lib.h"
#include "../ld/elf.h"
/*
* We use the 64-bit data structures on both 32- and 64-bit machines
......
......@@ -4,6 +4,9 @@
// go-specific code shared across loaders (5l, 6l, 8l).
#include "l.h"
#include "../ld/lib.h"
// accumulate all type information from .6 files.
// check for inconsistencies.
......
This diff is collapsed.
// Derived from Inferno utils/6l/l.h
// http://code.google.com/p/inferno-os/source/browse/utils/6l/l.h
//
// Copyright © 1994-1999 Lucent Technologies Inc. All rights reserved.
// Portions Copyright © 1995-1997 C H Forsyth (forsyth@terzarima.net)
// Portions Copyright © 1997-1999 Vita Nuova Limited
// Portions Copyright © 2000-2007 Vita Nuova Holdings Limited (www.vitanuova.com)
// Portions Copyright © 2004,2006 Bruce Ellis
// Portions Copyright © 2005-2007 C H Forsyth (forsyth@terzarima.net)
// Revisions Copyright © 2000-2007 Lucent Technologies Inc. and others
// Portions Copyright © 2009 The Go Authors. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
extern char symname[];
extern char *libdir[];
extern int nlibdir;
extern int cout;
EXTERN char* INITENTRY;
EXTERN char thechar;
EXTERN char* thestring;
EXTERN char* library[50];
EXTERN char* libraryobj[50];
EXTERN int libraryp;
EXTERN Sym* hash[NHASH];
EXTERN Sym* histfrog[MAXHIST];
EXTERN uchar fnuxi8[8];
EXTERN uchar fnuxi4[4];
EXTERN int histfrogp;
EXTERN int histgen;
EXTERN uchar inuxi1[1];
EXTERN uchar inuxi2[2];
EXTERN uchar inuxi4[4];
EXTERN uchar inuxi8[8];
EXTERN char* outfile;
EXTERN int32 nsymbol;
void addlib(char *src, char *obj);
void copyhistfrog(char *buf, int nbuf);
void addhist(int32 line, int type);
void histtoauto(void);
void collapsefrog(Sym *s);
Sym* lookup(char *symb, int v);
void nuxiinit(void);
int find1(int32 l, int c);
int find2(int32 l, int c);
int32 ieeedtof(Ieee *e);
double ieeedtod(Ieee *e);
void undefsym(Sym *s);
void zerosig(char *sp);
void readundefs(char *f, int t);
int32 Bget4(Biobuf *f);
void loadlib(void);
void errorexit(void);
void objfile(char *file);
void libinit(void);
void Lflag(char *arg);
void usage(void);
void ldobj1(Biobuf *f, int64 len, char *pn);
void ldobj(Biobuf*, int64, char*);
void ldpkg(Biobuf*, int64, char*);
int pathchar(void);
void* mal(uint32);
void mywhatsys(void);
/* set by call to mywhatsys() */
extern char* goroot;
extern char* goarch;
extern char* goos;
......@@ -5,6 +5,8 @@
// Mach-O file writing
// http://developer.apple.com/mac/library/DOCUMENTATION/DeveloperTools/Conceptual/MachORuntime/Reference/reference.html
#include "l.h"
#include "../ld/lib.h"
#include "../ld/macho.h"
static int macho64;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment