Binutils 2.9.1 LD failure with AT(0)

Eric Devolder ra3677@email.sps.mot.com
Thu Jun 4 21:54:00 GMT 1998


Hello all, I believe this to be the most appropriate group(s) for this
posting; if not, please let me know!

I've installed Bintutils 2.9.1 in conjuction with Egcs 1.0.3 for PowerPC
cross-compile environment hosted on a Solaris machine. I'm using the
cross-development environment to generate an S-record that can be used
to program a ROM. However, I believe that I've isolated a bug in LD that
prevents this from successfully working.

With the linker script below, I am using the SHADOW symbol in
conjunction with AT() to establish the address at which to locate all
.text and .data in the ROM image.

SHADOW = 0x00000000;

MEMORY
{
    rom     : org = 0x20000000, len = 0x00080000
    ram     : org = 0x00002000, len = 0x0000E000
}

SECTIONS
{
    .text   : AT(SHADOW)
    {
        *(.text)
        *(.rodata)
        PROVIDE (__DATA_ROM = .);
    } > rom

    .data   : AT(SHADOW + SIZEOF(.text))
    {
        PROVIDE (__DATA_RAM = .);
        *(.data)
        *(.got)
        PROVIDE (__DATA_END = .);
    } > ram

    .bss (NOLOAD)   :
    {
        PROVIDE(__BSS_START = .);
       *(.bss)
       *(COMMON)
       PROVIDE(__BSS_END = .);
    } > ram

    dbug (NOLOAD)   :
    {
        PROVIDE(__HEAP_START = .);
        . = . + 0x00000800;
        PROVIDE(__HEAP_END = .);
        PROVIDE(__FCR_START = .);
        . = . + 0x00000800;
        PROVIDE(__FCR_END = .);
        PROVIDE(__SP_END = .);
        . = . + 0x00002000;
        PROVIDE(__SP_INIT = .);
    } > ram

    .sdata (NOLOAD)     :
    {
        *(.sdata)
        *(.sbss)
    } > ram

    .sdata2 (NOLOAD)     :
    {
        *(.sdata2)
        *(.sbss2)
    } > ram

    /DISCARD/ :
    {
        *(*)
    }
}


 After building the final executable, I use objdump to display the
section headers:

a.out:     file format elf32-powerpc

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .text         00051e6c  20000000  20000000  00010000  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  1 .data         000001ec  00002000  00051e6c  00002000  2**2
                  CONTENTS, ALLOC, LOAD, DATA
  2 .bss          00008b30  000021f0  000021f0  000021f0  2**4
                  ALLOC
  3 dbug          00003000  0000ad20  0000ad20  00061e6c  2**0
                  CONTENTS
  4 .sdata        00000000  0000dd20  0000dd20  000051f0  2**2
                  ALLOC
  5 .sdata2       00000000  0000dd20  0000dd20  000051f0  2**2
                  ALLOC, READONLY

The problem here is that the LMA for .text is not ZERO, instead it is
the same as the VMA. Notice, however, that the LMA for .data is correct.

If I simply change the SHADOW symbol value to be non-zero, for example
0x00000004, here is what I get after rebuilding and using objdump:

a.out:     file format elf32-powerpc

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .text         00051e6c  20000000  00000004  00010000  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  1 .data         000001ec  00002000  00051e70  00002000  2**2
                  CONTENTS, ALLOC, LOAD, DATA
  2 .bss          00008b30  000021f0  000021f0  000021f0  2**4
                  ALLOC
  3 dbug          00003000  0000ad20  0000ad20  00061e6c  2**0
                  CONTENTS
  4 .sdata        00000000  0000dd20  0000dd20  000051f0  2**2
                  ALLOC
  5 .sdata2       00000000  0000dd20  0000dd20  000051f0  2**2
                  ALLOC, READONLY

Notice now that the LMA correctly reflects the SHADOW value.

There must be hundreds if not thousands of other people doing this very
thing. Can somebody help me out? If I'm doing something wrong, please
let me know. But it seems that using AT(0) isn't working in bin2.9.1. (I
don't know if this does or does not work in previous versions.)

Thanks in advance,
Eric




More information about the Gcc-bugs mailing list