Commit 9040da9e authored by Ian Lance Taylor's avatar Ian Lance Taylor

ld: Add -I option to set ELF interpreter.

R=rsc
CC=golang-dev
https://golang.org/cl/4080049
parent eea18d95
......@@ -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;
......
......@@ -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.
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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.
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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.
......
......@@ -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;
......
......@@ -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;
......
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