tcc: add "-Wl,-rpath=path" option (library search path)

This commit is contained in:
grischka 2009-12-19 22:08:15 +01:00
parent dd3d4f7295
commit e81569bc70
5 changed files with 16 additions and 3 deletions

View File

@ -215,12 +215,12 @@ ifneq ($(BCHECK_O),)
$(INSTALL) -m644 $(BCHECK_O) "$(tccdir)"
endif
$(INSTALL) -m644 $(addprefix include/,$(TCC_INCLUDES)) "$(tccdir)/include"
mkdir -p "$(docdir)"
$(INSTALL) -m644 tcc-doc.html "$(docdir)"
mkdir -p "$(libdir)"
$(INSTALL) -m644 libtcc.a "$(libdir)"
mkdir -p "$(includedir)"
$(INSTALL) -m644 libtcc.h "$(includedir)"
mkdir -p "$(docdir)"
-$(INSTALL) -m644 tcc-doc.html "$(docdir)"
uninstall:
rm -fv $(foreach P,$(PROGS),"$(bindir)/$P")

View File

@ -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
must also be given).
@item -soname name
set name for shared library to be used at runtime
@item -static
Generate a statically linked executable (default is a shared linked
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)
@end table
@item -Wl,-rpath=path
Set custom library search path
@end table
Debugger options:

2
tcc.c
View File

@ -442,6 +442,8 @@ int parse_args(TCCState *s, int argc, char **argv)
{
error("target %s not found", p);
}
} else if (strstart(optarg, "-rpath=", &p)) {
s->rpath = p;
} else {
error("unsupported linker option '%s'", optarg);
}

2
tcc.h
View File

@ -434,6 +434,8 @@ struct TCCState {
/* soname as specified on the command line (-soname) */
const char *soname;
/* rpath as specified on the command line (-Wl,-rpath=) */
const char *rpath;
/* if true, all symbols are exported */
int rdynamic;

View File

@ -1563,6 +1563,10 @@ int elf_output_file(TCCState *s1, const char *filename)
if (dllref->level == 0)
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
must relocate the readonly segments */
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_TEXTREL, 0);
}
/* add necessary space for other entries */
saved_dynamic_data_offset = dynamic->data_offset;
dynamic->data_offset += sizeof(ElfW(Dyn)) * EXTRA_RELITEMS;