public inbox for gnu-gabi@sourceware.org
 help / color / mirror / Atom feed
From: Suprateeka R Hegde <hegdesmailbox@gmail.com>
To: Carlos O'Donell <carlos@redhat.com>, gnu-gabi@sourceware.org
Subject: Re: GNU dlopen(3) differs from POSIX/IEEE
Date: Fri, 01 Jan 2016 00:00:00 -0000	[thread overview]
Message-ID: <8fead36d-c757-038a-3914-146ebeee8830@gmail.com> (raw)
In-Reply-To: <42a86c64-a042-0c0d-9601-49729816c825@redhat.com>



On 18-Jun-2016 11:02 AM, Carlos O'Donell wrote:
> On 06/18/2016 12:11 AM, Suprateeka R Hegde wrote:
>> All I am saying is, dlopen(3) with RTLD_GLOBAL also should bring in
>> foo at runtime to be compliant with POSIX.
>
> I disagree. Nothing in POSIX says that needs to be done. The
> key failure in your reasoning is that you have assumed lazy
> symbol resolution must happen at the point of the first function
> call.

ld(1) on a GNU/Linux machine says:
---
-z lazy

When generating an executable or shared library, mark it to tell the 
dynamic linker to defer function call resolution to the point when the 
function is called (lazy binding)
---

This made me think that GNU implementation also matches with other 
implementations -- that is lazy resolution happens at the time of the 
first call.

> You have read "shall be made available for relocation" and
> then used implementation knowledge to decide that _today_ those
> relocations have a happens-after relationship with dlopen in your
> program. But because lazy symbol resolution is not an observable
> event for a well-defined program,

Yes. I agree very much. But making some massive enterprise legacy 
application to become "well-defined" now is beyond tool chain writers.

The very use of --unresolved-symbol=ignore all for an executable link is 
bad in a way.

> and no guarantees are made,
> you can't make a happens-after relationship, and can't expect
> 'foo' to resolve to the loaded 'foo' that came into the global
> scope with dlopen.
>
> Perhaps in the future you want a mode where all lazy symbol
> resolution is done before the first dlopen runs. Say we want to
> do this to relocate the whole PLT and mark it read-only for
> safety hardening.

This is going to be a "mode". Almost similar to BIND_NOW. But not 
default. Even if decided default, a non-default (lazy writable PLTs) 
mode still exists.

> If you were to _require_ lazy resolution to happen at the point
> of the function call, which is what you're assuming here, then
> it would prevent the above implementation from being conforming.

Both are mutually exclusive. In my opinion, programs either want 
immediate binding or lazy binding. Not an arbitrary mix of both.

> However, because POSIX says nothing about when the lazy symbol
> resolution happens, or anything at all about it,

It indeed says something:
---
RTLD_LAZY

Relocations shall be performed at an implementation-defined time, 
ranging from the time of the dlopen() call until the first reference to 
a given symbol occurs
---

And then based on the ld(1) manpage, I thought GNU/Linux implementation 
uses the time of first call.

What is the harm if we go by the existing documentation and under the 
option -z lazy or RTLD_LAZY, make lazy resolution happen at the point of 
function call?

(BTW, the above is already in place currently and is working as expected)

And eventually change the semantics of RTLD_GLOBAL to match the 
description mentioned in the POSIX spec -- ...relocation processing of 
any other executable object file.

--
Supra

  reply	other threads:[~2016-06-18  8:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-01  0:00 Suprateeka R Hegde
2016-01-01  0:00 ` Carlos O'Donell
2016-01-01  0:00   ` Suprateeka R Hegde
2016-01-01  0:00     ` Carlos O'Donell
2016-01-01  0:00       ` Suprateeka R Hegde [this message]
2016-01-01  0:00         ` Carlos O'Donell
2016-01-01  0:00           ` Suprateeka R Hegde
2016-01-01  0:00             ` Carlos O'Donell
2016-01-01  0:00           ` Florian Weimer
2016-01-01  0:00             ` Szabolcs Nagy
2016-01-01  0:00               ` Florian Weimer
2016-01-01  0:00             ` Carlos O'Donell

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=8fead36d-c757-038a-3914-146ebeee8830@gmail.com \
    --to=hegdesmailbox@gmail.com \
    --cc=carlos@redhat.com \
    --cc=gnu-gabi@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).