[Cbe-oss-dev] MARS and SPU-GCC 4.6

Ulrich Weigand Ulrich.Weigand at de.ibm.com
Tue Feb 22 04:52:57 EST 2011


Geoff Levand <geoff at infradead.org> wrote on 02/21/2011 06:37:58 PM:
> On 01/27/2011 09:19 AM, Ulrich Weigand wrote:
> > Program Headers:
> >   Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg
Align
> >   LOAD           0x000100 0x00000000 0x00000000 0x00010 0x00010 R E
0x80
> >   LOAD           0x000180 0x00004000 0x00004000 0x009f0 0x009f0 R E
0x80
> >   LOAD           0x000b80 0x00004a00 0x00004a00 0x00320 0x00360 RW
0x80
> >   NOTE           0x008410 0x00000000 0x00000000 0x00024 0x00000 R
0x10
> >
> >  Section to Segment mapping:
> >   Segment Sections...
> >    00     .interrupt
> >    01     .init .text .fini .rodata
> >    02     .ctors .dtors .jcr .data .bss
> >    03     .note.spu_name
> >
> > For your purposes, it should probably just work if you simply
> > use .interrupt instead of .init in the command line above ...
>
> I guess using .interrupt my not get the entire second section
> (.init, etc) loaded to the spu since it seems task_map_elf() uses
> the section size for loading.
>
>   task->text_ea = mars_ea_map((void *)ehdr + phdr->p_offset, phdr->
p_filesz);
>
> Does the .interrupt section need to be loaded for a mars program?
> With the alignment it seems it will take up 128 bytes of spu memory
> even though it is just 16 bytes (above case).

For context, the problem was caused by the linker command line containing
  -Wl,--section-start,.init=0x4000
This forced the linker to create a gap between .interrupt and .init,
which means that it has to create two read-only LOAD segments, one
just for .interrupt, and one for the rest of the read-only sections.
This confuses task_map_elf as it expects expects exactly one such
segment.

By changing the command line to
  -Wl,--section-start,.interrupt=0x4000
there is no such gap, and therefore the linker will continue to place
all read-only sections (starting from .interrupt) into a single ELF
segment.  This makes task_map_elf work as expected again.

(Note that task_map_elf reads *segments*, and the size of that one
segment will include data contributed by all the sections that were
included into the segment by the linker.)

In summary, I believe that with the above change to the linker
command line, the existing task_map_elf implementation will work
correctly again.

> task_map_elf() should be updated.  Anyone who does so
> please post the results and I will add them to the mars
> sources (http://git.infradead.org/ps3/mars-src.git).

I agree that task_map_elf ideally ought to be modified to
handle any arbitrary set of ELF segments.


Mit freundlichen Gruessen / Best Regards

Ulrich Weigand

--
  Dr. Ulrich Weigand | Phone: +49-7031/16-3727
  STSM, GNU compiler and toolchain for Linux on System z and Cell/B.E.
  IBM Deutschland Research & Development GmbH
  Vorsitzender des Aufsichtsrats: Martin Jetter | Geschäftsführung: Dirk
Wittkopp
  Sitz der Gesellschaft: Böblingen | Registergericht: Amtsgericht
Stuttgart, HRB 243294



More information about the cbe-oss-dev mailing list