Should malloc-related functions be weak?
Pedro Alves
palves@redhat.com
Mon Aug 1 10:25:00 GMT 2016
On 07/31/2016 02:50 PM, Florian Weimer wrote:
> * DJ Delorie:
>
>> "Tulio Magno Quites Machado Filho" <tuliom@linux.vnet.ibm.com> writes:
>>> Shouldn't they be weak functions?
>>
>> I can imagine the mess that would happen if someone overwrode malloc()
>> but not free()...
>
> The problem is with the other symbols Tulio identified. I'll try to
> see if providing weak stubs for them addresses the issue.
>
Are these other symbols meant be overridden? If so, shouldn't they be
overridden as a group? In any case, maybe move them to a separate .o file
instead, so that the linker either pulls all in, or none, and thus complains
if the program overrides __malloc_fork_lock_parent but
not __malloc_fork_unlock_parent, but doesn't complain if the program
overrides malloc/free, etc.
Thanks,
Pedro Alves
More information about the Libc-alpha
mailing list