aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgrischka <grischka>2009-12-19 22:08:15 +0100
committergrischka <grischka>2009-12-19 22:16:20 +0100
commite81569bc70697d4380e7456e7938dec29c91af73 (patch)
treeb5bbdff565851065ed68deac7d762347f61b0f25
parentdd3d4f7295f0729f36acf9be0d6027d1838b9a9b (diff)
downloadtinycc-e81569bc70697d4380e7456e7938dec29c91af73.tar.gz
tinycc-e81569bc70697d4380e7456e7938dec29c91af73.tar.bz2
tcc: add "-Wl,-rpath=path" option (library search path)
-rw-r--r--Makefile4
-rw-r--r--tcc-doc.texi6
-rw-r--r--tcc.c2
-rw-r--r--tcc.h2
-rw-r--r--tccelf.c5
5 files changed, 16 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 131b42a..a6033da 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 c634ad6..f325e36 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 ce5e09f..aeda468 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 59384b4..a96a893 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 dc0c948..7b891cf 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;