Memory Command - Red Hat ENTERPRISE LINUX 3 - USING ID Using Instructions

Using ld, the gnu linker
Hide thumbs Also See for ENTERPRISE LINUX 3 - USING ID:
Table of Contents

Advertisement

Chapter 4. Linker Scripts
At the end of the overlay, the value of the location counter is set to the start address of the overlay plus
the size of the largest section.
Here is an example. Remember that this would appear inside a
OVERLAY 0x1000 : AT (0x4000)
{
.text0 { o1/*.o(.text) }
.text1 { o2/*.o(.text) }
}
This will define both
address 0x4000, and
will
be
defined:
__load_stop_text1
C code to copy overlay
extern char __load_start_text1, __load_stop_text1;
memcpy ((char *) 0x1000, &__load_start_text1,
&__load_stop_text1 - &__load_start_text1);
Note that the
OVERLAY
the more basic commands. The above example could have been written identically as follows.
.text0 0x1000 : AT (0x4000) { o1/*.o(.text) }
__load_start_text0 = LOADADDR (.text0);
__load_stop_text0 = LOADADDR (.text0) + SIZEOF (.text0);
.text1 0x1000 : AT (0x4000 + SIZEOF (.text0)) { o2/*.o(.text) }
__load_start_text1 = LOADADDR (.text1);
__load_stop_text1 = LOADADDR (.text1) + SIZEOF (.text1);
. = 0x1000 + MAX (SIZEOF (.text0), SIZEOF (.text1));

4.7. MEMORY Command

The linker's default configuration permits allocation of all available memory. You can override this by
using the
command.
MEMORY
The
command describes the location and size of blocks of memory in the target. You can use
MEMORY
it to describe which memory regions may be used by the linker, and which memory regions it must
avoid. You can then assign sections to particular memory regions. The linker will set section addresses
based on the memory regions, and will warn about regions that become too full. The linker will not
shuffle sections around to fit into the available regions.
A linker script may contain at most one use of the
many blocks of memory within it as you wish. The syntax is:
MEMORY
{
[(
)] : ORIGIN =
name
attr
...
}
The
is a name used in the linker script to refer to the region. The region name has no meaning
name
outside of the linker script. Region names are stored in a separate name space, and will not conflict
with symbol names, file names, or section names. Each memory region must have a distinct name.
The
string is an optional list of attributes that specify whether to use a particular memory region
attr
for an input section which is not explicitly mapped in the linker script. As described in Section 4.6
and
.text0
.text1
will be loaded immediately after
.text1
__load_start_text0
.
into the overlay area might look like the following.
.text1
command is just syntactic sugar, since everything it does can be done using
origin
SECTIONS
to start at address 0x1000.
,
__load_stop_text0
command. However, you can define as
MEMORY
, LENGTH =
len
construct.
will be loaded at
.text0
. The following symbols
.text0
,
__load_start_text1
45
,

Advertisement

Table of Contents
loading

This manual is also suitable for:

Enterprise linux 3

Table of Contents