Please help with __attribute__ weak

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux