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]
Other format: [Raw text]

Re: problem with initializing ppc-eabi r13 (sdata)


Jay,

I tried your suggestion and came up with the same result.
The mapfile from ld shows the start of .sdata to be 0xa4a8
and the address loaded into r13 is 0x124a8.

Matt

> You want to use the address of _SDA_BASE_, not the contents.  In C,
> it would look like this:
> 
>     int main(int argc, char **argv) {
>         extern void _SDA_BASE_;
>         printf("_SDA_BASE_ = 0x%08x\n", (int) &_SDA_BASE_);
>         exit(0);
>     }
> 
> In your _start, you can try this to set r13 = _SDA_BASE_:
> 
>     lis  13,_SDA_BASE_@ha
>     addi 13,13,_SDA_BASE_@l
> 
> On Friday 20 September 2002 10:35 am, mwette@grover.jpl.nasa.gov wrote:
> > I am looking for insight/help in working with the GNU loader.  I am
> > trying to work with my own versions of startup code, etc to understand
> > how _start, _eabi, main, crt0, ... all work together.  I am using
> > gcc-2.95.3, binutils-2.12.1, gdb-5.2, all compiled on suse-linux 7.2
> > for target powerpc-eabi.  I am running against the (psim) simulator
> > in gdb via "run -e bug".
> >
> > Here is the problem.  I want to initialize r13 with the address of the
> > start of .sdata segment.  If I look in the map file that is generated
> > by the loader, this address, given by _SDA_BASE_, is 0xa5a8.  When I
> > copy _SDA_BASE_ to "v1" and print it out from the program I get 0x125a8.
> > Bitwise these are
> >
> > 	0xa5a8		0000 0000 0000 0000 1010 0101 1010 0100
> > 	0x125a8		0000 0000 0000 0001 0010 0101 1010 0100
> >                                           ^ ^
> > Does anyone have a clue what is going on here and what I might be going
> > wrong?   Any help would be appreciated.  Relevant snippets of code
> > included below.
> >
> > Thanks,
> > Matt
> >
> >
> > --- run ---
> >
> > 	albacore$ powerpc-eabi-run -e bug load4
> > 	v1=0x125a8 (_SDA_BASE_)
> >
> >
> > --- load4.map ---
> >
> > .sdata          0x0000a5a8      0x120
> >                 0x0000a5a8                PROVIDE (__sda_base, .)
> >                 0x0000a5a8                __sdata_start = .
> >
> >
> > --- main.c ---
> >
> > 	unsigned long v1;
> >
> > 	printf("v1=0x%x (_SDA_BASE_)\n", v1);
> >
> >
> > --- Makefile ---
> > load4: main.o kos.o kos1.o kos0.o kos_i.o kos_n.o kos4b.ld
> >         powerpc-eabi-ld -o load4 \
> >                 -M >load4.map \
> >                 -g -N -Bstatic -T kos4b.ld \
> >                 -L/usr/local/powerpc-eabi/lib \
> >                 kos_i.o \
> >                 main.o kos.o kos1.o kos0.o \
> >                 -lucos1 --start-group -lmvme -lc --end-group \
> >                 kos_n.o
> >
> >
> > --- kos_i.S ---
> >
> > 	.section ".sdata","aw"
> > 	.weak	_SDA_BASE_
> > 	.type	_SDA_BASE_,@object
> > _SDA_BASE_:
> >
> >
> > --- kos1.S (startup code) ---
> >
> > 	.section ".got"
> > 	.align 2
> > .LCTOC1 = .
> > .Ltable = .-.LCTOC1
> > .Lsda   = .-.LCTOC1
> > 	.long	_SDA_BASE_
> >
> > _start:
> > 	...
> > 	.extern v1
> > 	lwz	%r7,.Lsda(%r5)
> > 	lis	%r6,v1@ha
> > 	stw	%r7,v1@l(%r6)
> >
> >
> > --- kos4b.ld ---
> >
> > PHDRS
> > {
> >   headers PT_PHDR FILEHDR PHDRS ;
> >   text PT_LOAD ;			/* text */
> >   data PT_LOAD ;			/* data */
> > }
> >
> > SECTIONS
> > {
> >   .text :
> >   {
> >     . = 0x0000;
> >     kos0.o(.text)
> >     . = 0x3000;
> >     kos1.o(.text)
> >     kos.o(.text)
> >     *(.text)
> >   } :text =0
> >   PROVIDE (__etext = .); PROVIDE (_etext = .); PROVIDE (etext = .);
> >   .sdata : {
> >     PROVIDE(__sda_base = . );
> >     __sdata_start = . ;
> >     *(.sdata)
> >     __sdata_end = . ;
> >     kos*(.sbss)
> >     *(.sbss)
> >   } :data = 0
> >   ...
> >
> >
> >
> > ------
> > Want more information?  See the CrossGCC FAQ,
> > http://www.objsw.com/CrossGCC/ Want to unsubscribe? Send a note to
> > crossgcc-unsubscribe@sources.redhat.com

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


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