gdb compile for powerpc64 target - Could not find symbol ".TOC."

Ulrich Weigand uweigand@de.ibm.com
Wed Jun 23 15:36:30 GMT 2021


On Tue, Jun 22, 2021 at 01:54:56PM -0500, will schmidt wrote:

> During gdb/compile/compile-object-load.c:
> compile-object-load() the following is emitted:
> 	warning: Could not find symbol ".TOC." for compiled module 
> 	"/tmp/gdbobj-wIKWtk/out15.o".
> 
> My best guess is that we need to incorporate some amount of special
> handling for the TOC entry to help find the symbols we are after. 
> But.. I havn't stumbled across anything similar for other targets, and
> I havn't yet gleamed enlightenment looking at the existing code in
> compile-object-load.  :-)    As a hack I have tried treating the 
> TOC symbol like we do the GOT entry, those attempts will later crash as
> we will trip over a zero dereference when trying to get at the symbol
> to print it.

Yes, we probably do need a proper value for .TOC.  Usually, this
is set by the linker to 0x8000 bytes after the beginning of the .toc
section, I think.

Looks like there is a BFD routine ppc64_elf_set_toc that will define
that symbol, but that's probably never called here if you just load
a plain object file.

Alan, do you have any suggestions of how to handle this, maybe?


> With "set debug compile" enabled, a few bits of possibly relevant
> info..
> 
> 	COLLECT_GCC_OPTIONS='-m64' '-mcmodel=large' '-A' 'system=linux'

Can you try without -mcmodel=large ?   The particular reference to
the .TOC. symbol you show below originated from this option.
However, even without that there may still be references to .TOC.

Bye,
Ulricj

-- 
  Dr. Ulrich Weigand
  GNU/Linux compilers and toolchain
  Ulrich.Weigand@de.ibm.com


More information about the Gdb-patches mailing list