mirror of
https://github.com/golang/go
synced 2024-11-21 20:24:50 -07:00
Add -r option to 6l/8l/5l.
This permits more flexibility with cgo and swig in cases where the program is run on a machine other than the one on which it is built. Rather than storing the absolute path to the shared library in the DT_NEEDED entry, we can store just the name, and let the dynamic linker find it using DT_RUNPATH or the LD_LIBRARY_PATH environment variable. R=rsc CC=golang-dev https://golang.org/cl/223068
This commit is contained in:
parent
ba50599e46
commit
e6443f6255
@ -322,6 +322,8 @@ doelf(void)
|
||||
elfwritedynentsym(s, DT_REL, lookup(".rel", 0));
|
||||
elfwritedynentsymsize(s, DT_RELSZ, lookup(".rel", 0));
|
||||
elfwritedynent(s, DT_RELENT, ELF32RELSIZE);
|
||||
if(rpath)
|
||||
elfwritedynent(s, DT_RUNPATH, addstring(dynstr, rpath));
|
||||
elfwritedynent(s, DT_NULL, 0);
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,8 @@ Options new in this version:
|
||||
-L dir1,dir2,..
|
||||
Search for libraries (package files) in the comma-separated list of directories.
|
||||
The default is the single location $GOROOT/pkg/$GOOS_arm.
|
||||
-r dir1:dir2:...
|
||||
Set the dynamic linker search path when using ELF.
|
||||
-V
|
||||
Print the linker version.
|
||||
|
||||
|
@ -333,6 +333,7 @@ EXTERN Oprang thumboprange[ALAST];
|
||||
EXTERN char* outfile;
|
||||
EXTERN int32 pc;
|
||||
EXTERN uchar repop[ALAST];
|
||||
EXTERN char* rpath;
|
||||
EXTERN uint32 stroffset;
|
||||
EXTERN int32 symsize;
|
||||
EXTERN Prog* textp;
|
||||
|
@ -81,7 +81,7 @@ linkername[] =
|
||||
void
|
||||
usage(void)
|
||||
{
|
||||
fprint(2, "usage: 5l [-E entry] [-H head] [-L dir] [-T text] [-D data] [-R rnd] [-o out] main.5\n");
|
||||
fprint(2, "usage: 5l [-E entry] [-H head] [-L dir] [-T text] [-D data] [-R rnd] [-r path] [-o out] main.5\n");
|
||||
errorexit();
|
||||
}
|
||||
|
||||
@ -128,6 +128,9 @@ main(int argc, char *argv[])
|
||||
case 'R':
|
||||
INITRND = atolwhex(EARGF(usage()));
|
||||
break;
|
||||
case 'r':
|
||||
rpath = EARGF(usage());
|
||||
break;
|
||||
case 'H':
|
||||
HEADTYPE = atolwhex(EARGF(usage()));
|
||||
/* do something about setting INITTEXT */
|
||||
|
@ -408,6 +408,8 @@ doelf(void)
|
||||
elfwritedynentsym(s, DT_RELA, lookup(".rela", 0));
|
||||
elfwritedynentsymsize(s, DT_RELASZ, lookup(".rela", 0));
|
||||
elfwritedynent(s, DT_RELAENT, ELF64RELASIZE);
|
||||
if(rpath)
|
||||
elfwritedynent(s, DT_RUNPATH, addstring(dynstr, rpath));
|
||||
elfwritedynent(s, DT_NULL, 0);
|
||||
}
|
||||
}
|
||||
|
@ -35,6 +35,8 @@ Options new in this version:
|
||||
-L dir1,dir2,..
|
||||
Search for libraries (package files) in the comma-separated list of directories.
|
||||
The default is the single location $GOROOT/pkg/$GOOS_amd64.
|
||||
-r dir1:dir2:...
|
||||
Set the dynamic linker search path when using ELF.
|
||||
-V
|
||||
Print the linker version.
|
||||
|
||||
|
@ -330,6 +330,7 @@ EXTERN int nerrors;
|
||||
EXTERN char* noname;
|
||||
EXTERN char* outfile;
|
||||
EXTERN vlong pc;
|
||||
EXTERN char* rpath;
|
||||
EXTERN int32 spsize;
|
||||
EXTERN Sym* symlist;
|
||||
EXTERN int32 symsize;
|
||||
|
@ -76,7 +76,7 @@ isobjfile(char *f)
|
||||
void
|
||||
usage(void)
|
||||
{
|
||||
fprint(2, "usage: 6l [-options] [-E entry] [-H head] [-L dir] [-T text] [-R rnd] [-o out] main.6\n");
|
||||
fprint(2, "usage: 6l [-options] [-E entry] [-H head] [-L dir] [-T text] [-R rnd] [-r path] [-o out] main.6\n");
|
||||
exits("usage");
|
||||
}
|
||||
|
||||
@ -126,6 +126,9 @@ main(int argc, char *argv[])
|
||||
case 'R':
|
||||
INITRND = atolwhex(EARGF(usage()));
|
||||
break;
|
||||
case 'r':
|
||||
rpath = EARGF(usage());
|
||||
break;
|
||||
case 'x': /* produce export table */
|
||||
doexp = 1;
|
||||
if(argv[1] != nil && argv[1][0] != '-' && !isobjfile(argv[1]))
|
||||
|
@ -398,6 +398,8 @@ doelf(void)
|
||||
elfwritedynentsym(s, DT_REL, lookup(".rel", 0));
|
||||
elfwritedynentsymsize(s, DT_RELSZ, lookup(".rel", 0));
|
||||
elfwritedynent(s, DT_RELENT, ELF32RELSIZE);
|
||||
if(rpath)
|
||||
elfwritedynent(s, DT_RUNPATH, addstring(dynstr, rpath));
|
||||
elfwritedynent(s, DT_NULL, 0);
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,8 @@ Options new in this version:
|
||||
-L dir1,dir2,..
|
||||
Search for libraries (package files) in the comma-separated list of directories.
|
||||
The default is the single location $GOROOT/pkg/$GOOS_386.
|
||||
-r dir1:dir2:...
|
||||
Set the dynamic linker search path when using ELF.
|
||||
-V
|
||||
Print the linker version.
|
||||
|
||||
|
@ -295,6 +295,7 @@ EXTERN int maxop;
|
||||
EXTERN int nerrors;
|
||||
EXTERN char* noname;
|
||||
EXTERN int32 pc;
|
||||
EXTERN char* rpath;
|
||||
EXTERN int32 spsize;
|
||||
EXTERN Sym* symlist;
|
||||
EXTERN int32 symsize;
|
||||
|
@ -81,7 +81,7 @@ isobjfile(char *f)
|
||||
void
|
||||
usage(void)
|
||||
{
|
||||
fprint(2, "usage: 8l [-options] [-E entry] [-H head] [-L dir] [-T text] [-R rnd] [-o out] main.8\n");
|
||||
fprint(2, "usage: 8l [-options] [-E entry] [-H head] [-L dir] [-T text] [-R rnd] [-r path] [-o out] main.8\n");
|
||||
exits("usage");
|
||||
}
|
||||
|
||||
@ -131,6 +131,8 @@ main(int argc, char *argv[])
|
||||
case 'R':
|
||||
INITRND = atolwhex(EARGF(usage()));
|
||||
break;
|
||||
case 'r':
|
||||
rpath = EARGF(usage());
|
||||
break;
|
||||
case 'x': /* produce export table */
|
||||
doexp = 1;
|
||||
|
Loading…
Reference in New Issue
Block a user