This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: MIPS question: _gp = (. + 0x8000);
- From: Jonathan Larmour <jifl at eCosCentric dot com>
- To: Michael Anburaj <embeddedeng at hotmail dot com>
- Cc: ecos-discuss at sources dot redhat dot com
- Date: Thu, 19 Feb 2004 06:19:44 +0000
- Subject: Re: [ECOS] MIPS question: _gp = (. + 0x8000);
- References: <BAY12-F52r8cgVtu8T30000988f@hotmail.com>
Michael Anburaj wrote:
Hi,
I have a question regarding the following line found in a lot of MIPS
linker scripts:
_gp = (. + 0x8000);
_gp gets loaded into $gp. How does this value ‘_gp’ relate with access
to .sdata & .sbss session using $gp?
Access to stuff in sdata/sbss uses different instructions that are more
efficient for small amounts of data. But the tradeoff is having to use a
fixed base register for accessing them. That is $gp. GCC/GAS generate
relocs relative to the _gp symbol, which the linker munges appropriately so
that as long as $gp points to _gp everything works.
Why is 0x8000 added (to the foot of .sdata section)? To Place $gp
halfway in the 64KB $gp accessible space??
Correct. The offsets that GCC uses are signed.
Can you point to a detailed material on this?
Here's the GCC info file about the -G argument on MIPS:
`-G NUM'
Put global and static items less than or equal to NUM bytes into
the small data or bss sections instead of the normal data or bss
section. This allows the assembler to emit one word memory
reference instructions based on the global pointer (GP or $28),
instead of the normal two words used. By default, NUM is 8 when
the MIPS assembler is used, and 0 when the GNU assembler is used.
The `-G NUM' switch is also passed to the assembler and linker.
All modules should be compiled with the same `-G NUM' value.
Jifl
--
eCosCentric http://www.eCosCentric.com/ The eCos and RedBoot experts
Visit us at Embedded World 2004, Nürnberg, Germany, 17-19 Feb, Stand 12-449
--["No sense being pessimistic, it wouldn't work anyway"]-- Opinions==mine
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss