This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: Linking images at one address, but loading them at another.
- To: Nick Clifton <nickc at cambridge dot redhat dot com>
- Subject: Re: Linking images at one address, but loading them at another.
- From: Richard Earnshaw <rearnsha at arm dot com>
- Date: Fri, 26 Oct 2001 10:09:48 +0100
- cc: Richard dot Earnshaw at arm dot com, binutils at sources dot redhat dot com
- Organization: ARM Ltd.
- Reply-To: Richard dot Earnshaw at arm dot com
> Hi Richard,
>
> > However, this image contains symbols, if I try to strip the image
> > (eg to remove debug data):
> >
> > arm-elf-strip -g -o os os.gdb
> > BFD: netbsd: warning: allocated section `.text' not in segment
>
> Not sure about this one. It sounds like a bug in strip. Can you
> create a small example for us to test ?
Attached below. Should work with pretty much any ELF toolchain. Note,
however, that the example is not executable.
Compile with
gcc -g t.c
link with
ld -T ldscript.sample -o t.gdb t.o
strip with
strip -g -o t t.gdb
>
> > Is there some other way of setting the load address of a segment
> > symbolically?
>
> This sounds like a job for memory regions. For example this script:
OK, I'll give this a go. Thanks for the tip.
Richard
PHDRS
{
headers PT_PHDR PHDRS ;
text PT_LOAD AT (0x10000) ;
data PT_LOAD ;
}
SECTIONS
{
.lotext 0x10000 : { *(.lotext) } :text
.text (0xa0110000 + SIZEOF (.lotext)) :
AT ( LOADADDR(.lotext) + SIZEOF ( .lotext ) )
{
*(.text)
*(.glue_7t) *(.glue_7)
} :text =0
. = ALIGN(256) + (. & (256 - 1));
.data : AT ( LOADADDR(.text) + SIZEOF ( .text ) )
{
*(.data)
} :data
.bss :
{
*(.bss)
*(COMMON)
. = ALIGN(32 / 8);
}
. = ALIGN(32 / 8);
}
void highfunc(void);
void (*func)(void) = highfunc;
void start() __attribute__((section(".lotext")));
void start()
{
(*func)();
}
void highfunc()
{
}