[PATCH 2/5] elf: Avoid unnecessary slowdown from profiling with audit (BZ#15533)

Adhemerval Zanella adhemerval.zanella@linaro.org
Wed Jul 7 20:05:57 GMT 2021



On 07/07/2021 16:20, Florian Weimer wrote:
> * Adhemerval Zanella via Libc-alpha:
> 
>> diff --git a/elf/dl-reloc.c b/elf/dl-reloc.c
>> index e13a672ade..998cfef099 100644
>> --- a/elf/dl-reloc.c
>> +++ b/elf/dl-reloc.c
>> @@ -181,7 +181,18 @@ _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[],
>>  #ifdef SHARED
>>    /* If we are auditing, install the same handlers we need for profiling.  */
>>    if ((reloc_mode & __RTLD_AUDIT) == 0)
>> -    consider_profiling |= GLRO(dl_audit) != NULL;
>> +    {
>> +      struct audit_ifaces *afct = GLRO(dl_audit);
>> +      for (unsigned int cnt = 0; cnt < GLRO(dl_naudit); ++cnt)
>> +	{
>> +	  /* Profiling is needed only if PLT hooks are provided.  */
>> +	  if (afct->symbind != NULL
>> +	      || afct->ARCH_LA_PLTENTER != NULL
>> +	      || afct->ARCH_LA_PLTEXIT != NULL)
>> +	    consider_profiling = 1;
>> +	  afct = afct->next;
>> +	}
>> +    }
> 
> Is the afct->symbind check really necessary?  Looking at _dl_fixup, it
> should be safe to call symbind with just the standard trampoline.

Yes, elf/tst-audit18b check specifically for this.  Without it,
returning LA_FLG_BINDFROM | LA_FLG_BINDTO from la_objopen() won't
trigger a la_symbind{32,64}.

> 
> I think this needs a NEWS entry, describing how to activate this
> optimization.

I can add a NEW entry, although it is not really a 'new feature'.
What about:

  * The audit libraries will avoid unnecessary slowdown if it is not
    required either PLT tracking or symbol binding profiling (enabled
    with LA_FLG_BINDFROM or LA_FLG_BINDTO from la_objopen() callback).


More information about the Libc-alpha mailing list