1
0
mirror of https://github.com/golang/go synced 2024-11-25 10:17:57 -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->type = SHT_PROGBITS;
sh->flags = SHF_ALLOC; sh->flags = SHF_ALLOC;
sh->addralign = 1; sh->addralign = 1;
elfinterp(sh, startva, linuxdynld); if(interpreter == nil)
interpreter = linuxdynld;
elfinterp(sh, startva, interpreter);
ph = newElfPhdr(); ph = newElfPhdr();
ph->type = PT_INTERP; ph->type = PT_INTERP;

View File

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

View File

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

View File

@ -61,7 +61,7 @@ linkername[] =
void void
usage(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(); errorexit();
} }
@ -100,6 +100,9 @@ main(int argc, char *argv[])
case 'E': case 'E':
INITENTRY = EARGF(usage()); INITENTRY = EARGF(usage());
break; break;
case 'I':
interpreter = EARGF(usage());
break;
case 'L': case 'L':
Lflag(EARGF(usage())); Lflag(EARGF(usage()));
break; break;

View File

@ -915,14 +915,17 @@ asmb(void)
sh->type = SHT_PROGBITS; sh->type = SHT_PROGBITS;
sh->flags = SHF_ALLOC; sh->flags = SHF_ALLOC;
sh->addralign = 1; sh->addralign = 1;
if(interpreter == nil) {
switch(HEADTYPE) { switch(HEADTYPE) {
case 7: case 7:
elfinterp(sh, startva, linuxdynld); interpreter = linuxdynld;
break; break;
case 9: case 9:
elfinterp(sh, startva, freebsddynld); interpreter = freebsddynld;
break; break;
} }
}
elfinterp(sh, startva, interpreter);
ph = newElfPhdr(); ph = newElfPhdr();
ph->type = PT_INTERP; 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) Write Apple Mach-O binaries (default when $GOOS is darwin)
-H7 -H7
Write Linux ELF binaries (default when $GOOS is linux) Write Linux ELF binaries (default when $GOOS is linux)
-I interpreter
Set the ELF dynamic linker to use.
-L dir1 -L dir2 -L dir1 -L dir2
Search for libraries (package files) in dir1, dir2, etc. Search for libraries (package files) in dir1, dir2, etc.
The default is the single location $GOROOT/pkg/$GOOS_amd64. The default is the single location $GOROOT/pkg/$GOOS_amd64.

View File

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

View File

@ -58,7 +58,7 @@ char* paramspace = "FP";
void void
usage(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"); exits("usage");
} }
@ -96,6 +96,9 @@ main(int argc, char *argv[])
case 'H': case 'H':
HEADTYPE = atolwhex(EARGF(usage())); HEADTYPE = atolwhex(EARGF(usage()));
break; break;
case 'I':
interpreter = EARGF(usage());
break;
case 'L': case 'L':
Lflag(EARGF(usage())); Lflag(EARGF(usage()));
break; break;

View File

@ -936,14 +936,17 @@ asmb(void)
sh->type = SHT_PROGBITS; sh->type = SHT_PROGBITS;
sh->flags = SHF_ALLOC; sh->flags = SHF_ALLOC;
sh->addralign = 1; sh->addralign = 1;
if(interpreter == nil) {
switch(HEADTYPE) { switch(HEADTYPE) {
case 7: case 7:
elfinterp(sh, startva, linuxdynld); interpreter = linuxdynld;
break; break;
case 9: case 9:
elfinterp(sh, startva, freebsddynld); interpreter = freebsddynld;
break; break;
} }
}
elfinterp(sh, startva, interpreter);
ph = newElfPhdr(); ph = newElfPhdr();
ph->type = PT_INTERP; 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) Write Apple Mach-O binaries (default when $GOOS is darwin)
-H7 -H7
Write Linux ELF binaries (default when $GOOS is linux) Write Linux ELF binaries (default when $GOOS is linux)
-I interpreter
Set the ELF dynamic linker to use.
-L dir1 -L dir2 -L dir1 -L dir2
Search for libraries (package files) in dir1, dir2, etc. Search for libraries (package files) in dir1, dir2, etc.
The default is the single location $GOROOT/pkg/$GOOS_386. The default is the single location $GOROOT/pkg/$GOOS_386.

View File

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

View File

@ -64,7 +64,7 @@ char *thestring = "386";
void void
usage(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"); exits("usage");
} }
@ -102,6 +102,9 @@ main(int argc, char *argv[])
case 'H': case 'H':
HEADTYPE = atolwhex(EARGF(usage())); HEADTYPE = atolwhex(EARGF(usage()));
break; break;
case 'I':
interpreter = EARGF(usage());
break;
case 'L': case 'L':
Lflag(EARGF(usage())); Lflag(EARGF(usage()));
break; break;