From e81569bc70697d4380e7456e7938dec29c91af73 Mon Sep 17 00:00:00 2001 From: grischka Date: Sat, 19 Dec 2009 22:08:15 +0100 Subject: [PATCH] tcc: add "-Wl,-rpath=path" option (library search path) --- Makefile | 4 ++-- tcc-doc.texi | 6 ++++++ tcc.c | 2 ++ tcc.h | 2 ++ tccelf.c | 5 ++++- 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 131b42a0..a6033da4 100644 --- a/Makefile +++ b/Makefile @@ -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") diff --git a/tcc-doc.texi b/tcc-doc.texi index c634ad6f..f325e365 100644 --- a/tcc-doc.texi +++ b/tcc-doc.texi @@ -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: diff --git a/tcc.c b/tcc.c index ce5e09f9..aeda4689 100644 --- a/tcc.c +++ b/tcc.c @@ -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); } diff --git a/tcc.h b/tcc.h index 59384b42..a96a8935 100644 --- a/tcc.h +++ b/tcc.h @@ -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; diff --git a/tccelf.c b/tccelf.c index dc0c9481..7b891cf8 100644 --- a/tccelf.c +++ b/tccelf.c @@ -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; -- 2.11.4.GIT