Really? That is the best alternative compared to:
- create a linker warning against malloc, calloc, realloc, ...
- get the symbols of the compiled image, and fail the build if the above are referenced
- other ideas: eliminating the allocator code from the image? (Why have it there if it's not called?)
He explains how to detect the symbols later in the article.
> - other ideas: eliminating the allocator code from the image? (Why have it there if it's not called?)
Because you want to detect if it is called indirectly by some function you're calling.
> create a linker warning against malloc, calloc, realloc, ...
This prints something on a screen. It does not prevent the usage.
> get the symbols of the compiled image, and fail the build if the above are referenced
It was used, and now you've detected its usage. It did not prevent the usage.
> eliminating the allocator code from the image? (Why have it there if it's not called?)
This requires attention, and a deep knowledge of all the code. It doesn't prevent the usage, since you’re free to type “malloc()” with your fingers.
Sometimes you need an explosive guarantee!
-Werror=...?
foo_image: $(OBJS) .... if $(NM) $@ | grep -s -E 'malloc|...' ; then \ echo "dynamic allocation not allowed" ; \ exit 1 ; \ fi
Really? That is the best alternative compared to:
- create a linker warning against malloc, calloc, realloc, ...
- get the symbols of the compiled image, and fail the build if the above are referenced
- other ideas: eliminating the allocator code from the image? (Why have it there if it's not called?)