public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Cary Coutant <ccoutant@google.com>
To: "Kevin P. Fleming" <kpfleming@digium.com>
Cc: binutils@sourceware.org
Subject: Re: Ensuring symbol resolution order at runtime
Date: Fri, 20 Jan 2012 22:57:00 -0000	[thread overview]
Message-ID: <CAHACq4rWKUxh-o_h3xfm4SGZsa7T7BJjVBvtfwJmyWFjuM=-ug@mail.gmail.com> (raw)
In-Reply-To: <4F19EF05.7020104@digium.com>

>> As long as the runtime loader sees the same libraries that the linker
>> saw, yes, there is a guarantee. However, if lib1.so is replaced with a
>> library that does not define "foo", then the dynamic loader will bind
>> "foo" to the definition in lib2.so without any complaint.
>
> So, to be as specific as I can, not only will the runtime loader see those
> same libraries, but it will look at them in the *same order* that the static
> linker did (presumably because the static linker will list them in the
> linked executable in the order it processed them, and the dynamic linker
> follows that order).

Yes. The ABI requires that:

"When the dynamic linker creates the memory segments for an object
file, the dependencies (recorded in DT_NEEDED entries of the dynamic
structure) tell what shared objects are needed to supply the program's
services. By repeatedly connecting referenced shared objects and their
dependencies, the dynamic linker builds a complete process image. When
resolving symbolic references, the dynamic linker examines the symbol
tables with a breadth-first search. That is, it first looks at the
symbol table of the executable program itself, then at the symbol
tables of the DT_NEEDED entries (in order), and then at the second
level DT_NEEDED entries, and so on. Shared object files must be
readable by the process; other permissions are not required." [from
http://www.sco.com/developers/gabi/latest/ch5.dynamic.html#shobj_dependencies
]

-cary

  reply	other threads:[~2012-01-20 22:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-20 19:34 Kevin P. Fleming
2012-01-20 21:52 ` Cary Coutant
2012-01-20 22:47   ` Kevin P. Fleming
2012-01-20 22:57     ` Cary Coutant [this message]
2012-01-20 23:01       ` Kevin P. Fleming

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='CAHACq4rWKUxh-o_h3xfm4SGZsa7T7BJjVBvtfwJmyWFjuM=-ug@mail.gmail.com' \
    --to=ccoutant@google.com \
    --cc=binutils@sourceware.org \
    --cc=kpfleming@digium.com \
    /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).