Should malloc-related functions be weak?

Florian Weimer fweimer@redhat.com
Fri Jul 29 20:12:00 GMT 2016


On 07/29/2016 03:11 PM, Tulio Magno Quites Machado Filho wrote:
> Florian Weimer <fweimer@redhat.com> writes:
>
>> On 07/29/2016 02:27 PM, Tulio Magno Quites Machado Filho wrote:
>>>
>>> According to the __malloc_hook man page [1]
>>>
>>>     Programmers should instead preempt calls to the relevant functions by
>>>     defining and exporting functions such as "malloc" and "free".
>>>
>>> But malloc, free and realloc are all global functions, causing problems when
>>> linking statically.
>>>
>>> Shouldn't they be weak functions?
>>
>> I don't think so.  With those non-weak definition, the static linker
>> enforces that you interpose *all* malloc-related APIs in use.
>
> Including the new __malloc_fork_lock_parent, __malloc_fork_unlock_parent and
> __malloc_fork_unlock_child?

Hmm, right.  Would you file a bug for this so that we do not forget it?

Florian



More information about the Libc-alpha mailing list