This is the mail archive of the mailing list for the binutils 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] ld/ld.texinfo: Do not constrain dynamic linker lazy binding behaviour.

On 07/07/2016 12:21 PM, Nick Clifton wrote:
> Hi Carlos,
>> 2016-07-07  Carlos O'Donell  <>
>> 	* ld.texinfo (Command Line Options,lazy): Lazy binding can
>> 	happen at any time between load and function call.
> Approved - please apply.
>> Florian wrote:
>> Maybe also mention that binding per relocation can happen multiple
>> times?

I agree that this needs to be clarified for IFUNC resolvers which can
observer the multiple invocations.

>> I think this is true even today because the PLT update is racy, and
>> it's observable through IFUNC resolvers.

Clarified in v2 below.
> Is this a feature of lazy binding, or can it happen with non-lazy binding as well ?

It is a feature of lazy binding. 

The resolution function for an IFUNC needs to support being called any
number of times and must return the same result.

There are two ways in which an IFUNC resolver can be called more than once:

(1) By multiple threads which are lazily resolving the same symbol at the
    same time. We purposely do not serialize updates to the PLT/GOT entries
    used for the subsequent function call.

(2) Every shared object which references the IFUNC has a relocation against
    the resolver which will cause the resolver to be re-run to determine
    the relocation result for the given object. Say you have two DSOs
    whose functions call an IFUNC in a third DSO, that IFUNC resolver will
    be run twice, once for each time the DSOs resolve their relocation
    against the third DSOs IFUNC.

In non-lazy binding and in a statically linked application we only ever
call the ifunc resolver once.

> If this is an artefact of lazy binding then it would be worth mentioning.

- Mention that IFUNC resolvers may be called multiple times.

OK to checkin?

2016-07-07  Carlos O'Donell  <>

	* ld.texinfo (Command Line Options,lazy): Lazy binding can
	happen at any time between load and function call.

diff --git a/ld/ld.texinfo b/ld/ld.texinfo
index bc16764..7ca6c6d 100644
--- a/ld/ld.texinfo
+++ b/ld/ld.texinfo
@@ -1122,9 +1122,11 @@ but the primary executable.
 @item 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), rather than at load time.
-Lazy binding is the default.
+dynamic linker to defer function call resolution to a future time
+which may be as late as when the function is called (lazy binding),
+rather than at load time.  Resolution functions for GNU indirect
+functions (STT_GNU_IFUNC) may be called one or more times during
+function call resolution.  Lazy binding is the default.
 @item loadfltr
 Marks  the object that its filters be processed immediately at


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