Commit 7d507dc6 authored by Russ Cox's avatar Russ Cox

liblink: create new library based on linker code

There is an enormous amount of code moving around in this CL,
but the code is the same, and it is invoked in the same ways.
This CL is preparation for the new linker structure, not the new
structure itself.

The new library's definition is in include/link.h.

The main change is the use of a Link structure to hold all the
linker-relevant state, replacing the smattering of global variables.
The Link structure should both make it clearer which state must
be carried around and make it possible to parallelize more easily
later.

The main body of the linker has moved into the architecture-independent
cmd/ld directory. That includes the list of known header types, so the
distinction between Hplan9x32 and Hplan9x64 is removed (no other
header type distinguished 32- and 64-bit formats), and code for unused
formats such as ipaq kernels has been deleted.

The code being deleted from 5l, 6l, and 8l reappears in liblink or in ld.
Because multiple files are being merged in the liblink directory,
it is not possible to show the diffs nicely in hg.

The Prog and Addr structures have been unified into an
architecture-independent form and moved to link.h, where they will
be shared by all tools: the assemblers, the compilers, and the linkers.
The unification makes it possible to write architecture-independent
traversal of Prog lists, among other benefits.

The Sym structures cannot be unified: they are too fundamentally
different between the linker and the compilers. Instead, liblink defines
an LSym - a linker Sym - to be used in the Prog and Addr structures,
and the linker now refers exclusively to LSyms. The compilers will
keep using their own syms but will fill out the corresponding LSyms in
the Prog and Addr structures.

Although code from 5l, 6l, and 8l is now in a single library, the
code has been arranged so that only one architecture needs to
be linked into a particular program: 5l will not contain the code
needed for x86 instruction layout, for example.

The object file writing code in liblink/obj.c is from cmd/gc/obj.c.

Preparation for golang.org/s/go13linker work.

This CL does not build by itself. It depends on 35740044
and will be submitted at the same time.

