1
0
mirror of https://github.com/golang/go synced 2024-11-21 22:44:40 -07:00

ld: Add -I option to set ELF interpreter.

R=rsc
CC=golang-dev
https://golang.org/cl/4080049
This commit is contained in:
Ian Lance Taylor 2011-02-01 12:49:56 -08:00
parent eea18d959e
commit 9040da9e40
12 changed files with 44 additions and 18 deletions

View File

@ -448,7 +448,9 @@ asmb(void)
sh->type = SHT_PROGBITS;
sh->flags = SHF_ALLOC;
sh->addralign = 1;
elfinterp(sh, startva, linuxdynld);
if(interpreter == nil)
interpreter = linuxdynld;
elfinterp(sh, startva, interpreter);
ph = newElfPhdr();
ph->type = PT_INTERP;

View File

@ -23,6 +23,8 @@ Options new in this version:
-F
Force use of software floating point.
Also implied by setting GOARM=5 in the environment.
-I interpreter
Set the ELF dynamic linker to use.
-L dir1 -L dir2
Search for libraries (package files) in dir1, dir2, etc.
The default is the single location $GOROOT/pkg/$GOOS_arm.

View File

@ -332,6 +332,7 @@ EXTERN Oprang thumboprange[ALAST];
EXTERN char* outfile;
EXTERN int32 pc;
EXTERN uchar repop[ALAST];
EXTERN char* interpreter;
EXTERN char* rpath;
EXTERN uint32 stroffset;
EXTERN int32 symsize;

View File

@ -61,7 +61,7 @@ linkername[] =
void
usage(void)
{
fprint(2, "usage: 5l [-E entry] [-H head] [-L dir] [-T text] [-D data] [-R rnd] [-r path] [-o out] main.5\n");
fprint(2, "usage: 5l [-E entry] [-H head] [-I interpreter] [-L dir] [-T text] [-D data] [-R rnd] [-r path] [-o out] main.5\n");
errorexit();
}
@ -100,6 +100,9 @@ main(int argc, char *argv[])
case 'E':
INITENTRY = EARGF(usage());
break;
case 'I':
interpreter = EARGF(usage());
break;
case 'L':
Lflag(EARGF(usage()));
break;

View File

@ -915,14 +915,17 @@ asmb(void)
sh->type = SHT_PROGBITS;
sh->flags = SHF_ALLOC;
sh->addralign = 1;
switch(HEADTYPE) {
case 7:
elfinterp(sh, startva, linuxdynld);
break;
case 9:
elfinterp(sh, startva, freebsddynld);
break;
if(interpreter == nil) {
switch(HEADTYPE) {
case 7:
interpreter = linuxdynld;
break;
case 9:
interpreter = freebsddynld;
break;
}
}
elfinterp(sh, startva, interpreter);
ph = newElfPhdr();
ph->type = PT_INTERP;

View File

@ -32,6 +32,8 @@ Options new in this version:
Write Apple Mach-O binaries (default when $GOOS is darwin)
-H7
Write Linux ELF binaries (default when $GOOS is linux)
-I interpreter
Set the ELF dynamic linker to use.
-L dir1 -L dir2
Search for libraries (package files) in dir1, dir2, etc.
The default is the single location $GOROOT/pkg/$GOOS_amd64.

View File

@ -352,6 +352,7 @@ EXTERN int nerrors;
EXTERN char* noname;
EXTERN char* outfile;
EXTERN vlong pc;
EXTERN char* interpreter;
EXTERN char* rpath;
EXTERN int32 spsize;
EXTERN Sym* symlist;

View File

@ -58,7 +58,7 @@ char* paramspace = "FP";
void
usage(void)
{
fprint(2, "usage: 6l [-options] [-E entry] [-H head] [-L dir] [-T text] [-R rnd] [-r path] [-o out] main.6\n");
fprint(2, "usage: 6l [-options] [-E entry] [-H head] [-I interpreter] [-L dir] [-T text] [-R rnd] [-r path] [-o out] main.6\n");
exits("usage");
}
@ -96,6 +96,9 @@ main(int argc, char *argv[])
case 'H':
HEADTYPE = atolwhex(EARGF(usage()));
break;
case 'I':
interpreter = EARGF(usage());
break;
case 'L':
Lflag(EARGF(usage()));
break;

View File

@ -936,14 +936,17 @@ asmb(void)
sh->type = SHT_PROGBITS;
sh->flags = SHF_ALLOC;
sh->addralign = 1;
switch(HEADTYPE) {
case 7:
elfinterp(sh, startva, linuxdynld);
break;
case 9:
elfinterp(sh, startva, freebsddynld);
break;
if(interpreter == nil) {
switch(HEADTYPE) {
case 7:
interpreter = linuxdynld;
break;
case 9:
interpreter = freebsddynld;
break;
}
}
elfinterp(sh, startva, interpreter);
ph = newElfPhdr();
ph->type = PT_INTERP;

View File

@ -29,6 +29,8 @@ Options new in this version:
Write Apple Mach-O binaries (default when $GOOS is darwin)
-H7
Write Linux ELF binaries (default when $GOOS is linux)
-I interpreter
Set the ELF dynamic linker to use.
-L dir1 -L dir2
Search for libraries (package files) in dir1, dir2, etc.
The default is the single location $GOROOT/pkg/$GOOS_386.

View File

@ -315,6 +315,7 @@ EXTERN int maxop;
EXTERN int nerrors;
EXTERN char* noname;
EXTERN int32 pc;
EXTERN char* interpreter;
EXTERN char* rpath;
EXTERN int32 spsize;
EXTERN Sym* symlist;

View File

@ -64,7 +64,7 @@ char *thestring = "386";
void
usage(void)
{
fprint(2, "usage: 8l [-options] [-E entry] [-H head] [-L dir] [-T text] [-R rnd] [-r path] [-o out] main.8\n");
fprint(2, "usage: 8l [-options] [-E entry] [-H head] [-I interpreter] [-L dir] [-T text] [-R rnd] [-r path] [-o out] main.8\n");
exits("usage");
}
@ -102,6 +102,9 @@ main(int argc, char *argv[])
case 'H':
HEADTYPE = atolwhex(EARGF(usage()));
break;
case 'I':
interpreter = EARGF(usage());
break;
case 'L':
Lflag(EARGF(usage()));
break;