Should malloc-related functions be weak?
Florian Weimer
fweimer@redhat.com
Fri Jul 29 19:12:00 GMT 2016
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.
Florian
More information about the Libc-alpha
mailing list