R=iant
CC=golang-dev
https://golang.org/cl/35790044
parent 8642cbd6
This diff is collapsed.
...@@ -188,6 +188,8 @@ typedef u32int uint32; ...@@ -188,6 +188,8 @@ typedef u32int uint32;
typedef s64int int64; typedef s64int int64;
typedef u64int uint64; typedef u64int uint64;
typedef float float32;
typedef double float64;
#undef _NEEDUCHAR #undef _NEEDUCHAR
#undef _NEEDUSHORT #undef _NEEDUSHORT
......
...@@ -234,62 +234,53 @@ enum as ...@@ -234,62 +234,53 @@ enum as
#define SHIFT_AR 2<<5 #define SHIFT_AR 2<<5
#define SHIFT_RR 3<<5 #define SHIFT_RR 3<<5
enum
{
/* type/name */ /* type/name */
#define D_GOK 0 D_GOK = 0,
#define D_NONE 1 D_NONE = 1,
/* type */ /* type */
#define D_BRANCH (D_NONE+1) D_BRANCH = (D_NONE+1),
#define D_OREG (D_NONE+2) D_OREG = (D_NONE+2),
#define D_CONST (D_NONE+7) D_CONST = (D_NONE+7),
#define D_FCONST (D_NONE+8) D_FCONST = (D_NONE+8),
#define D_SCONST (D_NONE+9) D_SCONST = (D_NONE+9),
#define D_PSR (D_NONE+10) D_PSR = (D_NONE+10),
#define D_REG (D_NONE+12) D_REG = (D_NONE+12),
#define D_FREG (D_NONE+13) D_FREG = (D_NONE+13),
#define D_FILE (D_NONE+16) D_FILE = (D_NONE+16),
#define D_OCONST (D_NONE+17) D_OCONST = (D_NONE+17),
#define D_FILE1 (D_NONE+18) D_FILE1 = (D_NONE+18),
#define D_SHIFT (D_NONE+19) D_SHIFT = (D_NONE+19),
#define D_FPCR (D_NONE+20) D_FPCR = (D_NONE+20),
#define D_REGREG (D_NONE+21) // (reg, reg) D_REGREG = (D_NONE+21), // (reg, reg)
#define D_ADDR (D_NONE+22) D_ADDR = (D_NONE+22),
#define D_SBIG (D_NONE+23) D_SBIG = (D_NONE+23),
#define D_CONST2 (D_NONE+24) D_CONST2 = (D_NONE+24),
#define D_REGREG2 (D_NONE+25) // reg, reg D_REGREG2 = (D_NONE+25), // reg, reg
/* name */ /* name */
#define D_EXTERN (D_NONE+3) D_EXTERN = (D_NONE+3),
#define D_STATIC (D_NONE+4) D_STATIC = (D_NONE+4),
#define D_AUTO (D_NONE+5) D_AUTO = (D_NONE+5),
#define D_PARAM (D_NONE+6) D_PARAM = (D_NONE+6),
/* internal only */ /* internal only */
#define D_SIZE (D_NONE+40) D_SIZE = (D_NONE+40),
#define D_PCREL (D_NONE+41) D_PCREL = (D_NONE+41),
#define D_GOTOFF (D_NONE+42) // R_ARM_GOTOFF D_GOTOFF = (D_NONE+42), // R_ARM_GOTOFF
#define D_PLT0 (D_NONE+43) // R_ARM_PLT32, 1st inst: add ip, pc, #0xNN00000 D_PLT0 = (D_NONE+43), // R_ARM_PLT32, 1st inst: add ip, pc, #0xNN00000
#define D_PLT1 (D_NONE+44) // R_ARM_PLT32, 2nd inst: add ip, ip, #0xNN000 D_PLT1 = (D_NONE+44), // R_ARM_PLT32, 2nd inst: add ip, ip, #0xNN000
#define D_PLT2 (D_NONE+45) // R_ARM_PLT32, 3rd inst: ldr pc, [ip, #0xNNN]! D_PLT2 = (D_NONE+45), // R_ARM_PLT32, 3rd inst: ldr pc, [ip, #0xNNN]!
#define D_CALL (D_NONE+46) // R_ARM_PLT32/R_ARM_CALL/R_ARM_JUMP24, bl xxxxx or b yyyyy D_CALL = (D_NONE+46), // R_ARM_PLT32/R_ARM_CALL/R_ARM_JUMP24, bl xxxxx or b yyyyy
#define D_TLS (D_NONE+47) // R_ARM_TLS_LE32 D_TLS = (D_NONE+47), // R_ARM_TLS_LE32
};
/* /*
* this is the ranlib header * this is the ranlib header
*/ */
#define SYMDEF "__.GOSYMDEF" #define SYMDEF "__.GOSYMDEF"
/*
* this is the simulated IEEE floating point
*/
typedef struct ieee Ieee;
struct ieee
{
int32 l; /* contains ls-man 0xffffffff */
int32 h; /* contains sign 0x80000000
exp 0x7ff00000
ms-man 0x000fffff */
};
This diff is collapsed.
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include <u.h> #include <u.h>
#include <libc.h> #include <libc.h>
#include <bio.h> #include <bio.h>
#include <link.h>
#include "5.out.h" #include "5.out.h"
enum enum
...@@ -51,167 +52,13 @@ enum ...@@ -51,167 +52,13 @@ enum
#define dynptrsize 0 #define dynptrsize 0
typedef struct Adr Adr;
typedef struct Sym Sym;
typedef struct Autom Auto;
typedef struct Prog Prog;
typedef struct Reloc Reloc;
typedef struct Optab Optab;
typedef struct Oprang Oprang;
typedef uchar Opcross[32][2][32];
typedef struct Count Count;
#define P ((Prog*)0) #define P ((Prog*)0)
#define S ((Sym*)0) #define S ((LSym*)0)
#define TNAME (cursym?cursym->name:noname) #define TNAME (ctxt->cursym?ctxt->cursym->name:noname)
struct Adr
{
union
{
struct {
int32 u0offset;
int32 u0offset2; // argsize
} u0off;
char* u0sval;
Ieee u0ieee;
char* u0sbig;
} u0;
Sym* sym;
Sym* gotype;
char type;
char reg;
char name;
char class;
};
#define offset u0.u0off.u0offset
#define offset2 u0.u0off.u0offset2
#define sval u0.u0sval
#define scon sval
#define ieee u0.u0ieee
#define sbig u0.u0sbig
struct Reloc
{
int32 off;
uchar siz;
uchar done;
int16 type;
int32 add;
int32 xadd;
Sym* sym;
Sym* xsym;
};
struct Prog
{
Adr from;
Adr to;
union
{
int32 u0regused;
Prog* u0forwd;
} u0;
Prog* cond;
Prog* link;
Prog* pcrel;
int32 pc;
int32 line;
int32 spadj;
uchar mark;
uchar optab;
uchar as;
uchar scond;
uchar reg;
uchar align; // unused
};
#define regused u0.u0regused
#define forwd u0.u0forwd
#define datasize reg
#define textflag reg
#define iscall(p) ((p)->as == ABL)
struct Sym
{
char* name;
char* extname; // name used in external object files
short type;
short version;
uchar dupok;
uchar reachable;
uchar cgoexport;
uchar leaf;
int32 dynid;
int32 plt;
int32 got;
int32 value;
int32 sig;
int32 size;
int32 align; // if non-zero, required alignment in bytes
int32 elfsym;
int32 locals; // size of stack frame locals area
int32 args; // size of stack frame incoming arguments area
uchar special;
uchar fnptr; // used as fn ptr
uchar stkcheck;
uchar hide;
Sym* hash; // in hash table
Sym* allsym; // in all symbol list
Sym* next; // in text or data list
Sym* sub; // in SSUB list
Sym* outer; // container of sub
Sym* gotype;
Sym* reachparent;
Sym* queue;
char* file;
char* dynimplib;
char* dynimpvers;
struct Section* sect;
struct Hist* hist;
// STEXT
Auto* autom;
Prog* text;
// SDATA, SBSS
uchar* p;
int32 np;
int32 maxp;
Reloc* r;
int32 nr;
int32 maxr;
};
#define SIGNINTERN (1729*325*1729) #define SIGNINTERN (1729*325*1729)
struct Autom typedef struct Count Count;
{
Sym* asym;
Auto* link;
int32 aoffset;
short type;
Sym* gotype;
};
struct Optab
{
char as;
uchar a1;
char a2;
uchar a3;
uchar type;
char size;
char param;
char flag;
uchar pcrelsiz;
};
struct Oprang
{
Optab* start;
Optab* stop;
};
struct Count struct Count
{ {
int32 count; int32 count;
...@@ -220,10 +67,17 @@ struct Count ...@@ -220,10 +67,17 @@ struct Count
enum enum
{ {
LFROM = 1<<0, /* mark flags */
LTO = 1<<1, FOLL = 1<<0,
LPOOL = 1<<2, LABEL = 1<<1,
LPCREL = 1<<3, LEAF = 1<<2,
STRINGSZ = 200,
MINSIZ = 64,
NENT = 100,
MAXIO = 8192,
MAXHIST = 40, /* limit of path elements for history symbols */
MINLC = 4,
C_NONE = 0, C_NONE = 0,
C_REG, C_REG,
...@@ -260,7 +114,7 @@ enum ...@@ -260,7 +114,7 @@ enum
C_HFOREG, C_HFOREG,
C_SOREG, C_SOREG,
C_ROREG, C_ROREG,
C_SROREG, /* both S and R */ C_SROREG, /* both nil and R */
C_LOREG, C_LOREG,
C_PC, C_PC,
...@@ -270,179 +124,61 @@ enum ...@@ -270,179 +124,61 @@ enum
C_ADDR, /* reference to relocatable address */ C_ADDR, /* reference to relocatable address */
C_GOK, C_GOK,
/* mark flags */
FOLL = 1<<0,
LABEL = 1<<1,
LEAF = 1<<2,
STRINGSZ = 200,
MINSIZ = 64,
NENT = 100,
MAXIO = 8192,
MAXHIST = 40, /* limit of path elements for history symbols */
MINLC = 4,
}; };
#ifndef COFFCVT #ifndef COFFCVT
EXTERN int32 HEADR; /* length of header */
EXTERN int HEADTYPE; /* type of header */
EXTERN int32 INITDAT; /* data location */
EXTERN int32 INITRND; /* data round above text location */
EXTERN int32 INITTEXT; /* text location */
EXTERN char* INITENTRY; /* entry point */
EXTERN int32 autosize; EXTERN int32 autosize;
EXTERN Auto* curauto; EXTERN LSym* datap;
EXTERN Auto* curhist;
EXTERN Prog* curp;
EXTERN Sym* cursym;
EXTERN Sym* datap;
EXTERN int debug[128]; EXTERN int debug[128];
EXTERN Sym* etextp;
EXTERN char* noname; EXTERN char* noname;
EXTERN Prog* lastp; EXTERN Prog* lastp;
EXTERN int32 lcsize; EXTERN int32 lcsize;
EXTERN char literal[32]; EXTERN char literal[32];
EXTERN int nerrors; EXTERN int nerrors;
EXTERN int32 instoffset; EXTERN int32 instoffset;
EXTERN Opcross opcross[8];
EXTERN Oprang oprange[ALAST];
EXTERN char* outfile;
EXTERN int32 pc;
EXTERN uchar repop[ALAST];
EXTERN char* interpreter;
EXTERN char* rpath; EXTERN char* rpath;
EXTERN uint32 stroffset; EXTERN uint32 stroffset;
EXTERN int32 symsize; EXTERN int32 symsize;
EXTERN Sym* textp;
EXTERN char xcmp[C_GOK+1][C_GOK+1];
EXTERN Prog zprg;
EXTERN int dtype;
EXTERN int tlsoffset;
EXTERN int armsize; EXTERN int armsize;
EXTERN int goarm;
EXTERN Sym* adrgotype; // type symbol on last Adr read
EXTERN Sym* fromgotype; // type symbol on last p->from read
extern char* anames[];
extern Optab optab[];
void addpool(Prog*, Adr*);
EXTERN Prog* blitrl;
EXTERN Prog* elitrl;
EXTERN int goarm;
void initdiv(void);
EXTERN Prog* prog_div;
EXTERN Prog* prog_divu;
EXTERN Prog* prog_mod;
EXTERN Prog* prog_modu;
#pragma varargck type "A" int #pragma varargck type "A" int
#pragma varargck type "C" int #pragma varargck type "C" int
#pragma varargck type "D" Adr* #pragma varargck type "D" Addr*
#pragma varargck type "I" uchar* #pragma varargck type "I" uchar*
#pragma varargck type "N" Adr* #pragma varargck type "N" Addr*
#pragma varargck type "P" Prog* #pragma varargck type "P" Prog*
#pragma varargck type "S" char* #pragma varargck type "S" char*
#pragma varargck type "Z" char* #pragma varargck type "Z" char*
#pragma varargck type "i" char* #pragma varargck type "i" char*
int Aconv(Fmt*); int Aconv(Fmt *fp);
int Cconv(Fmt*); int Cconv(Fmt *fp);
int Dconv(Fmt*); int Dconv(Fmt *fp);
int Iconv(Fmt*); int Iconv(Fmt *fp);
int Nconv(Fmt*); int Nconv(Fmt *fp);
int Oconv(Fmt*); int Oconv(Fmt *fp);
int Pconv(Fmt*); int Pconv(Fmt *fp);
int Sconv(Fmt*); int Sconv(Fmt *fp);
int aclass(Adr*); void adddynlib(char *lib);
void addhist(int32, int); void adddynrel(LSym *s, Reloc *r);
Prog* appendp(Prog*); void adddynrela(LSym *rel, LSym *s, Reloc *r);
void adddynsym(Link *ctxt, LSym *s);
int archreloc(Reloc *r, LSym *s, vlong *val);
void asmb(void); void asmb(void);
void asmout(Prog*, Optab*, int32*, Sym*); void cput(int32 c);
int32 atolwhex(char*); void diag(char *fmt, ...);
Prog* brloop(Prog*); int elfreloc1(Reloc *r, vlong sectoff);
void buildop(void); void elfsetupplt(void);
void buildrep(int, int); void hput(int32 l);
void cflush(void);
int chipzero(Ieee*);
int chipfloat(Ieee*);
int cmp(int, int);
int compound(Prog*);
double cputime(void);
void diag(char*, ...);
void divsig(void);
void dodata(void);
void doprof1(void);
void doprof2(void);
int32 entryvalue(void);
void exchange(Prog*);
void follow(void);
void hputl(int);
int isnop(Prog*);
void listinit(void); void listinit(void);
Sym* lookup(char*, int); void lput(int32 l);
void cput(int); int machoreloc1(Reloc *r, vlong sectoff);
void hput(int32); void main(int argc, char *argv[]);
void lput(int32);
void lputb(int32);
void lputl(int32);
void* mysbrk(uint32);
void names(void);
void nocache(Prog*);
int ocmp(const void*, const void*);
int32 opirr(int);
Optab* oplook(Prog*);
int32 oprrr(int, int);
int32 olr(int32, int, int, int);
int32 olhr(int32, int, int, int);
int32 olrr(int, int, int, int);
int32 olhrr(int, int, int, int);
int32 osr(int, int, int32, int, int);
int32 oshr(int, int32, int, int);
int32 ofsr(int, int, int32, int, int, Prog*);
int32 osrr(int, int, int, int);
int32 oshrr(int, int, int, int);
int32 omvl(Prog*, Adr*, int);
void patch(void);
void prasm(Prog*);
void prepend(Prog*, Prog*);
Prog* prg(void);
int pseudo(Prog*);
int32 regoff(Adr*);
int relinv(int);
int32 rnd(int32, int32);
void softfloat(void);
void span(void);
void strnput(char*, int);
int32 symaddr(Sym*);
void undef(void);
void vputb(uint64);
void vputl(uint64);
void wputb(uint16);
void wput(int32);
void wputl(ushort w);
void xdefine(char*, int, int32);
void noops(void); void noops(void);
int32 immrot(uint32); void nopstat(char *f, Count *c);
int32 immaddr(int32); int32 rnd(int32 v, int32 r);
int32 opbra(int, int); void wput(int32 l);
int brextra(Prog*);
int isbranch(Prog*);
void doelf(void);
void dozerostk(void); // used by -Z
vlong addaddr(Sym *s, Sym *t);
vlong addsize(Sym *s, Sym *t);
vlong addstring(Sym *s, char *str);
vlong adduint16(Sym *s, uint16 v);
vlong adduint32(Sym *s, uint32 v);
vlong adduint64(Sym *s, uint64 v);
vlong adduint8(Sym *s, uint8 v);
vlong adduintxx(Sym *s, uint64 v, int wid);
/* Native is little-endian */ /* Native is little-endian */
#define LPUT(a) lputl(a) #define LPUT(a) lputl(a)
......
...@@ -47,11 +47,7 @@ listinit(void) ...@@ -47,11 +47,7 @@ listinit(void)
fmtinstall('I', Iconv); fmtinstall('I', Iconv);
} }
void static Prog *curp;
prasm(Prog *p)
{
print("%P\n", p);
}
int int
Pconv(Fmt *fp) Pconv(Fmt *fp)
...@@ -64,7 +60,7 @@ Pconv(Fmt *fp) ...@@ -64,7 +60,7 @@ Pconv(Fmt *fp)
a = p->as; a = p->as;
switch(a) { switch(a) {
default: default:
fmtprint(fp, "(%d)", p->line); fmtprint(fp, "(%d)", p->lineno);
if(p->reg == NREG && p->as != AGLOBL) if(p->reg == NREG && p->as != AGLOBL)
fmtprint(fp, " %A%C %D,%D", fmtprint(fp, " %A%C %D,%D",
a, p->scond, &p->from, &p->to); a, p->scond, &p->from, &p->to);
...@@ -80,22 +76,22 @@ Pconv(Fmt *fp) ...@@ -80,22 +76,22 @@ Pconv(Fmt *fp)
case ASWPW: case ASWPW:
case ASWPBU: case ASWPBU:
fmtprint(fp, "(%d) %A%C R%d,%D,%D", fmtprint(fp, "(%d) %A%C R%d,%D,%D",
p->line, a, p->scond, p->reg, &p->from, &p->to); p->lineno, a, p->scond, p->reg, &p->from, &p->to);
break; break;
case ADATA: case ADATA:
case AINIT_: case AINIT_:
case ADYNT_: case ADYNT_:
fmtprint(fp, "(%d) %A%C %D/%d,%D", fmtprint(fp, "(%d) %A%C %D/%d,%D",
p->line, a, p->scond, &p->from, p->reg, &p->to); p->lineno, a, p->scond, &p->from, p->reg, &p->to);
break; break;
case AWORD: case AWORD:
fmtprint(fp, "(%d) WORD %D", p->line, &p->to); fmtprint(fp, "(%d) WORD %D", p->lineno, &p->to);
break; break;
case ADWORD: case ADWORD:
fmtprint(fp, "(%d) DWORD %D %D", p->line, &p->from, &p->to); fmtprint(fp, "(%d) DWORD %D %D", p->lineno, &p->from, &p->to);
break; break;
} }
...@@ -114,7 +110,7 @@ Aconv(Fmt *fp) ...@@ -114,7 +110,7 @@ Aconv(Fmt *fp)
a = va_arg(fp->args, int); a = va_arg(fp->args, int);
s = "???"; s = "???";
if(a >= AXXX && a < ALAST) if(a >= AXXX && a < ALAST)
s = anames[a]; s = anames5[a];
return fmtstrcpy(fp, s); return fmtstrcpy(fp, s);
} }
...@@ -162,10 +158,10 @@ Dconv(Fmt *fp) ...@@ -162,10 +158,10 @@ Dconv(Fmt *fp)
{ {
char str[STRINGSZ]; char str[STRINGSZ];
const char *op; const char *op;
Adr *a; Addr *a;
int32 v; int32 v;
a = va_arg(fp->args, Adr*); a = va_arg(fp->args, Addr*);
switch(a->type) { switch(a->type) {
default: default:
...@@ -271,8 +267,8 @@ Dconv(Fmt *fp) ...@@ -271,8 +267,8 @@ Dconv(Fmt *fp)
break; break;
case D_BRANCH: /* botch */ case D_BRANCH: /* botch */
if(curp->cond != P) { if(curp->pcond != P) {
v = curp->cond->pc; v = curp->pcond->pc;
if(a->sym != S) if(a->sym != S)
snprint(str, sizeof str, "%s+%.5ux(BRANCH)", a->sym->name, v); snprint(str, sizeof str, "%s+%.5ux(BRANCH)", a->sym->name, v);
else else
...@@ -285,11 +281,11 @@ Dconv(Fmt *fp) ...@@ -285,11 +281,11 @@ Dconv(Fmt *fp)
break; break;
case D_FCONST: case D_FCONST:
snprint(str, sizeof str, "$%e", ieeedtod(&a->ieee)); snprint(str, sizeof str, "$%.17g", a->u.dval);
break; break;
case D_SCONST: case D_SCONST:
snprint(str, sizeof str, "$\"%S\"", a->sval); snprint(str, sizeof str, "$\"%S\"", a->u.sval);
break; break;
} }
return fmtstrcpy(fp, str); return fmtstrcpy(fp, str);
...@@ -299,10 +295,10 @@ int ...@@ -299,10 +295,10 @@ int
Nconv(Fmt *fp) Nconv(Fmt *fp)
{ {
char str[STRINGSZ]; char str[STRINGSZ];
Adr *a; Addr *a;
Sym *s; LSym *s;
a = va_arg(fp->args, Adr*); a = va_arg(fp->args, Addr*);
s = a->sym; s = a->sym;
switch(a->name) { switch(a->name) {
default: default:
...@@ -478,8 +474,8 @@ diag(char *fmt, ...) ...@@ -478,8 +474,8 @@ diag(char *fmt, ...)
tn = ""; tn = "";
sep = ""; sep = "";
if(cursym != S) { if(ctxt->cursym != S) {
tn = cursym->name; tn = ctxt->cursym->name;
sep = ": "; sep = ": ";
} }
va_start(arg, fmt); va_start(arg, fmt);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
// 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/lib.h"
// Software floating point.
void
softfloat(void)
{
Prog *p, *next, *psfloat;
Sym *symsfloat;
int wasfloat;
if(!debug['F'])
return;
symsfloat = lookup("_sfloat", 0);
psfloat = P;
if(symsfloat->type == STEXT)
psfloat = symsfloat->text;
for(cursym = textp; cursym != nil; cursym = cursym->next) {
wasfloat = 0;
for(p = cursym->text; p != P; p = p->link)
if(p->cond != P)
p->cond->mark |= LABEL;
for(p = cursym->text; p != P; p = p->link) {
switch(p->as) {
case AMOVW:
if(p->to.type == D_FREG || p->from.type == D_FREG)
goto soft;
goto notsoft;
case AMOVWD:
case AMOVWF:
case AMOVDW:
case AMOVFW:
case AMOVFD:
case AMOVDF:
case AMOVF:
case AMOVD:
case ACMPF:
case ACMPD:
case AADDF:
case AADDD:
case ASUBF:
case ASUBD:
case AMULF:
case AMULD:
case ADIVF:
case ADIVD:
case ASQRTF:
case ASQRTD:
case AABSF:
case AABSD:
goto soft;
default:
goto notsoft;
soft:
if (psfloat == P)
diag("floats used with _sfloat not defined");
if (!wasfloat || (p->mark&LABEL)) {
next = prg();
*next = *p;
// BL _sfloat(SB)
*p = zprg;
p->link = next;
p->as = ABL;
p->to.type = D_BRANCH;
p->to.sym = symsfloat;
p->cond = psfloat;
p->line = next->line;
p = next;
wasfloat = 1;
}
break;
notsoft:
wasfloat = 0;
}
}
}
}
This diff is collapsed.
...@@ -891,15 +891,3 @@ enum ...@@ -891,15 +891,3 @@ enum
* this is the ranlib header * this is the ranlib header
*/ */
#define SYMDEF "__.GOSYMDEF" #define SYMDEF "__.GOSYMDEF"
/*
* this is the simulated IEEE floating point
*/
typedef struct ieee Ieee;
struct ieee
{
int32 l; /* contains ls-man 0xffffffff */
int32 h; /* contains sign 0x80000000
exp 0x7ff00000
ms-man 0x000fffff */
};
This diff is collapsed.
This diff is collapsed.
...@@ -58,21 +58,21 @@ Pconv(Fmt *fp) ...@@ -58,21 +58,21 @@ Pconv(Fmt *fp)
case ATEXT: case ATEXT:
if(p->from.scale) { if(p->from.scale) {
fmtprint(fp, "(%d) %A %D,%d,%lD", fmtprint(fp, "(%d) %A %D,%d,%lD",
p->line, p->as, &p->from, p->from.scale, &p->to); p->lineno, p->as, &p->from, p->from.scale, &p->to);
break; break;
} }
fmtprint(fp, "(%d) %A %D,%lD", fmtprint(fp, "(%d) %A %D,%lD",
p->line, p->as, &p->from, &p->to); p->lineno, p->as, &p->from, &p->to);
break; break;
default: default:
fmtprint(fp, "(%d) %A %D,%D", fmtprint(fp, "(%d) %A %D,%D",
p->line, p->as, &p->from, &p->to); p->lineno, p->as, &p->from, &p->to);
break; break;
case ADATA: case ADATA:
case AINIT_: case AINIT_:
case ADYNT_: case ADYNT_:
fmtprint(fp, "(%d) %A %D/%d,%D", fmtprint(fp, "(%d) %A %D/%d,%D",
p->line, p->as, &p->from, p->from.scale, &p->to); p->lineno, p->as, &p->from, p->from.scale, &p->to);
break; break;
} }
bigP = P; bigP = P;
...@@ -85,17 +85,17 @@ Aconv(Fmt *fp) ...@@ -85,17 +85,17 @@ Aconv(Fmt *fp)
int i; int i;
i = va_arg(fp->args, int); i = va_arg(fp->args, int);
return fmtstrcpy(fp, anames[i]); return fmtstrcpy(fp, anames6[i]);
} }
int int
Dconv(Fmt *fp) Dconv(Fmt *fp)
{ {
char str[STRINGSZ], s[STRINGSZ]; char str[STRINGSZ], s[STRINGSZ];
Adr *a; Addr *a;
int i; int i;
a = va_arg(fp->args, Adr*); a = va_arg(fp->args, Addr*);
i = a->type; i = a->type;
if(fp->flags & FmtLong) { if(fp->flags & FmtLong) {
...@@ -182,11 +182,11 @@ Dconv(Fmt *fp) ...@@ -182,11 +182,11 @@ Dconv(Fmt *fp)
break; break;
case D_FCONST: case D_FCONST:
snprint(str, sizeof(str), "$(%.8ux,%.8ux)", a->ieee.h, a->ieee.l); snprint(str, sizeof(str), "$(%.17g)", a->u.dval);
break; break;
case D_SCONST: case D_SCONST:
snprint(str, sizeof(str), "$\"%S\"", a->scon); snprint(str, sizeof(str), "$\"%S\"", a->u.sval);
break; break;
case D_ADDR: case D_ADDR:
...@@ -431,8 +431,8 @@ diag(char *fmt, ...) ...@@ -431,8 +431,8 @@ diag(char *fmt, ...)
tn = ""; tn = "";
sep = ""; sep = "";
if(cursym != S) { if(ctxt->cursym != S) {
tn = cursym->name; tn = ctxt->cursym->name;
sep = ": "; sep = ": ";
} }
va_start(arg, fmt); va_start(arg, fmt);
......
This diff is collapsed.
This diff is collapsed.
...@@ -677,15 +677,3 @@ enum ...@@ -677,15 +677,3 @@ enum
* this is the ranlib header * this is the ranlib header
*/ */
#define SYMDEF "__.GOSYMDEF" #define SYMDEF "__.GOSYMDEF"
/*
* this is the simulated IEEE floating point
*/
typedef struct ieee Ieee;
struct ieee
{
int32 l; /* contains ls-man 0xffffffff */
int32 h; /* contains sign 0x80000000
exp 0x7ff00000
ms-man 0x000fffff */
};
This diff is collapsed.
This diff is collapsed.
...@@ -58,18 +58,18 @@ Pconv(Fmt *fp) ...@@ -58,18 +58,18 @@ Pconv(Fmt *fp)
case ATEXT: case ATEXT:
if(p->from.scale) { if(p->from.scale) {
fmtprint(fp, "(%d) %A %D,%d,%D", fmtprint(fp, "(%d) %A %D,%d,%D",
p->line, p->as, &p->from, p->from.scale, &p->to); p->lineno, p->as, &p->from, p->from.scale, &p->to);
break; break;
} }
default: default:
fmtprint(fp, "(%d) %A %D,%D", fmtprint(fp, "(%d) %A %D,%D",
p->line, p->as, &p->from, &p->to); p->lineno, p->as, &p->from, &p->to);
break; break;
case ADATA: case ADATA:
case AINIT_: case AINIT_:
case ADYNT_: case ADYNT_:
fmtprint(fp, "(%d) %A %D/%d,%D", fmtprint(fp, "(%d) %A %D/%d,%D",
p->line, p->as, &p->from, p->from.scale, &p->to); p->lineno, p->as, &p->from, p->from.scale, &p->to);
break; break;
} }
bigP = P; bigP = P;
...@@ -82,11 +82,11 @@ Aconv(Fmt *fp) ...@@ -82,11 +82,11 @@ Aconv(Fmt *fp)
int i; int i;
i = va_arg(fp->args, int); i = va_arg(fp->args, int);
return fmtstrcpy(fp, anames[i]); return fmtstrcpy(fp, anames8[i]);
} }
char* char*
xsymname(Sym *s) xsymname(LSym *s)
{ {
if(s == nil) if(s == nil)
return "!!noname!!"; return "!!noname!!";
...@@ -97,10 +97,10 @@ int ...@@ -97,10 +97,10 @@ int
Dconv(Fmt *fp) Dconv(Fmt *fp)
{ {
char str[STRINGSZ], s[STRINGSZ]; char str[STRINGSZ], s[STRINGSZ];
Adr *a; Addr *a;
int i; int i;
a = va_arg(fp->args, Adr*); a = va_arg(fp->args, Addr*);
i = a->type; i = a->type;
if(i >= D_INDIR && i < 2*D_INDIR) { if(i >= D_INDIR && i < 2*D_INDIR) {
if(a->offset) if(a->offset)
...@@ -159,11 +159,11 @@ Dconv(Fmt *fp) ...@@ -159,11 +159,11 @@ Dconv(Fmt *fp)
break; break;
case D_FCONST: case D_FCONST:
snprint(str, sizeof str, "$(%.8ux,%.8ux)", a->ieee.h, a->ieee.l); snprint(str, sizeof str, "$(%.17g)", a->u.dval);
break; break;
case D_SCONST: case D_SCONST:
snprint(str, sizeof str, "$\"%S\"", a->scon); snprint(str, sizeof str, "$\"%S\"", a->u.sval);
break; break;
case D_ADDR: case D_ADDR:
...@@ -361,8 +361,8 @@ diag(char *fmt, ...) ...@@ -361,8 +361,8 @@ diag(char *fmt, ...)
tn = ""; tn = "";
sep = ""; sep = "";
if(cursym != S) { if(ctxt->cursym != S) {
tn = cursym->name; tn = ctxt->cursym->name;
sep = ": "; sep = ": ";
} }
va_start(arg, fmt); va_start(arg, fmt);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -19,7 +19,7 @@ void dwarfemitdebugsections(void); ...@@ -19,7 +19,7 @@ void dwarfemitdebugsections(void);
* s[ection]h[eader]str[ing]tab. Prerequisite for * s[ection]h[eader]str[ing]tab. Prerequisite for
* dwarfaddelfheaders(). * dwarfaddelfheaders().
*/ */
void dwarfaddshstrings(Sym *shstrtab); void dwarfaddshstrings(LSym *shstrtab);
/* /*
* Add section headers pointing to the sections emitted in * Add section headers pointing to the sections emitted in
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -176,4 +176,4 @@ typedef struct { ...@@ -176,4 +176,4 @@ typedef struct {
IMAGE_DATA_DIRECTORY DataDirectory[16]; IMAGE_DATA_DIRECTORY DataDirectory[16];
} PE64_IMAGE_OPTIONAL_HEADER; } PE64_IMAGE_OPTIONAL_HEADER;
void setpersrc(Sym *sym); void setpersrc(LSym *sym);
This diff is collapsed.
This diff is collapsed.
# Copyright 2013 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 ../Make.dist
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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