tech-toolchain archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Add support for DT_RUNPATH in ld.elf_so?



Hey folks,

we currently do not follow the ELF specs correctly by not supporting 
DT_RUNPATH dynamic tags.

The full story is a bit lengthy, and there probably have been several
design issues involved in other systems and the spec. However, adding
support for it is trivial (see patch below).

Chat discussions upfront have met a few objections though (from what I
understand: out of principle, nothing should ever use these tags on NetBSD).

Here is what the ld(1) info says:

`--enable-new-dtags'
`--disable-new-dtags'
     This linker can create the new dynamic tags in ELF. But the older
     ELF systems may not understand them. If you specify
     `--enable-new-dtags', the new dynamic tags will be created as
     needed and older dynamic tags will be omitted.  If you specify
     `--disable-new-dtags', no new dynamic tags will be created. By
     default, the new dynamic tags are not created. Note that those
     options are only available for ELF systems.

The update of the ELF spec is like 15 years old (I think). The main point
is addition of DT_RUNPATH, used to replace DT_RPATH, as the old spec
for DT_RPATH was seriously broken. However, all BSDs ever implemented
DT_RPATH differently, with the exact same semantics DT_RUNPATH now has.

And that is what makes the ld.elf_so patch trivial - we just alias the
two.

Other options would be to make ld(1) ignore the --enable-new-dtags option
(either silently, with an abort, or by mailing the binutils bugs list
about their stupid command line option design).

So we have three choices:

 - Do nothintg and continue patching 3rd party code and fight upstream
   to avoid them adding --enable-new-dtags on NetBSD
 - apply the attached ld.elf_so patch and ignore the politics
 - patch our ld(1) and try to upstream the change

Martin
Index: headers.c
===================================================================
RCS file: /cvsroot/src/libexec/ld.elf_so/headers.c,v
retrieving revision 1.62
diff -u -p -r1.62 headers.c
--- headers.c	23 Jun 2017 15:29:21 -0000	1.62
+++ headers.c	27 Nov 2017 09:37:36 -0000
@@ -216,6 +216,7 @@ _rtld_digest_dynamic(const char *execnam
 			break;
 
 		case DT_RPATH:
+		case DT_RUNPATH:
 			/*
 		         * We have to wait until later to process this, because
 			 * we might not have gotten the address of the string


Home | Main Index | Thread Index | Old Index