Feature request: undefined-symbol hints

Martin v. Löwis loewis@informatik.hu-berlin.de
Sat Aug 10 02:42:00 GMT 2002


In C++, the compiler emits a number of implicit symbols (vtable,
typeinfo). To avoid code duplication, these are only defined together
with some user-defined symbol (the first virtual function in a class).

If the user fails to define that symbol, the implicit symbols are not
defined, either. Users are often confused by the linker error messages
in these cases.

Some compilers (SunPRO) diagnose the problem with a text like "make
sure you've implemented the first virtual function" While this is
helpful, the user often still has difficulties to correct the problem,
since it may not be obvious which this first function is.

Instead, I'd like to see a message like "Make sure you've implemented
foo::bar". When emitting a reference to these symbols, the compiler
has knowledge which function needs to be implemented, so it could
emit a pseudo-op like

  .undefined_hint __foo_vtable, "Make sure you've implemented foo::bar"

(To make this more compact,

  .undefined_hint __foo_vtable, __foo__bar

might be better) (Adjust name namgling for your compiler in these
examples)

To make such warnings work, support would be needed in the assembler
and the linker (atleast for ELF targets perhaps). I'd like to request
that binutils provides such a feature.

What do you think?

Regards,
Martin



More information about the Binutils mailing list