problem with initializing ppc-eabi r13 (sdata)
Matthew.R.Wette@jpl.nasa.gov
mwette@grover.jpl.nasa.gov
Fri Sep 20 07:35:00 GMT 2002
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
More information about the crossgcc
mailing list