This is the mail archive of the crossgcc@sources.redhat.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


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

ppc-elf cross compiling: how get segments to load here with value but have addresses there?


I have a .ld file for my build with a test section that clearly 
demonstrates my problem. Given the following section (.odell):

MEMORY
{
    /* 64MB: SDRAM (2, 16Mbit x 16 chips)
    */
    sdram (rwx) : ORIGIN = 0x00000000, LENGTH = 64M
}

SECTIONS 
{
    /* Vectors and text segments allocated here 
    */
     
    /* My test segment.
    */
    .odell : AT(7M) { *(.odell) } > sdram
}

When I define a variable in a C file as:

unsigned int g_odell __attribute__ ((section (".odell"))) = 0xDEADFACE;

and then build, I get:

.odell          0x0003a794        0x4 load address 0x00700000
 *(.odell)
 .odell         0x0003a794        0x4 foo.o
                0x0003a794                g_odell

Looks good, my image is packed up nice and tight and my g_odell var. will 
live happily at 0x00700000... wrong. The value 0xDEADFACE is stored at 
0x0003a794, the run-time address of g_odell. This is half of what I 
expected. I do want the value at 0x0003a794 but I need the address to be 
0x00700000. I have assembly that will copy the value from 0x0003a794 to 
0x00700000 but with the linker defining g_odell at 0x0003a794 I'm screwed.

Swapping things around like:

SECTIONS 
{
    /* Vectors and text segments allocated here 
    */
    AFTER_TEXT = .;

    /* My test segment.
    */
    .odell 7M : AT(AFTER_TEXT) { *(.odell) } > sdram
}

and I get this:

.odell          0x00700000        0x4 load address 0x0003a794
 *(.odell)
 .odell         0x00700000        0x4 foo.o
                0x00700000                g_odell

This would put my variable at the correct address but it makes my image 
size huge and does not put the value at 0x0003a794 for copying to 
0x00700000 (the value is place at 0x00700000) so I'm still out of luck.

So (finally the question), how do I get the variable to have an address of 
0x00700000 but have its value placed at 0x0003a794 thus keeping the image 
size to a minimum? This is dead simple with Diab's DLD linker but I cannot 
get this to work with powerpc-elf-ld.

Thanks.

-- 
- Mark A. Odell
- Embedded Firmware Design, Inc.
- http://www.embeddedfw.com



------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com


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