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