public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: Brennan Shacklett <bpshacklett@gmail.com>
Cc: libc-alpha@sourceware.org
Subject: Re: [PATCH][BZ 17251] Calculate RPATH $ORIGIN from absolute path
Date: Mon, 02 Mar 2015 07:21:00 -0000	[thread overview]
Message-ID: <20150302072105.GZ19363@vapier> (raw)
In-Reply-To: <1407860209-21797-1-git-send-email-bpshacklett@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1752 bytes --]

On 12 Aug 2014 09:16, Brennan Shacklett wrote:
> Bug 17251 deals with (what I believe is) the incorrect calculation of $ORIGIN
> for shared libraries. Currently $ORIGIN is calculated correctly for executables
> on linux, because readlink is called on /proc/self/exe, which means the
> resulting path is absolute and has no symlinks. 

i'm not sure this behavior is even correct (see below), but at the same time, 
i'm not sure there's a reasonable way to implement the correct behavior.

> Shared libraries with relative paths on the other hand are based 
> off of appending the name / path of the library to the current working 
> directory, which means if the library is a symlink, it is not followed, which 
> breaks RPATH $ORIGIN in the following scenario:

using the current working directory to fill in $ORIGIN surely is incorrect.  the 
ELF spec states:
	When the dynamic linker loads an object that uses $ORIGIN, it must calculate 
	the pathname of the directory containing the object.

which means i'm not sure that's justification for doing a full path resolution.  
if the library is located in ~/, then $ORIGIN inside that lib means it should 
search in ~/ (and not wherever getcwd returns).  although the spec does provide 
enough wiggle room to say either implementation is conforming ...

you do have a case that $ORIGIN should behave the same regardless of the object 
using it (the main executable or a shared lib).  i wonder if the $ORIGIN usage 
in the main ELF breaks if you utilize the ld.so directly if it's utilizing the 
/proc/self/exe symlink ...
$ /lib64/ld-linux-x86-64.so.2 /bin/sh
sh-4.3$ ls -l /proc/$$/exe
lrwxrwxrwx 1 vapier users 0 Mar  2 02:19 /proc/8304/exe -> /lib64/ld-2.21.so
-mike

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

      parent reply	other threads:[~2015-03-02  7:21 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-12 16:18 Brennan Shacklett
2014-08-26 19:28 ` Brennan Shacklett
2014-09-02 18:58 ` Brennan Shacklett
2014-09-02 20:27   ` Joseph S. Myers
2014-09-02 22:35     ` Brennan Shacklett
2014-09-18  7:17 ` Brennan Shacklett
2014-09-24  3:09 ` Brennan Shacklett
2014-10-01  7:28   ` Brennan Shacklett
2014-10-06 16:18     ` Brennan Shacklett
2014-10-26 19:44       ` Brennan Shacklett
2014-11-03 23:31         ` Brennan Shacklett
2014-11-12 23:34           ` Brennan Shacklett
2014-12-12 10:44 ` Florian Weimer
2015-01-13 23:58   ` Brennan Shacklett
2015-03-02  7:21 ` Mike Frysinger [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150302072105.GZ19363@vapier \
    --to=vapier@gentoo.org \
    --cc=bpshacklett@gmail.com \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).