This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
link script question - adding sections at specific addresses
- To: binutils at sourceware dot cygnus dot com
- Subject: link script question - adding sections at specific addresses
- From: Becky Gill <bgill at ibmoto dot com>
- Date: Thu, 03 Aug 2000 19:50:04 -0500
- Organization: Motorola Semiconductor Products Sector
I have a few questions that I'm really hoping a linker expert out there can
shed some light on... I've RTFM (ld docs and the ABI for PowerPC) all I could
stand and still haven't been able to figure these out:
1) Can someone explain how to add another text section to an elf32 ppc linux
executable at a specific address? I need to add a new section of code that is
located several pages away from the rest of an application's text and data.
I've done a lot of playing around with the default elf32ppclinux.x script, but
I keep getting the "not enough room for program headers" message, depending on
where I put it. I can add the section, but not specify an address for it. What
are the rules/restrictions on doing this? Here's an excerpt - the rest of
the file is unmodified:
/* FYI - text starts around 0x10000000 */
.text :
{
*(.text)
*(.text.*)
*(.stub)
/* .gnu.warning sections are handled specially by elf32.em. */
*(.gnu.warning)
*(.gnu.linkonce.t*)
}
.fini :
{
KEEP (*(.fini))
} =0
/* My addition.... */
NEWLOC = 0x10f00000;
.newtext NEWLOC : AT (NEWLOC)
{
*(.newtext)
}
I can do this sort of thing without any problems with embedded standalone apps
like bootstraps and such. The problem seems to arise when I need to link
statically with libc.
2) Is there anything I need to specify in the .s file other than .section
".newtext", "ax"? to get the code placed properly?
3) Somewhat off-topic - Currently, the header information ends up in the text
by default. So if I specify a TEXT_START of 0x00000500, then my actual _start
symbol is actually at address 0x00000640 (or however much space was needed for
the headers). Is there a way to place the headers *before* TEXT_START so that
the _start symbol ends up at that address? (make TEXT_START = TEXT_START -
SIZEOF_HEADERS). I wasn't able to get this to work. I'm not concerned about
alignment - the code I'm generating with this script will be run in a sim
environment where alignment isn't an issue.
Thanks in advance for any advice!
-Becky
--
Becky L. Gill
PowerPC Core Design Technologies/Architecture & Performance
Motorola SPS, Austin (512) 996-4949