Dimitry Golubovsky wrote:

> 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.


H. J. Lu wrote:

The weak symbol is different from the normal one only during creating
executable or shared library if it is in a relocatable file. You
can't use weak symbol for your purpose. But you can mark your symbol in
shared library protected.

=================

Well, libraries are not created by me, so I cannot rely on any
possibility to mark symbols in it. Besides, this is for an automated
tool which may deal with tens of functions at once (this is for a
Haskell FFI generator known as `hsffig' that I am developing).

If there is no way to declare overridable symbols in executables, then
perhaps placing all those fallback stub functions in a separate static
library (.a) and telling the linker to use it last (after all default
and user-specified libraries) could do the job, couldn't it?

This is less desirable though, as it complicates the linker command
line, but if there is no way to do this via declaration in C code,
I'll go with the library.

-- 
Dimitry Golubovsky

Anywhere on the Web

Reply via email to