This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch+7.5.1] Work around PR libc/13097 "linux-vdso.so.1" #3


On Tue, Nov 27, 2012 at 1:59 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> On Friday 23 November 2012 11:01:03 Pedro Alves wrote:
>
>>  "If a shared object name has one or more slash (/) characters anywhere in
>> the name, such as /usr/lib/lib2 above or directory/file, the dynamic
>> linker uses that string directly as the path name. If the name has no
>> slashes, such as lib1 above, three facilities specify shared object path
>> search-ing, with the following precedence."
>>
>> So your example had a slash.  If there'd be no slash, the below applies:
>>
>>  "First, the dynamic array tag DT_RPATH may give a string that holds a list
>> of directories, separated by colons (:). For example, the string
>> /home/dir/lib:/home/dir2/lib: tells the dynamic linker to search first the
>> directory /home/dir/lib, then /home/dir2/lib, and then the current
>> directory to find dependencies.
>>   Second, a variable called LD_LIBRARY_PATH in the process environment [see
>> exec(BA_OS)] may hold a list of directories as above, optionally followed
>> by a semicolon (;) and another directory list."
>>
>>   The following values would be equivalent to the previous example:
>>   LD_LIBRARY_PATH=/home/dir/lib:/home/dir2/lib:
>>   LD_LIBRARY_PATH=/home/dir/lib;/home/dir2/lib:
>>   LD_LIBRARY_PATH=/home/dir/lib:/home/dir2/lib:;
>>   All LD_LIBRARY_PATH directories are searched after those from DT_RPATH.
>> Although some programs (such as the link editor) treat the lists before
>> and after the semicolon differently, the dynamic linker does not.
>> Nevertheless, the dynamic linker accepts the semicolon notation, with the
>> semantics described above.
>>   Finally, if the other two groups of directories fail to locate the
>> desired library, the dynamic linker searches /usr/lib."
>
> there's actually a 4th way according to the ELF spec: DT_RUNPATH is after
> LD_LIBRARY_PATH and before the runtime ldso falls back to its own
> configuration.  further, if DT_RUNPATH is set, the DT_RPATH settings are
> ignored.  this can make a difference if LD_LIBRARY_PATH is in use.
>
> beyond that, while not part of the ELF spec, every ldso worth using has a
> ld.so.cache which it consults before the paths it has hardcoded internally.
> although any path loaded via either of those mechanisms will be a full path,
> so gdb probably need not worry about it.

there is sort of a 5th, la_objsearch from rtld-audit(7) which can
happen at various stages through all of this to replace a path (see
its FLAG argument) I didn't find anything specifying it in the glibc
manual but  the 'slash characters rule' seems to apply to the return
value, under glibc there is currently no way to do this without
specifying an audit lib as a environment variable, but under sun, a
library could specify one itself by adding a DT_AUDIT or DT_DEPAUDIT
entry in the dynamic section.

not sure how this matters except to say it doesn't appear to be useful
for generating a relative path without a '/' due to the slash
characters rule applying.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]