Hello.

Cool, thanks for enabling multiple components in DT_RPATH,
grischka!

Today by accident i had to deal with linker problems of some
software and found an issue that mentioned DT_RUNPATH, which
mentioned that DT_RPATH is legacy and searched for
$LD_LIBRARY_PATH, whereas the newer DT_RUNPATH is searched
thereafter.  Completely unencrypted!  Well.  For what's it worth,
i for one am astonished because of course i want to override
$LD_LIBRARY_PATH, but it surely has its merites, smart people came
to the conclusion, did they.

The attached diff below seems to be sufficient to support
DT_RUNPATH instead of DT_RPATH with tcc(1).  But i have no insight
in what --enable-new-dtags is supposed to change in addition, so
i wonder.

Ciao!

--steffen
CommitDate: 2017-02-16 15:39:54 +0100

    Pseudo --enable-new-dtags for DT_RUNPATH
---
 libtcc.c     | 2 ++
 tcc-doc.texi | 4 ++++
 tcc.h        | 1 +
 tccelf.c     | 3 ++-
 4 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/libtcc.c b/libtcc.c
index f1bbc6c..a2135e3 100644
--- a/libtcc.c
+++ b/libtcc.c
@@ -1380,6 +1380,8 @@ static int tcc_set_linker(TCCState *s, const char *option)
             ignoring = 1;
         } else if (link_option(option, "rpath=", &p)) {
             copy_linker_arg(&s->rpath, p, ':');
+        } else if (link_option(option, "enable-new-dtags", &p)) {
+            s->enable_new_dtags = 1;
         } else if (link_option(option, "section-alignment=", &p)) {
             s->section_align = strtoul(p, &end, 16);
         } else if (link_option(option, "soname=", &p)) {
diff --git a/tcc-doc.texi b/tcc-doc.texi
index db1d28f..a1c6761 100644
--- a/tcc-doc.texi
+++ b/tcc-doc.texi
@@ -307,6 +307,10 @@ Generate an object file combining all input files.
 @item -Wl,-rpath=path
 Put custom search path for dynamic libraries into executable.
 
+@item -Wl,--enable-new-dtags
+When putting a custom search path for dynamic libraries into the executable,
+create the new ELF dynamic tag DT_RUNPATH instead of the old legacy DT_RPATH.
+
 @item -Wl,--oformat=fmt
 Use @var{fmt} as output format. The supported output formats are:
 @table @code
diff --git a/tcc.h b/tcc.h
index c061c79..3494836 100644
--- a/tcc.h
+++ b/tcc.h
@@ -605,6 +605,7 @@ struct TCCState {
     char *tcc_lib_path; /* CONFIG_TCCDIR or -B option */
     char *soname; /* as specified on the command line (-soname) */
     char *rpath; /* as specified on the command line (-Wl,-rpath=) */
+    int enable_new_dtags; /* ditto, (-Wl,--enable-new-dtags) */
 
     /* output type, see TCC_OUTPUT_XXX */
     int output_type;
diff --git a/tccelf.c b/tccelf.c
index ec92bdb..cc21325 100644
--- a/tccelf.c
+++ b/tccelf.c
@@ -1968,7 +1968,8 @@ static int elf_output_file(TCCState *s1, const char *filename)
             }
 
             if (s1->rpath)
-                put_dt(dynamic, DT_RPATH, put_elf_str(dynstr, s1->rpath));
+                put_dt(dynamic, s1->enable_new_dtags ? DT_RUNPATH : DT_RPATH,
+                    put_elf_str(dynstr, s1->rpath));
 
             /* XXX: currently, since we do not handle PIC code, we
                must relocate the readonly segments */
_______________________________________________
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to