\input texinfo
@setfilename ld.info
@c Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-@c 2001, 2002, 2003 Free Software Foundation, Inc.
+@c 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
@syncodeindex ky cp
@include configdoc.texi
@c (configdoc.texi is generated by the Makefile)
This file documents the @sc{gnu} linker LD version @value{VERSION}.
Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 98, 99, 2000,
-2001, 2002, 2003 Free Software Foundation, Inc.
+2001, 2002, 2003, 2004 Free Software Foundation, Inc.
@ignore
@vskip 0pt plus 1filll
@c man begin COPYRIGHT
Copyright @copyright{} 1991, 92, 93, 94, 95, 96, 97, 98, 99, 2000, 2001,
-2002, 2003 Free Software Foundation, Inc.
+2002, 2003, 2004 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.1
The linker will normally set the LMA equal to the VMA. You can change
that by using the @code{AT} keyword. The expression @var{lma} that
follows the @code{AT} keyword specifies the load address of the
-section. Alternatively, with @samp{AT>@var{lma_region}} expression,
-you may specify a memory region for the section's load address. @xref{MEMORY}.
+section.
+
+Alternatively, with @samp{AT>@var{lma_region}} expression, you may
+specify a memory region for the section's load address. @xref{MEMORY}.
+Note that if the section has not had a VMA assigned to it then the
+linker will use the @var{lma_region} as the VMA region as well.
+@xref{Output Section Region}.
@cindex ROM initialized data
@cindex initialized data in ROM
static void
os_region_check (lang_output_section_statement_type *os,
- struct memory_region_struct *region,
+ lang_memory_region_type *region,
etree_type *tree,
bfd_vma base)
{
It is an error to specify both a load region and a load address. */
static void
-lang_get_regions (struct memory_region_struct **region,
- struct memory_region_struct **lma_region,
+lang_get_regions (lang_memory_region_type **region,
+ lang_memory_region_type **lma_region,
const char *memspec,
const char *lma_memspec,
- int have_lma_p)
+ bfd_boolean have_lma,
+ bfd_boolean have_vma)
{
*lma_region = lang_memory_region_lookup (lma_memspec, FALSE);
- /* If no runtime region has been given, but the load region has
- been, use the load region. */
- if (lma_memspec != 0 && strcmp (memspec, DEFAULT_MEMORY_REGION) == 0)
+ /* If no runtime region or VMA has been specified, but the load region has
+ been specified, then use the load region for the runtime region as well. */
+ if (lma_memspec != NULL
+ && ! have_vma
+ && strcmp (memspec, DEFAULT_MEMORY_REGION) == 0)
*region = *lma_region;
else
*region = lang_memory_region_lookup (memspec, FALSE);
- if (have_lma_p && lma_memspec != 0)
+ if (have_lma && lma_memspec != 0)
einfo (_("%X%P:%S: section has both a load address and a load region\n"));
}
void
-lang_leave_output_section_statement
- (fill_type *fill, const char *memspec,
- struct lang_output_section_phdr_list *phdrs, const char *lma_memspec)
+lang_leave_output_section_statement (fill_type *fill, const char *memspec,
+ lang_output_section_phdr_list *phdrs,
+ const char *lma_memspec)
{
lang_get_regions (¤t_section->region,
¤t_section->lma_region,
memspec, lma_memspec,
- current_section->load_base != 0);
+ current_section->load_base != NULL,
+ current_section->addr_tree != NULL);
current_section->fill = fill;
current_section->phdrs = phdrs;
stat_ptr = &statement_list;
{
unsigned int alc;
asection **secs;
- struct lang_output_section_phdr_list *last;
+ lang_output_section_phdr_list *last;
struct lang_phdr *l;
lang_statement_union_type *u;
u = u->output_section_statement.next)
{
lang_output_section_statement_type *os;
- struct lang_output_section_phdr_list *pl;
+ lang_output_section_phdr_list *pl;
os = &u->output_section_statement;
u != NULL;
u = u->output_section_statement.next)
{
- struct lang_output_section_phdr_list *pl;
+ lang_output_section_phdr_list *pl;
if (u->output_section_statement.bfd_section == NULL)
continue;
/* Record a list of sections which may not be cross referenced. */
void
-lang_add_nocrossref (struct lang_nocrossref *l)
+lang_add_nocrossref (lang_nocrossref_type *l)
{
struct lang_nocrossrefs *n;
void
lang_leave_overlay_section (fill_type *fill,
- struct lang_output_section_phdr_list *phdrs)
+ lang_output_section_phdr_list *phdrs)
{
const char *name;
char *clean, *s2;
int nocrossrefs,
fill_type *fill,
const char *memspec,
- struct lang_output_section_phdr_list *phdrs,
+ lang_output_section_phdr_list *phdrs,
const char *lma_memspec)
{
lang_memory_region_type *region;
lang_memory_region_type *lma_region;
struct overlay_list *l;
- struct lang_nocrossref *nocrossref;
+ lang_nocrossref_type *nocrossref;
lang_get_regions (®ion, &lma_region,
memspec, lma_memspec,
- lma_expr != 0);
+ lma_expr != NULL, FALSE);
nocrossref = NULL;
if (nocrossrefs)
{
- struct lang_nocrossref *nc;
+ lang_nocrossref_type *nc;
nc = xmalloc (sizeof *nc);
nc->name = l->os->name;
#define DEFAULT_MEMORY_REGION "*default*"
-typedef enum {
+typedef enum
+{
lang_input_file_is_l_enum,
lang_input_file_is_symbols_only_enum,
lang_input_file_is_marker_enum,
lang_input_file_is_file_enum
} lang_input_file_enum_type;
-struct _fill_type {
+struct _fill_type
+{
size_t size;
unsigned char data[1];
};
-typedef struct statement_list {
+typedef struct statement_list
+{
union lang_statement_union *head;
union lang_statement_union **tail;
} lang_statement_list_type;
-typedef struct memory_region_struct {
+typedef struct memory_region_struct
+{
char *name;
struct memory_region_struct *next;
bfd_vma origin;
bfd_boolean had_full_message;
} lang_memory_region_type;
-typedef struct lang_statement_header_struct {
+typedef struct lang_statement_header_struct
+{
union lang_statement_union *next;
- enum statement_enum {
+ enum statement_enum
+ {
lang_output_section_statement_enum,
lang_assignment_statement_enum,
lang_input_statement_enum,
} type;
} lang_statement_header_type;
-typedef struct {
+typedef struct
+{
lang_statement_header_type header;
union etree_union *exp;
} lang_assignment_statement_type;
-typedef struct lang_target_statement_struct {
+typedef struct lang_target_statement_struct
+{
lang_statement_header_type header;
const char *target;
} lang_target_statement_type;
-typedef struct lang_output_statement_struct {
+typedef struct lang_output_statement_struct
+{
lang_statement_header_type header;
const char *name;
} lang_output_statement_type;
/* Section types specified in a linker script. */
-enum section_type {
+enum section_type
+{
normal_section,
dsect_section,
copy_section,
overlay_section
};
-/* This structure holds a list of program headers describing segments
- in which this section should be placed. */
+/* This structure holds a list of program headers describing
+ segments in which this section should be placed. */
-struct lang_output_section_phdr_list {
+typedef struct lang_output_section_phdr_list
+{
struct lang_output_section_phdr_list *next;
const char *name;
bfd_boolean used;
-};
+} lang_output_section_phdr_list;
-typedef struct lang_output_section_statement_struct {
+typedef struct lang_output_section_statement_struct
+{
lang_statement_header_type header;
union etree_union *addr_tree;
lang_statement_list_type children;
bfd_boolean processed;
asection *bfd_section;
- flagword flags; /* Or together of all input sections */
+ flagword flags; /* Or together of all input sections. */
enum section_type sectype;
- struct memory_region_struct *region;
- struct memory_region_struct *lma_region;
+ lang_memory_region_type *region;
+ lang_memory_region_type *lma_region;
size_t block_value;
fill_type *fill;
- int subsection_alignment; /* alignment of components */
- int section_alignment; /* alignment of start of section */
+ int subsection_alignment; /* Alignment of components. */
+ int section_alignment; /* Alignment of start of section. */
union etree_union *load_base;
to move '.' past all the overlaid sections. */
union etree_union *update_dot_tree;
- struct lang_output_section_phdr_list *phdrs;
+ lang_output_section_phdr_list *phdrs;
} lang_output_section_statement_type;
-typedef struct {
+typedef struct
+{
lang_statement_header_type header;
} lang_common_statement_type;
-typedef struct {
+typedef struct
+{
lang_statement_header_type header;
} lang_object_symbols_statement_type;
-typedef struct {
+typedef struct
+{
lang_statement_header_type header;
fill_type *fill;
int size;
asection *output_section;
} lang_fill_statement_type;
-typedef struct {
+typedef struct
+{
lang_statement_header_type header;
unsigned int type;
union etree_union *exp;
/* Generate a reloc in the output file. */
-typedef struct {
+typedef struct
+{
lang_statement_header_type header;
/* Reloc to generate. */
/* Reloc howto structure. */
reloc_howto_type *howto;
- /* Section to generate reloc against. Exactly one of section and
- name must be NULL. */
+ /* Section to generate reloc against.
+ Exactly one of section and name must be NULL. */
asection *section;
- /* Name of symbol to generate reloc against. Exactly one of section
- and name must be NULL. */
+ /* Name of symbol to generate reloc against.
+ Exactly one of section and name must be NULL. */
const char *name;
/* Expression for addend. */
bfd_vma output_vma;
} lang_reloc_statement_type;
-typedef struct lang_input_statement_struct {
+typedef struct lang_input_statement_struct
+{
lang_statement_header_type header;
/* Name of this file. */
const char *filename;
- /* Name to use for the symbol giving address of text start */
- /* Usually the same as filename, but for a file spec'd with -l
- this is the -l switch itself rather than the filename. */
+ /* Name to use for the symbol giving address of text start.
+ Usually the same as filename, but for a file spec'd with
+ -l this is the -l switch itself rather than the filename. */
const char *local_sym_name;
bfd *the_bfd;
/* Point to the next file - whatever it is, wanders up and down
archives */
-
union lang_statement_union *next;
- /* Point to the next file, but skips archive contents */
+
+ /* Point to the next file, but skips archive contents. */
union lang_statement_union *next_real_file;
bfd_boolean is_archive;
/* 1 means this is base file of incremental load.
Do not load this file's text or data.
Also default text_start to after this file's bss. */
-
bfd_boolean just_syms_flag;
/* Whether to search for this entry as a dynamic archive. */
bfd_boolean real;
} lang_input_statement_type;
-typedef struct {
+typedef struct
+{
lang_statement_header_type header;
asection *section;
lang_input_statement_type *ifile;
} lang_input_section_type;
-typedef struct {
+typedef struct
+{
lang_statement_header_type header;
asection *section;
union lang_statement_union *file;
} lang_afile_asection_pair_statement_type;
-typedef struct lang_wild_statement_struct {
+typedef struct lang_wild_statement_struct
+{
lang_statement_header_type header;
const char *filename;
bfd_boolean filenames_sorted;
lang_statement_list_type children;
} lang_wild_statement_type;
-typedef struct lang_address_statement_struct {
+typedef struct lang_address_statement_struct
+{
lang_statement_header_type header;
const char *section_name;
union etree_union *address;
} lang_address_statement_type;
-typedef struct {
+typedef struct
+{
lang_statement_header_type header;
bfd_vma output_offset;
size_t size;
symbols are found. The effect is to search a group of libraries as
though they were a single library. */
-typedef struct {
+typedef struct
+{
lang_statement_header_type header;
lang_statement_list_type children;
} lang_group_statement_type;
-typedef union lang_statement_union {
+typedef union lang_statement_union
+{
lang_statement_header_type header;
lang_wild_statement_type wild_statement;
lang_data_statement_type data_statement;
/* This structure holds information about a program header, from the
PHDRS command in the linker script. */
-struct lang_phdr {
+struct lang_phdr
+{
struct lang_phdr *next;
const char *name;
unsigned long type;
/* This structure is used to hold a list of sections which may not
cross reference each other. */
-struct lang_nocrossref {
+typedef struct lang_nocrossref
+{
struct lang_nocrossref *next;
const char *name;
-};
+} lang_nocrossref_type;
/* The list of nocrossref lists. */
-struct lang_nocrossrefs {
+struct lang_nocrossrefs
+{
struct lang_nocrossrefs *next;
- struct lang_nocrossref *list;
+ lang_nocrossref_type *list;
};
extern struct lang_nocrossrefs *nocrossref_list;
/* This structure is used to hold a list of input section names which
will not match an output section in the linker script. */
-struct unique_sections {
+struct unique_sections
+{
struct unique_sections *next;
const char *name;
};
/* This structure records symbols for which we need to keep track of
definedness for use in the DEFINED () test. */
-struct lang_definedness_hash_entry {
+struct lang_definedness_hash_entry
+{
struct bfd_hash_entry root;
int iteration;
};
extern void lang_init
(void);
-extern struct memory_region_struct *lang_memory_region_lookup
+extern lang_memory_region_type *lang_memory_region_lookup
(const char *const, bfd_boolean);
-extern struct memory_region_struct *lang_memory_region_default
+extern lang_memory_region_type *lang_memory_region_default
(asection *);
extern void lang_map
(void);
extern void lang_float
(bfd_boolean);
extern void lang_leave_output_section_statement
- (fill_type *, const char *, struct lang_output_section_phdr_list *,
+ (fill_type *, const char *, lang_output_section_phdr_list *,
const char *);
extern void lang_abs_symbol_at_end_of
(const char *, const char *);
extern void lang_abs_symbol_at_beginning_of
(const char *, const char *);
extern void lang_statement_append
- (struct statement_list *, union lang_statement_union *,
- union lang_statement_union **);
+ (lang_statement_list_type *, lang_statement_union_type *,
+ lang_statement_union_type **);
extern void lang_for_each_input_file
(void (*dothis) (lang_input_statement_type *));
extern void lang_for_each_file
(const char *, etree_type *, bfd_boolean, bfd_boolean, etree_type *,
etree_type *);
extern void lang_add_nocrossref
- (struct lang_nocrossref *);
+ (lang_nocrossref_type *);
extern void lang_enter_overlay
(etree_type *, etree_type *);
extern void lang_enter_overlay_section
(const char *);
extern void lang_leave_overlay_section
- (fill_type *, struct lang_output_section_phdr_list *);
+ (fill_type *, lang_output_section_phdr_list *);
extern void lang_leave_overlay
(etree_type *, int, fill_type *, const char *,
- struct lang_output_section_phdr_list *, const char *);
+ lang_output_section_phdr_list *, const char *);
extern struct bfd_elf_version_tree *lang_elf_version_info;