From 6bdafbeb578394fd9fff6c45b15f71dd5678190b Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Tue, 13 Jan 2004 11:10:53 +0000 Subject: [PATCH] * ldlang.c (lang_get_regions): Add extra parameter 'have_vma' which if true will prevent the LMA region being used as a replacement for a default VMA region. (lang_leave_output_section_statement): Pass extra parameter. (lang_leave_overlay): Likewise. * ld.texinfo (Output Section LMA): Document that the LMA region can be set to the VMA region if no VMA has been set. * ldlang.h (struct lang_output_section_phdr_list): Create a typedef for this type. Minor formatting fixes. --- ld/ChangeLog | 12 +++++ ld/ld.texinfo | 15 ++++-- ld/ldlang.c | 46 ++++++++-------- ld/ldlang.h | 147 ++++++++++++++++++++++++++++++-------------------- 4 files changed, 135 insertions(+), 85 deletions(-) diff --git a/ld/ChangeLog b/ld/ChangeLog index c1bc1c2b83b..9a9563c9d53 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,15 @@ +2004-01-13 Nick Clifton + + * ldlang.c (lang_get_regions): Add extra parameter 'have_vma' + which if true will prevent the LMA region being used as a + replacement for a default VMA region. + (lang_leave_output_section_statement): Pass extra parameter. + (lang_leave_overlay): Likewise. + * ld.texinfo (Output Section LMA): Document that the LMA + region can be set to the VMA region if no VMA has been set. + * ldlang.h (struct lang_output_section_phdr_list): Create a + typedef for this type. Minor formatting fixes. + 2004-01-13 Nick Clifton * ldlang.c (lang_size_sections_1): If dot is advanced, then diff --git a/ld/ld.texinfo b/ld/ld.texinfo index 5ac6721ad17..f0faa8e9322 100644 --- a/ld/ld.texinfo +++ b/ld/ld.texinfo @@ -1,7 +1,7 @@ \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) @@ -61,7 +61,7 @@ END-INFO-DIR-ENTRY 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 @@ -106,7 +106,7 @@ notice identical to this one except for the removal of this paragraph @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 @@ -3362,8 +3362,13 @@ Address}). 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 diff --git a/ld/ldlang.c b/ld/ldlang.c index ac7ab332876..108ad584320 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -2828,7 +2828,7 @@ _("%X%P: section %s [%V -> %V] overlaps section %s [%V -> %V]\n"), 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) { @@ -4503,34 +4503,38 @@ lang_float (bfd_boolean maybe) 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; @@ -4689,7 +4693,7 @@ lang_record_phdrs (void) { 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; @@ -4708,7 +4712,7 @@ lang_record_phdrs (void) 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; @@ -4768,7 +4772,7 @@ lang_record_phdrs (void) 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; @@ -4785,7 +4789,7 @@ lang_record_phdrs (void) /* 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; @@ -4870,7 +4874,7 @@ lang_enter_overlay_section (const char *name) 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; @@ -4917,17 +4921,17 @@ lang_leave_overlay (etree_type *lma_expr, 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; @@ -4964,7 +4968,7 @@ lang_leave_overlay (etree_type *lma_expr, if (nocrossrefs) { - struct lang_nocrossref *nc; + lang_nocrossref_type *nc; nc = xmalloc (sizeof *nc); nc->name = l->os->name; diff --git a/ld/ldlang.h b/ld/ldlang.h index 87318b0501c..867eb142367 100644 --- a/ld/ldlang.h +++ b/ld/ldlang.h @@ -25,7 +25,8 @@ #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, @@ -34,17 +35,20 @@ typedef 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; @@ -56,9 +60,11 @@ typedef struct memory_region_struct { 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, @@ -79,24 +85,28 @@ typedef struct lang_statement_header_struct { } 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, @@ -105,16 +115,18 @@ enum section_type { 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; @@ -125,15 +137,15 @@ typedef struct lang_output_section_statement_struct { 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; @@ -143,25 +155,29 @@ typedef struct lang_output_section_statement_struct { 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; @@ -172,7 +188,8 @@ typedef struct { /* Generate a reloc in the output file. */ -typedef struct { +typedef struct +{ lang_statement_header_type header; /* Reloc to generate. */ @@ -181,12 +198,12 @@ typedef struct { /* 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. */ @@ -202,13 +219,14 @@ typedef struct { 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; @@ -222,9 +240,9 @@ typedef struct lang_input_statement_struct { /* 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; @@ -241,7 +259,6 @@ typedef struct lang_input_statement_struct { /* 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. */ @@ -259,20 +276,23 @@ typedef struct lang_input_statement_struct { 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; @@ -281,13 +301,15 @@ typedef struct lang_wild_statement_struct { 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; @@ -300,12 +322,14 @@ typedef struct { 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; @@ -328,7 +352,8 @@ typedef union lang_statement_union { /* 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; @@ -341,16 +366,18 @@ struct lang_phdr { /* 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; @@ -358,7 +385,8 @@ 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; }; @@ -366,7 +394,8 @@ struct unique_sections { /* 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; }; @@ -389,9 +418,9 @@ extern int lang_statement_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); @@ -431,15 +460,15 @@ extern void lang_startup 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 @@ -501,16 +530,16 @@ extern void lang_new_phdr (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; -- 2.30.2