[PATCH 2/5] elf: Avoid unnecessary slowdown from profiling with audit (BZ#15533)
Adhemerval Zanella
adhemerval.zanella@linaro.org
Mon Jul 19 13:17:40 GMT 2021
On 07/07/2021 17:15, Florian Weimer wrote:
> * Adhemerval Zanella:
>
>> 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}.
>
> Hmm, I'm surprised we get a la_symbind call with BIND_NOW at all. And
> for BIND_NOW the choice of trampoline really should not matter anyway.
>
> Anyway, I think we have a feature request that without
> la_ltenter/la_pltexit defined, the presence of la_symbind should not
> incur the overhead from the profiling trampoline. The afct->symbind
> check defeats that.
Indeed, we will need to track the la_symbind for bind-now in a different
fix then. I will update the patch.
More information about the Libc-alpha
mailing list