1
0
mirror of https://github.com/golang/go synced 2024-11-22 04:34:39 -07:00

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
This commit is contained in:
Joel Sing 2013-08-24 01:18:04 +10:00
parent 180da80e90
commit 71dc91db0f
15 changed files with 98 additions and 16 deletions

View File

@ -43,6 +43,7 @@ char linuxdynld[] = "/lib64/ld-linux-x86-64.so.2";
char freebsddynld[] = "/libexec/ld-elf.so.1";
char openbsddynld[] = "/usr/libexec/ld.so";
char netbsddynld[] = "/libexec/ld.elf_so";
char dragonflydynld[] = "/libexec/ld-elf.so.2";
char zeroes[32];
@ -672,6 +673,7 @@ asmb(void)
case Hfreebsd:
case Hnetbsd:
case Hopenbsd:
case Hdragonfly:
debug['8'] = 1; /* 64-bit addresses */
break;
case Hwindows:
@ -700,6 +702,7 @@ asmb(void)
case Hfreebsd:
case Hnetbsd:
case Hopenbsd:
case Hdragonfly:
symo = rnd(HEADR+segtext.len, INITRND)+rnd(segrodata.len, INITRND)+segdata.filelen;
symo = rnd(symo, INITRND);
break;
@ -790,6 +793,7 @@ asmb(void)
case Hfreebsd:
case Hnetbsd:
case Hopenbsd:
case Hdragonfly:
asmbelf(symo);
break;
case Hwindows:

View File

