Commit 71dc91db authored by Joel Sing's avatar Joel Sing

all: compiler/bootstrap for dragonfly/amd64

Add dragonfly/amd64 support to the Go compiler, bootstrap and GOOS list.

R=devon.odell, bradfitz
CC=golang-dev
https://golang.org/cl/12796050
parent 180da80e
...@@ -43,6 +43,7 @@ char linuxdynld[] = "/lib64/ld-linux-x86-64.so.2"; ...@@ -43,6 +43,7 @@ char linuxdynld[] = "/lib64/ld-linux-x86-64.so.2";
char freebsddynld[] = "/libexec/ld-elf.so.1"; char freebsddynld[] = "/libexec/ld-elf.so.1";
char openbsddynld[] = "/usr/libexec/ld.so"; char openbsddynld[] = "/usr/libexec/ld.so";
char netbsddynld[] = "/libexec/ld.elf_so"; char netbsddynld[] = "/libexec/ld.elf_so";
char dragonflydynld[] = "/libexec/ld-elf.so.2";
char zeroes[32]; char zeroes[32];
...@@ -672,6 +673,7 @@ asmb(void) ...@@ -672,6 +673,7 @@ asmb(void)
case Hfreebsd: case Hfreebsd:
case Hnetbsd: case Hnetbsd:
case Hopenbsd: case Hopenbsd:
case Hdragonfly:
debug['8'] = 1; /* 64-bit addresses */ debug['8'] = 1; /* 64-bit addresses */
break; break;
case Hwindows: case Hwindows:
...@@ -700,6 +702,7 @@ asmb(void) ...@@ -700,6 +702,7 @@ asmb(void)
case Hfreebsd: case Hfreebsd:
case Hnetbsd: case Hnetbsd:
case Hopenbsd: case Hopenbsd:
case Hdragonfly:
symo = rnd(HEADR+segtext.len, INITRND)+rnd(segrodata.len, INITRND)+segdata.filelen; symo = rnd(HEADR+segtext.len, INITRND)+rnd(segrodata.len, INITRND)+segdata.filelen;
symo = rnd(symo, INITRND); symo = rnd(symo, INITRND);
break; break;
...@@ -790,6 +793,7 @@ asmb(void) ...@@ -790,6 +793,7 @@ asmb(void)
case Hfreebsd: case Hfreebsd:
case Hnetbsd: case Hnetbsd:
case Hopenbsd: case Hopenbsd:
case Hdragonfly:
asmbelf(symo); asmbelf(symo);
break; break;
case Hwindows: case Hwindows:
......
...@@ -48,6 +48,7 @@ Header headers[] = { ...@@ -48,6 +48,7 @@ Header headers[] = {
"plan9", Hplan9x64, "plan9", Hplan9x64,
"elf", Helf, "elf", Helf,
"darwin", Hdarwin, "darwin", Hdarwin,
"dragonfly", Hdragonfly,
"linux", Hlinux, "linux", Hlinux,
"freebsd", Hfreebsd, "freebsd", Hfreebsd,
"netbsd", Hnetbsd, "netbsd", Hnetbsd,
...@@ -62,6 +63,7 @@ Header headers[] = { ...@@ -62,6 +63,7 @@ Header headers[] = {
* -Hplan9 -T0x200028 -R0x200000 is plan9 64-bit format * -Hplan9 -T0x200028 -R0x200000 is plan9 64-bit format
* -Helf -T0x80110000 -R4096 is ELF32 * -Helf -T0x80110000 -R4096 is ELF32
* -Hdarwin -Tx -Rx is apple MH-exec * -Hdarwin -Tx -Rx is apple MH-exec
* -Hdragonfly -Tx -Rx is DragonFly elf-exec
* -Hlinux -Tx -Rx is linux elf-exec * -Hlinux -Tx -Rx is linux elf-exec
* -Hfreebsd -Tx -Rx is FreeBSD elf-exec * -Hfreebsd -Tx -Rx is FreeBSD elf-exec
* -Hnetbsd -Tx -Rx is NetBSD elf-exec * -Hnetbsd -Tx -Rx is NetBSD elf-exec
...@@ -170,7 +172,7 @@ main(int argc, char *argv[]) ...@@ -170,7 +172,7 @@ main(int argc, char *argv[])
default: default:
diag("unknown -H option"); diag("unknown -H option");
errorexit(); errorexit();
case Hplan9x32: /* plan 9 */ case Hplan9x32: /* plan 9 */
HEADR = 32L; HEADR = 32L;
if(INITTEXT == -1) if(INITTEXT == -1)
INITTEXT = 4096+HEADR; INITTEXT = 4096+HEADR;
...@@ -179,7 +181,7 @@ main(int argc, char *argv[]) ...@@ -179,7 +181,7 @@ main(int argc, char *argv[])
if(INITRND == -1) if(INITRND == -1)
INITRND = 4096; INITRND = 4096;
break; break;
case Hplan9x64: /* plan 9 */ case Hplan9x64: /* plan 9 */
HEADR = 32L + 8L; HEADR = 32L + 8L;
if(INITTEXT == -1) if(INITTEXT == -1)
INITTEXT = 0x200000+HEADR; INITTEXT = 0x200000+HEADR;
...@@ -188,7 +190,7 @@ main(int argc, char *argv[]) ...@@ -188,7 +190,7 @@ main(int argc, char *argv[])
if(INITRND == -1) if(INITRND == -1)
INITRND = 0x200000; INITRND = 0x200000;
break; break;
case Helf: /* elf32 executable */ case Helf: /* elf32 executable */
HEADR = rnd(52L+3*32L, 16); HEADR = rnd(52L+3*32L, 16);
if(INITTEXT == -1) if(INITTEXT == -1)
INITTEXT = 0x80110000L; INITTEXT = 0x80110000L;
...@@ -197,7 +199,7 @@ main(int argc, char *argv[]) ...@@ -197,7 +199,7 @@ main(int argc, char *argv[])
if(INITRND == -1) if(INITRND == -1)
INITRND = 4096; INITRND = 4096;
break; break;
case Hdarwin: /* apple MACH */ case Hdarwin: /* apple MACH */
/* /*
* OS X system constant - offset from 0(GS) to our TLS. * OS X system constant - offset from 0(GS) to our TLS.
* Explained in ../../pkg/runtime/cgo/gcc_darwin_amd64.c. * Explained in ../../pkg/runtime/cgo/gcc_darwin_amd64.c.
...@@ -212,10 +214,11 @@ main(int argc, char *argv[]) ...@@ -212,10 +214,11 @@ main(int argc, char *argv[])
if(INITDAT == -1) if(INITDAT == -1)
INITDAT = 0; INITDAT = 0;
break; break;
case Hlinux: /* elf64 executable */ case Hlinux: /* elf64 executable */
case Hfreebsd: /* freebsd */ case Hfreebsd: /* freebsd */
case Hnetbsd: /* netbsd */ case Hnetbsd: /* netbsd */
case Hopenbsd: /* openbsd */ case Hopenbsd: /* openbsd */
case Hdragonfly: /* dragonfly */
/* /*
* ELF uses TLS offset negative from FS. * ELF uses TLS offset negative from FS.
* Translate 0(FS) and 8(FS) into -16(FS) and -8(FS). * Translate 0(FS) and 8(FS) into -16(FS) and -8(FS).
...@@ -232,7 +235,7 @@ main(int argc, char *argv[]) ...@@ -232,7 +235,7 @@ main(int argc, char *argv[])
if(INITRND == -1) if(INITRND == -1)
INITRND = 4096; INITRND = 4096;
break; break;
case Hwindows: /* PE executable */ case Hwindows: /* PE executable */
peinit(); peinit();
HEADR = PEFILEHEADR; HEADR = PEFILEHEADR;
if(INITTEXT == -1) if(INITTEXT == -1)
......
...@@ -322,7 +322,7 @@ patch(void) ...@@ -322,7 +322,7 @@ patch(void)
} }
if(HEADTYPE == Hlinux || HEADTYPE == Hfreebsd if(HEADTYPE == Hlinux || HEADTYPE == Hfreebsd
|| HEADTYPE == Hopenbsd || HEADTYPE == Hnetbsd || HEADTYPE == Hopenbsd || HEADTYPE == Hnetbsd
|| HEADTYPE == Hplan9x64) { || HEADTYPE == Hplan9x64 || HEADTYPE == Hdragonfly) {
// ELF uses FS instead of GS. // ELF uses FS instead of GS.
if(p->from.type == D_INDIR+D_GS) if(p->from.type == D_INDIR+D_GS)
p->from.type = D_INDIR+D_FS; p->from.type = D_INDIR+D_FS;
...@@ -522,7 +522,8 @@ dostkoff(void) ...@@ -522,7 +522,8 @@ dostkoff(void)
p->as = AMOVQ; p->as = AMOVQ;
if(HEADTYPE == Hlinux || HEADTYPE == Hfreebsd if(HEADTYPE == Hlinux || HEADTYPE == Hfreebsd
|| HEADTYPE == Hopenbsd || HEADTYPE == Hnetbsd || HEADTYPE == Hopenbsd || HEADTYPE == Hnetbsd
|| HEADTYPE == Hplan9x64) // ELF uses FS || HEADTYPE == Hplan9x64 || HEADTYPE == Hdragonfly)
// ELF uses FS
p->from.type = D_INDIR+D_FS; p->from.type = D_INDIR+D_FS;
else else
p->from.type = D_INDIR+D_GS; p->from.type = D_INDIR+D_GS;
......
...@@ -48,6 +48,7 @@ static char *okgoarch[] = { ...@@ -48,6 +48,7 @@ static char *okgoarch[] = {
// The known operating systems. // The known operating systems.
static char *okgoos[] = { static char *okgoos[] = {
"darwin", "darwin",
"dragonfly",
"linux", "linux",
"freebsd", "freebsd",
"netbsd", "netbsd",
......
...@@ -674,6 +674,8 @@ main(int argc, char **argv) ...@@ -674,6 +674,8 @@ main(int argc, char **argv)
gohostarch = "amd64"; gohostarch = "amd64";
#elif defined(__linux__) #elif defined(__linux__)
gohostos = "linux"; gohostos = "linux";
#elif defined(__DragonFly__)
gohostos = "dragonfly";
#elif defined(__FreeBSD__) #elif defined(__FreeBSD__)
gohostos = "freebsd"; gohostos = "freebsd";
#elif defined(__FreeBSD_kernel__) #elif defined(__FreeBSD_kernel__)
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// +build darwin freebsd linux netbsd openbsd // +build darwin dragonfly freebsd linux netbsd openbsd
package main package main
......
...@@ -33,6 +33,8 @@ Options new in this version: ...@@ -33,6 +33,8 @@ Options new in this version:
linker. This flag cannot be used when $GOOS is windows. linker. This flag cannot be used when $GOOS is windows.
-H darwin (only in 6l/8l) -H darwin (only in 6l/8l)
Write Apple Mach-O binaries (default when $GOOS is darwin) Write Apple Mach-O binaries (default when $GOOS is darwin)
-H dragonfly (only in 6l)
Write DragonFly ELF binaries (default when $GOOS is dragonfly)
-H linux -H linux
Write Linux ELF binaries (default when $GOOS is linux) Write Linux ELF binaries (default when $GOOS is linux)
-H freebsd -H freebsd
......
...@@ -1189,6 +1189,9 @@ asmbelf(vlong symo) ...@@ -1189,6 +1189,9 @@ asmbelf(vlong symo)
case Hopenbsd: case Hopenbsd:
interpreter = openbsddynld; interpreter = openbsddynld;
break; break;
case Hdragonfly:
interpreter = dragonflydynld;
break;
} }
} }
resoff -= elfinterp(sh, startva, resoff, interpreter); resoff -= elfinterp(sh, startva, resoff, interpreter);
...@@ -1461,6 +1464,8 @@ elfobj: ...@@ -1461,6 +1464,8 @@ elfobj:
eh->ident[EI_OSABI] = ELFOSABI_NETBSD; eh->ident[EI_OSABI] = ELFOSABI_NETBSD;
else if(HEADTYPE == Hopenbsd) else if(HEADTYPE == Hopenbsd)
eh->ident[EI_OSABI] = ELFOSABI_OPENBSD; eh->ident[EI_OSABI] = ELFOSABI_OPENBSD;
else if(HEADTYPE == Hdragonfly)
eh->ident[EI_OSABI] = ELFOSABI_NONE;
if(PtrSize == 8) if(PtrSize == 8)
eh->ident[EI_CLASS] = ELFCLASS64; eh->ident[EI_CLASS] = ELFCLASS64;
else else
......
...@@ -1009,6 +1009,7 @@ extern char linuxdynld[]; ...@@ -1009,6 +1009,7 @@ extern char linuxdynld[];
extern char freebsddynld[]; extern char freebsddynld[];
extern char netbsddynld[]; extern char netbsddynld[];
extern char openbsddynld[]; extern char openbsddynld[];
extern char dragonflydynld[];
int elfreloc1(Reloc*, vlong sectoff); int elfreloc1(Reloc*, vlong sectoff);
void putelfsectionsyms(void); void putelfsectionsyms(void);
......
...@@ -344,6 +344,7 @@ enum { ...@@ -344,6 +344,7 @@ enum {
Hfreebsd, // FreeBSD ELF Hfreebsd, // FreeBSD ELF
Hwindows, // MS Windows PE Hwindows, // MS Windows PE
Hopenbsd, // OpenBSD ELF Hopenbsd, // OpenBSD ELF
Hdragonfly, // DragonFly ELF
}; };
typedef struct Header Header; typedef struct Header Header;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// +build darwin freebsd linux netbsd openbsd // +build darwin dragonfly freebsd linux netbsd openbsd
#include <u.h> #include <u.h>
#include <errno.h> #include <errno.h>
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// +build darwin freebsd linux netbsd openbsd // +build darwin dragonfly freebsd linux netbsd openbsd
#include <u.h> #include <u.h>
#include <dirent.h> #include <dirent.h>
......
// This is stubbed out for the moment. Will revisit when the time comes.
#include <u.h>
#include <libc.h>
#include <bio.h>
#include <mach.h>
int
ctlproc(int pid, char *msg)
{
USED(pid);
USED(msg);
sysfatal("ctlproc unimplemented in DragonFly");
return -1;
}
char*
proctextfile(int pid)
{
USED(pid);
sysfatal("proctextfile unimplemented in DragonFly");
return nil;
}
char*
procstatus(int pid)
{
USED(pid);
sysfatal("procstatus unimplemented in DragonFly");
return nil;
}
Map*
attachproc(int pid, Fhdr *fp)
{
USED(pid);
USED(fp);
sysfatal("attachproc unimplemented in DragonFly");
return nil;
}
void
detachproc(Map *m)
{
USED(m);
sysfatal("detachproc unimplemented in DragonFly");
}
int
procthreadpids(int pid, int *p, int np)
{
USED(pid);
USED(p);
USED(np);
sysfatal("procthreadpids unimplemented in DragonFly");
return -1;
}
...@@ -356,7 +356,7 @@ func allowed(pkg string) map[string]bool { ...@@ -356,7 +356,7 @@ func allowed(pkg string) map[string]bool {
} }
var bools = []bool{false, true} var bools = []bool{false, true}
var geese = []string{"darwin", "freebsd", "linux", "netbsd", "openbsd", "plan9", "windows"} var geese = []string{"darwin", "dragonfly", "freebsd", "linux", "netbsd", "openbsd", "plan9", "windows"}
var goarches = []string{"386", "amd64", "arm"} var goarches = []string{"386", "amd64", "arm"}
type osPkg struct { type osPkg struct {
......
...@@ -4,5 +4,5 @@ ...@@ -4,5 +4,5 @@
package build package build
const goosList = "darwin freebsd linux netbsd openbsd plan9 windows " const goosList = "darwin dragonfly freebsd linux netbsd openbsd plan9 windows "
const goarchList = "386 amd64 arm " const goarchList = "386 amd64 arm "
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