I need to declare a symbol which is weaker in the executable than in any
external static or dynamic library.
In other words, the executable provides some fallback function
implementation (in my example, for "write"). But if the linker or
dynamic linker resolves it, the symbol definition from an external
library must be used.
I use:
__f_write_weak_alias(int __fd, __const __ptr_t __buf, size_t __n)
__attribute__((weak, alias ("write"))); /* alias declaration */
int write(int __fd, __const __ptr_t __buf, size_t __n) {
printf("Abort\n");
} /* fallback implementation */
But even though "write" is resolved, calling the __f_write_weak_alias
just prints "Abort" i. e. the symbol "write" was not overridden by the
library definition.
What is the right way to do this?
Thanks for any advice.
Dimitry Golubovsky
Middletown, CT