summaryrefslogtreecommitdiff
path: root/src/cmd/5l
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/5l')
-rw-r--r--src/cmd/5l/5.out.h166
-rw-r--r--src/cmd/5l/asm.c75
-rw-r--r--src/cmd/5l/l.h76
-rw-r--r--src/cmd/5l/mkenam45
-rw-r--r--src/cmd/5l/noop.c43
-rw-r--r--src/cmd/5l/obj.c13
6 files changed, 137 insertions, 281 deletions
diff --git a/src/cmd/5l/5.out.h b/src/cmd/5l/5.out.h
index 9e8aceecb..7b16ac446 100644
--- a/src/cmd/5l/5.out.h
+++ b/src/cmd/5l/5.out.h
@@ -28,34 +28,94 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-#define NSNAME 8
-#define NSYM 50
-#define NREG 16
+enum
+{
+ NSNAME = 8,
+ NSYM = 50,
+ NREG = 16,
+};
#include "../ld/textflag.h"
-#define REGRET 0
/* -1 disables use of REGARG */
#define REGARG -1
-/* compiler allocates R1 up as temps */
-/* compiler allocates register variables R3 up */
-#define REGEXT 10
-/* these two registers are declared in runtime.h */
-#define REGG (REGEXT-0)
-#define REGM (REGEXT-1)
-/* compiler allocates external registers R10 down */
-#define REGTMP 11
-#define REGSP 13
-#define REGLINK 14
-#define REGPC 15
-
-#define NFREG 16
-#define FREGRET 0
-#define FREGEXT 7
-#define FREGTMP 15
+/*c2go enum { REGARG = -1 }; */
+
+enum
+{
+ REGRET = 0,
+ /* compiler allocates R1 up as temps */
+ /* compiler allocates register variables R3 up */
+ /* compiler allocates external registers R10 down */
+ REGEXT = 10,
+ /* these two registers are declared in runtime.h */
+ REGG = REGEXT-0,
+ REGM = REGEXT-1,
+
+ REGTMP = 11,
+ REGSP = 13,
+ REGLINK = 14,
+ REGPC = 15,
+
+ NFREG = 16,
+ FREGRET = 0,
+ FREGEXT = 7,
+ FREGTMP = 15,
+};
/* compiler allocates register variables F0 up */
/* compiler allocates external registers F7 down */
-enum as
+enum
+{
+ C_NONE,
+ C_REG,
+ C_REGREG,
+ C_REGREG2,
+ C_SHIFT,
+ C_FREG,
+ C_PSR,
+ C_FCR,
+
+ C_RCON, /* 0xff rotated */
+ C_NCON, /* ~RCON */
+ C_SCON, /* 0xffff */
+ C_LCON,
+ C_LCONADDR,
+ C_ZFCON,
+ C_SFCON,
+ C_LFCON,
+
+ C_RACON,
+ C_LACON,
+
+ C_SBRA,
+ C_LBRA,
+
+ C_HAUTO, /* halfword insn offset (-0xff to 0xff) */
+ C_FAUTO, /* float insn offset (0 to 0x3fc, word aligned) */
+ C_HFAUTO, /* both H and F */
+ C_SAUTO, /* -0xfff to 0xfff */
+ C_LAUTO,
+
+ C_HOREG,
+ C_FOREG,
+ C_HFOREG,
+ C_SOREG,
+ C_ROREG,
+ C_SROREG, /* both nil and R */
+ C_LOREG,
+
+ C_PC,
+ C_SP,
+ C_HREG,
+
+ C_ADDR, /* reference to relocatable address */
+
+ C_GOK,
+
+ C_NCLASS, /* must be the last */
+};
+
+enum
{
AXXX,
@@ -202,6 +262,8 @@ enum as
AVARKILL,
ADUFFCOPY,
ADUFFZERO,
+ ADATABUNDLE,
+ ADATABUNDLEEND,
AMRC, // MRC/MCR
@@ -209,35 +271,38 @@ enum as
};
/* scond byte */
-#define C_SCOND ((1<<4)-1)
-#define C_SBIT (1<<4)
-#define C_PBIT (1<<5)
-#define C_WBIT (1<<6)
-#define C_FBIT (1<<7) /* psr flags-only */
-#define C_UBIT (1<<7) /* up bit, unsigned bit */
-
-#define C_SCOND_EQ 0
-#define C_SCOND_NE 1
-#define C_SCOND_HS 2
-#define C_SCOND_LO 3
-#define C_SCOND_MI 4
-#define C_SCOND_PL 5
-#define C_SCOND_VS 6
-#define C_SCOND_VC 7
-#define C_SCOND_HI 8
-#define C_SCOND_LS 9
-#define C_SCOND_GE 10
-#define C_SCOND_LT 11
-#define C_SCOND_GT 12
-#define C_SCOND_LE 13
-#define C_SCOND_NONE 14
-#define C_SCOND_NV 15
-
-/* D_SHIFT type */
-#define SHIFT_LL 0<<5
-#define SHIFT_LR 1<<5
-#define SHIFT_AR 2<<5
-#define SHIFT_RR 3<<5
+enum
+{
+ C_SCOND = (1<<4)-1,
+ C_SBIT = 1<<4,
+ C_PBIT = 1<<5,
+ C_WBIT = 1<<6,
+ C_FBIT = 1<<7, /* psr flags-only */
+ C_UBIT = 1<<7, /* up bit, unsigned bit */
+
+ C_SCOND_EQ = 0,
+ C_SCOND_NE = 1,
+ C_SCOND_HS = 2,
+ C_SCOND_LO = 3,
+ C_SCOND_MI = 4,
+ C_SCOND_PL = 5,
+ C_SCOND_VS = 6,
+ C_SCOND_VC = 7,
+ C_SCOND_HI = 8,
+ C_SCOND_LS = 9,
+ C_SCOND_GE = 10,
+ C_SCOND_LT = 11,
+ C_SCOND_GT = 12,
+ C_SCOND_LE = 13,
+ C_SCOND_NONE = 14,
+ C_SCOND_NV = 15,
+
+ /* D_SHIFT type */
+ SHIFT_LL = 0<<5,
+ SHIFT_LR = 1<<5,
+ SHIFT_AR = 2<<5,
+ SHIFT_RR = 3<<5,
+};
enum
{
@@ -279,3 +344,4 @@ enum
* this is the ranlib header
*/
#define SYMDEF "__.GOSYMDEF"
+/*c2go extern char SYMDEF[]; */
diff --git a/src/cmd/5l/asm.c b/src/cmd/5l/asm.c
index e87921218..9c1c04e2d 100644
--- a/src/cmd/5l/asm.c
+++ b/src/cmd/5l/asm.c
@@ -648,19 +648,20 @@ asmb(void)
switch(HEADTYPE) {
default:
case Hplan9: /* plan 9 */
- lput(0x647); /* magic */
- lput(segtext.filelen); /* sizes */
- lput(segdata.filelen);
- lput(segdata.len - segdata.filelen);
- lput(symsize); /* nsyms */
- lput(entryvalue()); /* va of entry */
- lput(0L);
- lput(lcsize);
+ LPUT(0x647); /* magic */
+ LPUT(segtext.filelen); /* sizes */
+ LPUT(segdata.filelen);
+ LPUT(segdata.len - segdata.filelen);
+ LPUT(symsize); /* nsyms */
+ LPUT(entryvalue()); /* va of entry */
+ LPUT(0L);
+ LPUT(lcsize);
break;
case Hlinux:
case Hfreebsd:
case Hnetbsd:
case Hopenbsd:
+ case Hnacl:
asmbelf(symo);
break;
}
@@ -675,64 +676,6 @@ asmb(void)
}
}
-/*
-void
-cput(int32 c)
-{
- *cbp++ = c;
- if(--cbc <= 0)
- cflush();
-}
-*/
-
-void
-wput(int32 l)
-{
-
- cbp[0] = l>>8;
- cbp[1] = l;
- cbp += 2;
- cbc -= 2;
- if(cbc <= 0)
- cflush();
-}
-
-
-void
-hput(int32 l)
-{
-
- cbp[0] = l>>8;
- cbp[1] = l;
- cbp += 2;
- cbc -= 2;
- if(cbc <= 0)
- cflush();
-}
-
-void
-lput(int32 l)
-{
-
- cbp[0] = l>>24;
- cbp[1] = l>>16;
- cbp[2] = l>>8;
- cbp[3] = l;
- cbp += 4;
- cbc -= 4;
- if(cbc <= 0)
- cflush();
-}
-
-void
-nopstat(char *f, Count *c)
-{
- if(c->outof)
- Bprint(&bso, "%s delay %d/%d (%.2f)\n", f,
- c->outof - c->count, c->outof,
- (double)(c->outof - c->count)/c->outof);
-}
-
int32
rnd(int32 v, int32 r)
{
diff --git a/src/cmd/5l/l.h b/src/cmd/5l/l.h
index 761bc861a..c881a544a 100644
--- a/src/cmd/5l/l.h
+++ b/src/cmd/5l/l.h
@@ -48,23 +48,8 @@ enum
#define EXTERN extern
#endif
-/* do not undefine this - code will be removed eventually */
-#define CALLEEBX
-
-#define dynptrsize 0
-
#define P ((Prog*)0)
#define S ((LSym*)0)
-#define TNAME (ctxt->cursym?ctxt->cursym->name:noname)
-
-#define SIGNINTERN (1729*325*1729)
-
-typedef struct Count Count;
-struct Count
-{
- int32 count;
- int32 outof;
-};
enum
{
@@ -73,62 +58,9 @@ enum
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,
-
- C_NONE = 0,
- C_REG,
- C_REGREG,
- C_REGREG2,
- C_SHIFT,
- C_FREG,
- C_PSR,
- C_FCR,
-
- C_RCON, /* 0xff rotated */
- C_NCON, /* ~RCON */
- C_SCON, /* 0xffff */
- C_LCON,
- C_LCONADDR,
- C_ZFCON,
- C_SFCON,
- C_LFCON,
-
- C_RACON,
- C_LACON,
-
- C_SBRA,
- C_LBRA,
-
- C_HAUTO, /* halfword insn offset (-0xff to 0xff) */
- C_FAUTO, /* float insn offset (0 to 0x3fc, word aligned) */
- C_HFAUTO, /* both H and F */
- C_SAUTO, /* -0xfff to 0xfff */
- C_LAUTO,
-
- C_HOREG,
- C_FOREG,
- C_HFOREG,
- C_SOREG,
- C_ROREG,
- C_SROREG, /* both nil and R */
- C_LOREG,
-
- C_PC,
- C_SP,
- C_HREG,
-
- C_ADDR, /* reference to relocatable address */
-
- C_GOK,
};
-#ifndef COFFCVT
-
EXTERN int32 autosize;
EXTERN LSym* datap;
EXTERN int debug[128];
@@ -152,26 +84,18 @@ 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 cput(int32 c);
int elfreloc1(Reloc *r, vlong sectoff);
void elfsetupplt(void);
-void hput(int32 l);
void listinit(void);
-void lput(int32 l);
int machoreloc1(Reloc *r, vlong sectoff);
void main(int argc, char *argv[]);
-void noops(void);
-void nopstat(char *f, Count *c);
int32 rnd(int32 v, int32 r);
-void wput(int32 l);
/* Native is little-endian */
#define LPUT(a) lputl(a)
#define WPUT(a) wputl(a)
#define VPUT(a) abort()
-#endif
-
/* Used by ../ld/dwarf.c */
enum
{
diff --git a/src/cmd/5l/mkenam b/src/cmd/5l/mkenam
deleted file mode 100644
index 6cccb0263..000000000
--- a/src/cmd/5l/mkenam
+++ /dev/null
@@ -1,45 +0,0 @@
-# Inferno utils/5c/mkenam
-# http://code.google.com/p/inferno-os/source/browse/utils/5c/mkenam
-#
-# 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.
-
-awk '
-BEGIN {
- print "char* anames[] ="
- print "{"
-}
-
-/^ A/ {
- name=$1
- sub(/,/, "", name)
- sub(/^A/, "", name)
- print "\t\"" name "\","
-}
-
-END { print "};" }
-' ../5l/5.out.h >enam.c
diff --git a/src/cmd/5l/noop.c b/src/cmd/5l/noop.c
deleted file mode 100644
index d42c86289..000000000
--- a/src/cmd/5l/noop.c
+++ /dev/null
@@ -1,43 +0,0 @@
-// Inferno utils/5l/noop.c
-// http://code.google.com/p/inferno-os/source/browse/utils/5l/noop.c
-//
-// 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.
-
-// Code transformations.
-
-#include "l.h"
-#include "../ld/lib.h"
-
-void
-noops(void)
-{
- LSym *s;
-
- for(s = ctxt->textp; s != nil; s = s->next)
- ctxt->arch->addstacksplit(ctxt, s);
-}
diff --git a/src/cmd/5l/obj.c b/src/cmd/5l/obj.c
index 86a0ece2e..c6f60ee7c 100644
--- a/src/cmd/5l/obj.c
+++ b/src/cmd/5l/obj.c
@@ -63,6 +63,7 @@ archinit(void)
break;
case Hlinux:
case Hfreebsd:
+ case Hnacl:
break;
}
@@ -82,7 +83,6 @@ archinit(void)
case Hlinux: /* arm elf */
case Hfreebsd:
case Hnetbsd:
- case Hnacl:
debug['d'] = 0; // with dynamic linking
elfinit();
HEADR = ELFRESERVE;
@@ -93,6 +93,17 @@ archinit(void)
if(INITRND == -1)
INITRND = 4096;
break;
+ case Hnacl:
+ elfinit();
+ HEADR = 0x10000;
+ funcalign = 16;
+ if(INITTEXT == -1)
+ INITTEXT = 0x20000;
+ if(INITDAT == -1)
+ INITDAT = 0;
+ if(INITRND == -1)
+ INITRND = 0x10000;
+ break;
}
if(INITDAT != 0 && INITRND != 0)
print("warning: -D0x%ux is ignored because of -R0x%ux\n",