You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Originally posted by ghaerr August 14, 2024
Hello @jmalak,
I have a need to mark a symbol such that, when linking, other libraries will not normally be searched to find and pull in the referenced symbol unless the symbol has already been defined in object files already committed to being linked. In GCC, this is known as weak symbols, and can be specified using the GCC __attribute__((__weak__)) extension.
Can the OpenWatcom linker support weak symbols? I can't seem to find any direct documentation on it, although by looking at the OW source, I see that OBJ EXTRN comment records are apparently used (for import) to specify weak and lazy symbol attributes. (See
as well as IS_SYM_LINK_WEAK in wl/c/objpass1.c, and WEAK in many more places).
There is also some documentation identified on google but which I cannot find the full manual for, saying "Open Watcom Linker User's Guide ... The "EXPORT" directive is used to tell the Open Watcom Linker which symbols are available for import ... A lazy external reference is one which has two" but when I folllow the link I can't find the referenced text. So possibly there is a way to use the EXPORT or IMPORT directives to specify a weak symbol, rather than C source.
My requirement to use weak symbols is for optionally including various routines only when needed in the ELKS C Library, e.g. for including another function printf might call to perform float-to-string display only when floats are used, etc.
Can you point me into the right direction for how to take advantage of this possible internal capability in OpenWatcom?
Thank you!
The text was updated successfully, but these errors were encountered:
It is not supported by OW compilers for user code.
It is used internally by code generator for common block (fortran) or for C++ code I think. May be other reason.
The linker is fully capable to process it, but you cannot define it in linker. It must be defined in generated code (in modules) for real code.
But use of it can be danger and it is not required for current user code.
We can do it as extension but it needs review of OW code.
Probably we could extend #pragma aux for it.
Discussed in #1323
Originally posted by ghaerr August 14, 2024
Hello @jmalak,
I have a need to mark a symbol such that, when linking, other libraries will not normally be searched to find and pull in the referenced symbol unless the symbol has already been defined in object files already committed to being linked. In GCC, this is known as weak symbols, and can be specified using the GCC
__attribute__((__weak__))
extension.Can the OpenWatcom linker support weak symbols? I can't seem to find any direct documentation on it, although by looking at the OW source, I see that OBJ EXTRN comment records are apparently used (for import) to specify weak and lazy symbol attributes. (See
open-watcom-v2/bld/cg/intel/h/x86objd.h
Line 87 in 8eb58ce
IS_SYM_LINK_WEAK
in wl/c/objpass1.c, andWEAK
in many more places).There is also some documentation identified on google but which I cannot find the full manual for, saying "Open Watcom Linker User's Guide ... The "EXPORT" directive is used to tell the Open Watcom Linker which symbols are available for import ... A lazy external reference is one which has two" but when I folllow the link I can't find the referenced text. So possibly there is a way to use the EXPORT or IMPORT directives to specify a weak symbol, rather than C source.
My requirement to use weak symbols is for optionally including various routines only when needed in the ELKS C Library, e.g. for including another function
printf
might call to perform float-to-string display only when floats are used, etc.Can you point me into the right direction for how to take advantage of this possible internal capability in OpenWatcom?
Thank you!
The text was updated successfully, but these errors were encountered: