SV: Problem with overlays and virtual functions.

Peter Rönnquist peter.ronnquist@contextvision.se
Wed Mar 4 10:19:00 GMT 2009



>On Tue, Mar 03, 2009 at 01:09:36PM +0100, Peter Rönnquist wrote:
>> We have a problem with vtables and segments when using overlays for SPUs
on
>> the CELL.
>> 
>> The seg.map shows that a virtual function seems to be put on address
zero:
>> 
>> xxxx.seg.map
>> -----------------------------
>> .a(lib_a-impure.o)
>>  .data.impure_data
>>                 0x00000000000001b0      0x300
>> /opt/cell/sysroot/usr/spu/lib/libc.a(lib_a-impure.o)
>> 
>> .rodata._ZTVZ20GOPFilterxxxE10CLinexxx
>>                 0x0000000000000000       0x10
>>  .rodata._ZTVZ20GOPFilterxxxE10CLinexxx
>>                 0x0000000000000000       0x10 ../spu_obj/GOPFilterxxx.o
>>                 0x0000000000000000                vtable for
>> GOPFilterxxx::CLinexxx
>> -----------------------------
>
>How did you generate your overlay script?  --auto-overlay?  Did you
>use --overlay-rodata too?  The latter is a dangerous option because
>references to rodata in an overlay might be passed out from the
>overlay via pointers.
>
>-- 
>Alan Modra
>Australia Development Lab, IBM

Thank you for your answer.

We use a custom linker script. I included the Read-only sections below.
According to our assumptions all read only data should be included in the
text segment with this linker script.

I tried to find data regarding vtables on the net and I start to suspect
that they might be related to the ctors section. I included that part as
well below. 

....
SECTIONS
{
  /* Read-only sections, merged into text segment: */
  PROVIDE (__executable_start = 0); . = 0;
  .interrupt : { KEEP(*(.interrupt)) }
  .interp         : { *(.interp) }
  .hash           : { *(.hash) }
  .dynsym         : { *(.dynsym) }
  .dynstr         : { *(.dynstr) }
  .gnu.version    : { *(.gnu.version) }
  .gnu.version_d  : { *(.gnu.version_d) }
  .gnu.version_r  : { *(.gnu.version_r) }
  .rel.init       : { *(.rel.init) }
  .rela.init      : { *(.rela.init) }
  .rel.text       : { *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) }
  .rela.text      : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) }
  .rel.fini       : { *(.rel.fini) }
  .rela.fini      : { *(.rela.fini) }
  .rel.rodata     : { *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) }
  .rela.rodata    : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)
}
  .rel.data.rel.ro   : { *(.rel.data.rel.ro*) }
  .rela.data.rel.ro   : { *(.rel.data.rel.ro*) }
  .rel.data       : { *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) }
  .rela.data      : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) }
  .rel.tdata	  : { *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) }
  .rela.tdata	  : { *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) }
  .rel.tbss	  : { *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) }
  .rela.tbss	  : { *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) }
  .rel.ctors      : { *(.rel.ctors) }
  .rela.ctors     : { *(.rela.ctors) }
  .rel.dtors      : { *(.rel.dtors) }
  .rela.dtors     : { *(.rela.dtors) }
  .rel.got        : { *(.rel.got) }
  .rela.got       : { *(.rela.got) }
  .rel.bss        : { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) }
  .rela.bss       : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) }
  .rel.plt        : { *(.rel.plt) }
  .rela.plt       : { *(.rela.plt) }
  .init           :
  {
    KEEP (*(.init))
  } =0
  .plt            : { *(.plt) }
  .text           :
...

.ctors          :
  {
    /* gcc uses crtbegin.o to find the start of
       the constructors, so we make sure it is
       first.  Because this is a wildcard, it
       doesn't matter if the user does not
       actually link against crtbegin.o; the
       linker won't look for a file to match a
       wildcard.  The wildcard also means that it
       doesn't matter which directory crtbegin.o
       is in.  */
    KEEP (*crtbegin*.o(.ctors))
    /* We don't want to include the .ctor section from
       from the crtend.o file until after the sorted ctors.
       The .ctor section from the crtend file contains the
       end of ctors marker and it must be last */
    KEEP (*(EXCLUDE_FILE (*crtend*.o ) .ctors))
    KEEP (*(SORT(.ctors.*)))
    KEEP (*(.ctors))
  }

Peter Rönnquist





More information about the Binutils mailing list