diff options
Diffstat (limited to 'ld')
-rw-r--r-- | ld/ChangeLog | 8 | ||||
-rw-r--r-- | ld/NEWS | 6 | ||||
-rw-r--r-- | ld/ld.texinfo | 17 | ||||
-rw-r--r-- | ld/ldlang.c | 33 |
4 files changed, 53 insertions, 11 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog index cadb3f0..42cfec7 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,11 @@ +2006-08-22 Alan Modra <amodra@bigpond.net.au> + + * NEWS: Mention LMA default change. + * ld.texinfo (Output Section LMA): Update default description. + (Location Counter): Clarify backward movement. + * ldlang.c (lang_size_sections_1): Leave non-alloc sections with + default lma equal to vma. Warn on backward movement of dot. + 2006-08-22 Pedro Alves <pedro_alves@portugalmail.pt> * Makefile.am: Split arm-wince into its own emulation. @@ -1,4 +1,10 @@ -*- text -*- +* The default output section LMA has changed for allocatable sections from + being equal to VMA, to keeping the difference between LMA and VMA the same as + the previous output section in the same region. This is a more useful + default when using overlays and other cases where you specify an LMA + differing from the VMA for some sections. + * New switch: --print-gc-sections to list any sections removed by garabge collection. diff --git a/ld/ld.texinfo b/ld/ld.texinfo index 835482d..ea21283 100644 --- a/ld/ld.texinfo +++ b/ld/ld.texinfo @@ -3764,15 +3764,20 @@ Every section has a virtual address (VMA) and a load address (LMA); see an output section description sets the VMA (@pxref{Output Section 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. +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}. 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. + +If neither @code{AT} nor @code{AT>} is specified for an allocatable +section, the linker will set the LMA such that the difference between +VMA and LMA for the section is the same as the preceding output +section in the same region. If there is no preceding output section +or the section is not allocatable, the linker will set the LMA equal +to the VMA. @xref{Output Section Region}. @cindex ROM initialized data @@ -4586,7 +4591,9 @@ anywhere that an ordinary symbol is allowed in an expression. @cindex holes Assigning a value to @code{.} will cause the location counter to be moved. This may be used to create holes in the output section. The -location counter may never be moved backwards. +location counter may not be moved backwards inside an output section, +and may not be moved backwards outside of an output section if so +doing creates areas with overlapping LMAs. @smallexample SECTIONS diff --git a/ld/ldlang.c b/ld/ldlang.c index e478bd8..df5c33c 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -4400,16 +4400,30 @@ lang_size_sections_1 lma = align_power (lma, os->section_alignment); os->bfd_section->lma = lma; } - else if (r->last_os != NULL) + else if (r->last_os != NULL + && (os->bfd_section->flags & SEC_ALLOC) != 0) { bfd_vma lma; asection *last; last = r->last_os->output_section_statement.bfd_section; - /* If dot moved backwards (which is invalid according - to ld docs) then leave lma equal to vma. This - keeps users of buggy ld scripts happy. */ - if (dot >= last->vma) + + /* A backwards move of dot should be accompanied by + an explicit assignment to the section LMA (ie. + os->load_base set) because backwards moves normally + create overlapping LMAs. */ + if (dot < last->vma) + { + einfo (_("%P: warning: dot moved backwards before `%s'\n"), + os->name); + + /* If dot moved backwards then leave lma equal to + vma. This is the old default lma, which might + just happen to work when the backwards move is + sufficiently large. Nag anyway, so people fix + their linker scripts. */ + } + else { /* If the current vma overlaps the previous section, then set the current lma to that at the end of @@ -4440,9 +4454,16 @@ lang_size_sections_1 lma region. We use this to set the lma for following sections. Overlays or other linker script assignment to lma might mean that the - default lma == vma is incorrect. */ + default lma == vma is incorrect. + To avoid warnings about dot moving backwards when using + -Ttext, don't start tracking sections until we find one + of non-zero size or with lma set differently to vma. */ if (((os->bfd_section->flags & SEC_HAS_CONTENTS) != 0 || (os->bfd_section->flags & SEC_THREAD_LOCAL) == 0) + && (os->bfd_section->flags & SEC_ALLOC) != 0 + && (os->bfd_section->size != 0 + || os->bfd_section->vma != os->bfd_section->lma + || r->last_os != NULL) && os->lma_region == NULL && !link_info.relocatable) r->last_os = s; |