This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Attempt to relocate sections via linker script fails
- From: Ray Whitmer <ray at xmission dot com>
- To: binutils at sources dot redhat dot com
- Date: Wed, 31 Mar 2004 10:11:14 -0700 (MST)
- Subject: Attempt to relocate sections via linker script fails
I am trying to use the cross-linker m68k-coff-ld to link some code for an
embedded device.
I want to zero-base the parts of the compilation that will be loaded into
RAM and ROM, respectively (the generated code was pic, but relies on zero
basing).
After reading the documentation, I try to use the following linker command:
m68k-coff-ld test.spc test.o -o test
test.spc has the following content:
SECTIONS
{
RAM 0 (NOLOAD) : {
*(.bss)
}
ROM 0 (NOLOAD) : {
*(.text)
*(.data)
}
}
The link completes successfully with no errors, but when I dump the
resulting test executable, none of the sections seem to be relocated to 0, as
I expected.
Sections:
Idx Name Size VMA LMA File off Algn
0 RAM 00000000 00000000 00000000 00000000 2**2
ALLOC, NEVER_LOAD
1 .text 000000c4 01000000 01000000 00002000 2**2
CONTENTS, ALLOC, LOAD, CODE
2 .data 00000004 010000c4 010000c4 000020c4 2**2
CONTENTS, ALLOC, LOAD, DATA
3 .bss 00000012 010000c8 010000c8 00000000 2**2
ALLOC
RAM shows up, so it seems clear that the linker script has been read.
I expected the script to make .bss start at 0, and the sequence of .text and
.data to be likewise started at 0 and the size of RAM and ROM to reflect
these sections. While this lists RAM at base 0, .text, .data, and .bss seem
to have been not included, both in the base address, and the size of RAM,
and the absence of ROM.
I have tried changing the base addresses so they do not overlap and also
removing the NOLOAD specifier. Whatever I do, the base addresses of
.text, .data, and .bss still do not change.
I have tried using elf instead of coff, which changes the base addresses, but
still ignores my attempts to specify a different base address.
The coff ld says it does not support pic, but it was not obvious to me
that I need pic, since the code is already pic, and I will be using objdump
to pull out the ROM section to be downloaded into the device.
What do I have to do to get these sections to relocate?
Thanks,
Ray Whitmer