tcc: add "-Wl,-rpath=path" option (library search path)
This commit is contained in:
parent
dd3d4f7295
commit
e81569bc70
5 changed files with 16 additions and 3 deletions
4
Makefile
4
Makefile
|
@ -215,12 +215,12 @@ ifneq ($(BCHECK_O),)
|
||||||
$(INSTALL) -m644 $(BCHECK_O) "$(tccdir)"
|
$(INSTALL) -m644 $(BCHECK_O) "$(tccdir)"
|
||||||
endif
|
endif
|
||||||
$(INSTALL) -m644 $(addprefix include/,$(TCC_INCLUDES)) "$(tccdir)/include"
|
$(INSTALL) -m644 $(addprefix include/,$(TCC_INCLUDES)) "$(tccdir)/include"
|
||||||
mkdir -p "$(docdir)"
|
|
||||||
$(INSTALL) -m644 tcc-doc.html "$(docdir)"
|
|
||||||
mkdir -p "$(libdir)"
|
mkdir -p "$(libdir)"
|
||||||
$(INSTALL) -m644 libtcc.a "$(libdir)"
|
$(INSTALL) -m644 libtcc.a "$(libdir)"
|
||||||
mkdir -p "$(includedir)"
|
mkdir -p "$(includedir)"
|
||||||
$(INSTALL) -m644 libtcc.h "$(includedir)"
|
$(INSTALL) -m644 libtcc.h "$(includedir)"
|
||||||
|
mkdir -p "$(docdir)"
|
||||||
|
-$(INSTALL) -m644 tcc-doc.html "$(docdir)"
|
||||||
|
|
||||||
uninstall:
|
uninstall:
|
||||||
rm -fv $(foreach P,$(PROGS),"$(bindir)/$P")
|
rm -fv $(foreach P,$(PROGS),"$(bindir)/$P")
|
||||||
|
|
|
@ -284,6 +284,9 @@ libxxx.a. The library is searched in the paths specified by the
|
||||||
Generate a shared library instead of an executable (@option{-o} option
|
Generate a shared library instead of an executable (@option{-o} option
|
||||||
must also be given).
|
must also be given).
|
||||||
|
|
||||||
|
@item -soname name
|
||||||
|
set name for shared library to be used at runtime
|
||||||
|
|
||||||
@item -static
|
@item -static
|
||||||
Generate a statically linked executable (default is a shared linked
|
Generate a statically linked executable (default is a shared linked
|
||||||
executable) (@option{-o} option must also be given).
|
executable) (@option{-o} option must also be given).
|
||||||
|
@ -310,6 +313,9 @@ Binary image (only for executable output)
|
||||||
COFF output format (only for executable output for TMS320C67xx target)
|
COFF output format (only for executable output for TMS320C67xx target)
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
|
@item -Wl,-rpath=path
|
||||||
|
Set custom library search path
|
||||||
|
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
Debugger options:
|
Debugger options:
|
||||||
|
|
2
tcc.c
2
tcc.c
|
@ -442,6 +442,8 @@ int parse_args(TCCState *s, int argc, char **argv)
|
||||||
{
|
{
|
||||||
error("target %s not found", p);
|
error("target %s not found", p);
|
||||||
}
|
}
|
||||||
|
} else if (strstart(optarg, "-rpath=", &p)) {
|
||||||
|
s->rpath = p;
|
||||||
} else {
|
} else {
|
||||||
error("unsupported linker option '%s'", optarg);
|
error("unsupported linker option '%s'", optarg);
|
||||||
}
|
}
|
||||||
|
|
2
tcc.h
2
tcc.h
|
@ -434,6 +434,8 @@ struct TCCState {
|
||||||
|
|
||||||
/* soname as specified on the command line (-soname) */
|
/* soname as specified on the command line (-soname) */
|
||||||
const char *soname;
|
const char *soname;
|
||||||
|
/* rpath as specified on the command line (-Wl,-rpath=) */
|
||||||
|
const char *rpath;
|
||||||
|
|
||||||
/* if true, all symbols are exported */
|
/* if true, all symbols are exported */
|
||||||
int rdynamic;
|
int rdynamic;
|
||||||
|
|
5
tccelf.c
5
tccelf.c
|
@ -1563,6 +1563,10 @@ int elf_output_file(TCCState *s1, const char *filename)
|
||||||
if (dllref->level == 0)
|
if (dllref->level == 0)
|
||||||
put_dt(dynamic, DT_NEEDED, put_elf_str(dynstr, dllref->name));
|
put_dt(dynamic, DT_NEEDED, put_elf_str(dynstr, dllref->name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (s1->rpath)
|
||||||
|
put_dt(dynamic, DT_RPATH, put_elf_str(dynstr, s1->rpath));
|
||||||
|
|
||||||
/* XXX: currently, since we do not handle PIC code, we
|
/* XXX: currently, since we do not handle PIC code, we
|
||||||
must relocate the readonly segments */
|
must relocate the readonly segments */
|
||||||
if (file_type == TCC_OUTPUT_DLL) {
|
if (file_type == TCC_OUTPUT_DLL) {
|
||||||
|
@ -1570,7 +1574,6 @@ int elf_output_file(TCCState *s1, const char *filename)
|
||||||
put_dt(dynamic, DT_SONAME, put_elf_str(dynstr, s1->soname));
|
put_dt(dynamic, DT_SONAME, put_elf_str(dynstr, s1->soname));
|
||||||
put_dt(dynamic, DT_TEXTREL, 0);
|
put_dt(dynamic, DT_TEXTREL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add necessary space for other entries */
|
/* add necessary space for other entries */
|
||||||
saved_dynamic_data_offset = dynamic->data_offset;
|
saved_dynamic_data_offset = dynamic->data_offset;
|
||||||
dynamic->data_offset += sizeof(ElfW(Dyn)) * EXTRA_RELITEMS;
|
dynamic->data_offset += sizeof(ElfW(Dyn)) * EXTRA_RELITEMS;
|
||||||
|
|
Loading…
Reference in a new issue