diff options
author | Alan Modra <amodra@gmail.com> | 2006-08-22 07:41:05 +0000 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2006-08-22 07:41:05 +0000 |
commit | dc0b6aa05a3bb1de236f5cf81cfe1dab70bec879 (patch) | |
tree | d17846acd1c9be928639dbbe3169d5805ed717e0 /ld/ldlang.c | |
parent | 0e2a4ebaf06499fe6d2883e9b8df8bfc19558cd5 (diff) | |
download | gdb-dc0b6aa05a3bb1de236f5cf81cfe1dab70bec879.zip gdb-dc0b6aa05a3bb1de236f5cf81cfe1dab70bec879.tar.gz gdb-dc0b6aa05a3bb1de236f5cf81cfe1dab70bec879.tar.bz2 |
* 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.
Diffstat (limited to 'ld/ldlang.c')
-rw-r--r-- | ld/ldlang.c | 33 |
1 files changed, 27 insertions, 6 deletions
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; |