mirror of
https://github.com/golang/go
synced 2024-11-25 02:07:58 -07:00
6l: OpenBSD support
Add linker support for OpenBSD ELF-64. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/4815066
This commit is contained in:
parent
91f0f18100
commit
ffa14e849c
@ -43,6 +43,7 @@
|
|||||||
|
|
||||||
char linuxdynld[] = "/lib64/ld-linux-x86-64.so.2";
|
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 zeroes[32];
|
char zeroes[32];
|
||||||
|
|
||||||
@ -554,7 +555,7 @@ doelf(void)
|
|||||||
{
|
{
|
||||||
Sym *s, *shstrtab, *dynstr;
|
Sym *s, *shstrtab, *dynstr;
|
||||||
|
|
||||||
if(HEADTYPE != Hlinux && HEADTYPE != Hfreebsd)
|
if(HEADTYPE != Hlinux && HEADTYPE != Hfreebsd && HEADTYPE != Hopenbsd)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* predefine strings we need for section headers */
|
/* predefine strings we need for section headers */
|
||||||
@ -746,6 +747,7 @@ asmb(void)
|
|||||||
break;
|
break;
|
||||||
case Hlinux:
|
case Hlinux:
|
||||||
case Hfreebsd:
|
case Hfreebsd:
|
||||||
|
case Hopenbsd:
|
||||||
debug['8'] = 1; /* 64-bit addresses */
|
debug['8'] = 1; /* 64-bit addresses */
|
||||||
/* index of elf text section; needed by asmelfsym, double-checked below */
|
/* index of elf text section; needed by asmelfsym, double-checked below */
|
||||||
/* !debug['d'] causes extra sections before the .text section */
|
/* !debug['d'] causes extra sections before the .text section */
|
||||||
@ -780,6 +782,7 @@ asmb(void)
|
|||||||
break;
|
break;
|
||||||
case Hlinux:
|
case Hlinux:
|
||||||
case Hfreebsd:
|
case Hfreebsd:
|
||||||
|
case Hopenbsd:
|
||||||
symo = rnd(HEADR+segtext.len, INITRND)+segdata.filelen;
|
symo = rnd(HEADR+segtext.len, INITRND)+segdata.filelen;
|
||||||
symo = rnd(symo, INITRND);
|
symo = rnd(symo, INITRND);
|
||||||
break;
|
break;
|
||||||
@ -849,6 +852,7 @@ asmb(void)
|
|||||||
break;
|
break;
|
||||||
case Hlinux:
|
case Hlinux:
|
||||||
case Hfreebsd:
|
case Hfreebsd:
|
||||||
|
case Hopenbsd:
|
||||||
/* elf amd-64 */
|
/* elf amd-64 */
|
||||||
|
|
||||||
eh = getElfEhdr();
|
eh = getElfEhdr();
|
||||||
@ -891,6 +895,9 @@ asmb(void)
|
|||||||
case Hfreebsd:
|
case Hfreebsd:
|
||||||
interpreter = freebsddynld;
|
interpreter = freebsddynld;
|
||||||
break;
|
break;
|
||||||
|
case Hopenbsd:
|
||||||
|
interpreter = openbsddynld;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elfinterp(sh, startva, interpreter);
|
elfinterp(sh, startva, interpreter);
|
||||||
@ -1053,7 +1060,9 @@ asmb(void)
|
|||||||
eh->ident[EI_MAG2] = 'L';
|
eh->ident[EI_MAG2] = 'L';
|
||||||
eh->ident[EI_MAG3] = 'F';
|
eh->ident[EI_MAG3] = 'F';
|
||||||
if(HEADTYPE == Hfreebsd)
|
if(HEADTYPE == Hfreebsd)
|
||||||
eh->ident[EI_OSABI] = 9;
|
eh->ident[EI_OSABI] = ELFOSABI_FREEBSD;
|
||||||
|
else if(HEADTYPE == Hopenbsd)
|
||||||
|
eh->ident[EI_OSABI] = ELFOSABI_OPENBSD;
|
||||||
eh->ident[EI_CLASS] = ELFCLASS64;
|
eh->ident[EI_CLASS] = ELFCLASS64;
|
||||||
eh->ident[EI_DATA] = ELFDATA2LSB;
|
eh->ident[EI_DATA] = ELFDATA2LSB;
|
||||||
eh->ident[EI_VERSION] = EV_CURRENT;
|
eh->ident[EI_VERSION] = EV_CURRENT;
|
||||||
|
@ -34,6 +34,8 @@ Options new in this version:
|
|||||||
Write Linux ELF binaries (default when $GOOS is linux)
|
Write Linux ELF binaries (default when $GOOS is linux)
|
||||||
-Hfreebsd
|
-Hfreebsd
|
||||||
Write FreeBSD ELF binaries (default when $GOOS is freebsd)
|
Write FreeBSD ELF binaries (default when $GOOS is freebsd)
|
||||||
|
-Hopenbsd
|
||||||
|
Write OpenBSD ELF binaries (default when $GOOS is openbsd)
|
||||||
-Hwindows
|
-Hwindows
|
||||||
Write Windows PE32+ binaries (default when $GOOS is windows)
|
Write Windows PE32+ binaries (default when $GOOS is windows)
|
||||||
-I interpreter
|
-I interpreter
|
||||||
|
@ -50,6 +50,7 @@ Header headers[] = {
|
|||||||
"darwin", Hdarwin,
|
"darwin", Hdarwin,
|
||||||
"linux", Hlinux,
|
"linux", Hlinux,
|
||||||
"freebsd", Hfreebsd,
|
"freebsd", Hfreebsd,
|
||||||
|
"openbsd", Hopenbsd,
|
||||||
"windows", Hwindows,
|
"windows", Hwindows,
|
||||||
"windowsgui", Hwindows,
|
"windowsgui", Hwindows,
|
||||||
0, 0
|
0, 0
|
||||||
@ -62,6 +63,7 @@ Header headers[] = {
|
|||||||
* -Hdarwin -Tx -Rx is apple MH-exec
|
* -Hdarwin -Tx -Rx is apple MH-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
|
||||||
|
* -Hopenbsd -Tx -Rx is OpenBSD elf-exec
|
||||||
* -Hwindows -Tx -Rx is MS Windows PE32+
|
* -Hwindows -Tx -Rx is MS Windows PE32+
|
||||||
*
|
*
|
||||||
* options used: 189BLQSWabcjlnpsvz
|
* options used: 189BLQSWabcjlnpsvz
|
||||||
@ -195,6 +197,7 @@ main(int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
case Hlinux: /* elf64 executable */
|
case Hlinux: /* elf64 executable */
|
||||||
case Hfreebsd: /* freebsd */
|
case Hfreebsd: /* freebsd */
|
||||||
|
case Hopenbsd: /* openbsd */
|
||||||
/*
|
/*
|
||||||
* 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).
|
||||||
|
@ -294,7 +294,8 @@ patch(void)
|
|||||||
p->from.offset = 0x58;
|
p->from.offset = 0x58;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(HEADTYPE == Hlinux || HEADTYPE == Hfreebsd) {
|
if(HEADTYPE == Hlinux || HEADTYPE == Hfreebsd
|
||||||
|
|| HEADTYPE == Hopenbsd) {
|
||||||
// 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;
|
||||||
@ -419,7 +420,8 @@ dostkoff(void)
|
|||||||
if(!(p->from.scale & NOSPLIT)) {
|
if(!(p->from.scale & NOSPLIT)) {
|
||||||
p = appendp(p); // load g into CX
|
p = appendp(p); // load g into CX
|
||||||
p->as = AMOVQ;
|
p->as = AMOVQ;
|
||||||
if(HEADTYPE == Hlinux || HEADTYPE == Hfreebsd) // ELF uses FS
|
if(HEADTYPE == Hlinux || HEADTYPE == Hfreebsd
|
||||||
|
|| HEADTYPE == Hopenbsd) // 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;
|
||||||
|
@ -263,6 +263,7 @@ enum {
|
|||||||
Hlinux, // Linux ELF
|
Hlinux, // Linux ELF
|
||||||
Hfreebsd, // FreeBSD ELF
|
Hfreebsd, // FreeBSD ELF
|
||||||
Hwindows, // MS Windows PE
|
Hwindows, // MS Windows PE
|
||||||
|
Hopenbsd, // OpenBSD ELF
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct Header Header;
|
typedef struct Header Header;
|
||||||
|
Loading…
Reference in New Issue
Block a user