This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[gold patch] RFC: Add extra note when 'vtable for C' is undefined


We keep getting complaints when a class is missing its key function,
and all the linker can do is complain about an "undefined reference to
'vtable for C'" (see, e.g., GCC PR 42540). This simple patch just
prints another line after the undefined reference error, explaining
"the vtable symbol may be undefined because the class is missing its
key function".

I'd like to extend this patch eventually to look for the DWARF info
for the class and use that to identify the key function. If the GCC
change that Mark Mitchell suggests in PR 42540 is ever implemented, we
may be able to do something simpler than that.

Ian, I'm doing a simple check for "_ZTV" here -- for a bit of extra
portability, I could also demangle the symbol name into components and
look for DEMANGLE_COMPONENT_VTABLE, but it just didn't seem worth it.
Also, I could have put the check in gold_undefined_symbol_at_location,
or in Errors::undefined_symbol. Do you have any preference?

-cary


2013-05-21  Cary Coutant  <ccoutant@google.com>

gold/
        * symtab.h (Symbol::is_cxx_vtable): New function.
        * target-reloc.h (relocate_section): Check for vtable symbol.
        * testsuite/Makefile.am (missing_key_func.sh): New test case.
        * testsuite/Makefile.in: Regenerate.
        * testsuite/missing_key_func.cc: New test source.
        * testsuite/missing_key_func.sh: New test script.

Attachment: gold-undef-vtable-patch.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]