History

-Wl, --enable-new-dtags for DT_RUNPATH instead of DT_RPATH

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 libtcc.c | 2 ++ tcc-doc.texi | 4 ++++ tcc.h | 1 + tccelf.c | 3 ++- 4 files changed, 9 insertions(+), 1 deletion(-)

Steffen Nurpmeso committed 9 years ago

Commit f34b1fe1 parent 096125d4 files · +9 −1Browse files

Unified · Split

4 files
  1. libtcc.c +2 −0
  2. tcc-doc.texi +4 −0
  3. tcc.h +1 −0
  4. tccelf.c +2 −1
libtcc.c+2−0
@@ -1377,6 +1377,8 @@ static int tcc_set_linker(TCCState *s, const char *option) · 1376 unmodified lines
1377 ignoring = 1;1377 ignoring = 1;
1378 } else if (link_option(option, "rpath=", &p)) {1378 } else if (link_option(option, "rpath=", &p)) {
1379 copy_linker_arg(&s->rpath, p, ':');1379 copy_linker_arg(&s->rpath, p, ':');
1380 } else if (link_option(option, "enable-new-dtags", &p)) {
1381 s->enable_new_dtags = 1;
1380 } else if (link_option(option, "section-alignment=", &p)) {1382 } else if (link_option(option, "section-alignment=", &p)) {
1381 s->section_align = strtoul(p, &end, 16);1383 s->section_align = strtoul(p, &end, 16);
1382 } else if (link_option(option, "soname=", &p)) {1384 } else if (link_option(option, "soname=", &p)) {
tcc-doc.texi+4−0
@@ -307,6 +307,10 @@ Generate an object file combining all input files. · 306 unmodified lines
307@item -Wl,-rpath=path307@item -Wl,-rpath=path
308Put custom search path for dynamic libraries into executable.308Put custom search path for dynamic libraries into executable.
309 309
310@item -Wl,--enable-new-dtags
311When putting a custom search path for dynamic libraries into the executable,
312create the new ELF dynamic tag DT_RUNPATH instead of the old legacy DT_RPATH.
313
310@item -Wl,--oformat=fmt314@item -Wl,--oformat=fmt
311Use @var{fmt} as output format. The supported output formats are:315Use @var{fmt} as output format. The supported output formats are:
312@table @code316@table @code
tcc.h+1−0
@@ -605,6 +605,7 @@ struct TCCState { · 604 unmodified lines
605 char *tcc_lib_path; /* CONFIG_TCCDIR or -B option */605 char *tcc_lib_path; /* CONFIG_TCCDIR or -B option */
606 char *soname; /* as specified on the command line (-soname) */606 char *soname; /* as specified on the command line (-soname) */
607 char *rpath; /* as specified on the command line (-Wl,-rpath=) */607 char *rpath; /* as specified on the command line (-Wl,-rpath=) */
608 int enable_new_dtags; /* ditto, (-Wl,--enable-new-dtags) */
608 609
609 /* output type, see TCC_OUTPUT_XXX */610 /* output type, see TCC_OUTPUT_XXX */
610 int output_type;611 int output_type;
tccelf.c+2−1
@@ -1968,7 +1968,8 @@ static int elf_output_file(TCCState *s1, const char *filename) · 1967 unmodified lines
1968 }1968 }
1969 1969
1970 if (s1->rpath)1970 if (s1->rpath)
1971 put_dt(dynamic, DT_RPATH, put_elf_str(dynstr, s1->rpath));1971 put_dt(dynamic, s1->enable_new_dtags ? DT_RUNPATH : DT_RPATH,
1972 put_elf_str(dynstr, s1->rpath));
1972 1973
1973 /* XXX: currently, since we do not handle PIC code, we1974 /* XXX: currently, since we do not handle PIC code, we
1974 must relocate the readonly segments */1975 must relocate the readonly segments */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t