@ -48,6 +48,7 @@ Header headers[] = {
"plan9", Hplan9x64,
"elf", Helf,
"darwin", Hdarwin,
"dragonfly", Hdragonfly,
"linux", Hlinux,
"freebsd", Hfreebsd,
"netbsd", Hnetbsd,
@ -62,6 +63,7 @@ Header headers[] = {
* -Hplan9 -T0x200028 -R0x200000 is plan9 64-bit format
* -Helf -T0x80110000 -R4096 is ELF32
* -Hdarwin -Tx -Rx is apple MH-exec
* -Hdragonfly -Tx -Rx is DragonFly elf-exec
* -Hlinux -Tx -Rx is linux elf-exec
* -Hfreebsd -Tx -Rx is FreeBSD elf-exec
* -Hnetbsd -Tx -Rx is NetBSD elf-exec
@ -170,7 +172,7 @@ main(int argc, char *argv[])
default:
diag("unknown -H option");
errorexit();
case Hplan9x32: /* plan 9 */
case Hplan9x32: /* plan 9 */
HEADR = 32L;
if(INITTEXT == -1)
INITTEXT = 4096+HEADR;
@ -179,7 +181,7 @@ main(int argc, char *argv[])
if(INITRND == -1)
INITRND = 4096;
break;
case Hplan9x64: /* plan 9 */
case Hplan9x64: /* plan 9 */
HEADR = 32L + 8L;
if(INITTEXT == -1)
INITTEXT = 0x200000+HEADR;
@ -188,7 +190,7 @@ main(int argc, char *argv[])
if(INITRND == -1)
INITRND = 0x200000;
break;
case Helf: /* elf32 executable */
case Helf: /* elf32 executable */
HEADR = rnd(52L+3*32L, 16);
if(INITTEXT == -1)
INITTEXT = 0x80110000L;
@ -197,7 +199,7 @@ main(int argc, char *argv[])
if(INITRND == -1)
INITRND = 4096;
break;
case Hdarwin: /* apple MACH */
case Hdarwin: /* apple MACH */
/*
* OS X system constant - offset from 0(GS) to our TLS.
* Explained in ../../pkg/runtime/cgo/gcc_darwin_amd64.c.
@ -212,10 +214,11 @@ main(int argc, char *argv[])
if(INITDAT == -1)
INITDAT = 0;
break;
case Hlinux: /* elf64 executable */
case Hfreebsd: /* freebsd */
case Hnetbsd: /* netbsd */
case Hopenbsd: /* openbsd */
case Hlinux: /* elf64 executable */
case Hfreebsd: /* freebsd */
case Hnetbsd: /* netbsd */
case Hopenbsd: /* openbsd */
case Hdragonfly: /* dragonfly */
/*
* ELF uses TLS offset negative from FS.
* Translate 0(FS) and 8(FS) into -16(FS) and -8(FS).
@ -232,7 +235,7 @@ main(int argc, char *argv[])
if(INITRND == -1)
INITRND = 4096;
break;
case Hwindows: /* PE executable */
case Hwindows: /* PE executable */
peinit();
HEADR = PEFILEHEADR;
if(INITTEXT == -1)

View File

@ -322,7 +322,7 @@ patch(void)
}
if(HEADTYPE == Hlinux || HEADTYPE == Hfreebsd
|| HEADTYPE == Hopenbsd || HEADTYPE == Hnetbsd
|| HEADTYPE == Hplan9x64) {
|| HEADTYPE == Hplan9x64 || HEADTYPE == Hdragonfly) {
// ELF uses FS instead of GS.
if(p->from.type == D_INDIR+D_GS)
p->from.type = D_INDIR+D_FS;
@ -522,7 +522,8 @@ dostkoff(void)
p->as = AMOVQ;
if(HEADTYPE == Hlinux || HEADTYPE == Hfreebsd
|| HEADTYPE == Hopenbsd || HEADTYPE == Hnetbsd
|| HEADTYPE == Hplan9x64) // ELF uses FS
|| HEADTYPE == Hplan9x64 || HEADTYPE == Hdragonfly)
// ELF uses FS
p->from.type = D_INDIR+D_FS;
else
p->from.type = D_INDIR+D_GS;

View File

@ -48,6 +48,7 @@ static char *okgoarch[] = {
// The known operating systems.
static char *okgoos[] = {
"darwin",
"dragonfly",
"linux",
"freebsd",
"netbsd",

2
src/cmd/dist/unix.c vendored
View File

@ -674,6 +674,8 @@ main(int argc, char **argv)
gohostarch = "amd64";
#elif defined(__linux__)
gohostos = "linux";
#elif defined(__DragonFly__)
gohostos = "dragonfly";
#elif defined(__FreeBSD__)
gohostos = "freebsd";
#elif defined(__FreeBSD_kernel__)

View File

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build darwin freebsd linux netbsd openbsd
// +build darwin dragonfly freebsd linux netbsd openbsd
package main

View File

@ -33,6 +33,8 @@ Options new in this version:
linker. This flag cannot be used when $GOOS is windows.
-H darwin (only in 6l/8l)
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
Write Linux ELF binaries (default when $GOOS is linux)
-H freebsd

View File

@ -1189,6 +1189,9 @@ asmbelf(vlong symo)
case Hopenbsd:
interpreter = openbsddynld;
break;
case Hdragonfly:
interpreter = dragonflydynld;
break;
}
}
resoff -= elfinterp(sh, startva, resoff, interpreter);
@ -1461,6 +1464,8 @@ elfobj:
eh->ident[EI_OSABI] = ELFOSABI_NETBSD;
else if(HEADTYPE == Hopenbsd)
eh->ident[EI_OSABI] = ELFOSABI_OPENBSD;
else if(HEADTYPE == Hdragonfly)
eh->ident[EI_OSABI] = ELFOSABI_NONE;
if(PtrSize == 8)
eh->ident[EI_CLASS] = ELFCLASS64;
else

View File

@ -1009,6 +1009,7 @@ extern char linuxdynld[];
extern char freebsddynld[];
extern char netbsddynld[];
extern char openbsddynld[];
extern char dragonflydynld[];
int elfreloc1(Reloc*, vlong sectoff);
void putelfsectionsyms(void);

View File

@ -344,6 +344,7 @@ enum {
Hfreebsd, // FreeBSD ELF
Hwindows, // MS Windows PE
Hopenbsd, // OpenBSD ELF
Hdragonfly, // DragonFly ELF
};
typedef struct Header Header;

View File

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// 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 <errno.h>

View File

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// 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 <dirent.h>

62
src/libmach/dragonfly.c Normal file
View File

@ -0,0 +1,62 @@
// 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;
}

View File

@ -356,7 +356,7 @@ func allowed(pkg string) map[string]bool {
}
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"}
type osPkg struct {

View File

@ -4,5 +4,5 @@
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 "