diff options
author | Alan Modra <amodra@gmail.com> | 2005-11-16 07:17:20 +0000 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2005-11-16 07:17:20 +0000 |
commit | 7270c5edcbb158904a8f11852cad1261162d8308 (patch) | |
tree | 37fd2cd974829baa043b6de63893c3cc988e887f | |
parent | c43c547375e1864c2e784d026bac89c582b2de68 (diff) | |
download | ppe42-binutils-7270c5edcbb158904a8f11852cad1261162d8308.tar.gz ppe42-binutils-7270c5edcbb158904a8f11852cad1261162d8308.zip |
* ld.texinfo (Forced Output Alignment): Specify that this is an
alignment increase, not an override.
* ldlang.c (init_os): Set output section alignment here..
(lang_add_section): ..rather than here.
(lang_size_sections_1): Consolidate alignment code. Warn if section
alignment affects start address when explicit address given.
-rw-r--r-- | ld/ChangeLog | 9 | ||||
-rw-r--r-- | ld/ld.texinfo | 4 | ||||
-rw-r--r-- | ld/ldlang.c | 39 |
3 files changed, 27 insertions, 25 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog index ea25fd9c5d..60ff9b3871 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,12 @@ +2005-11-16 Alan Modra <amodra@bigpond.net.au> + + * ld.texinfo (Forced Output Alignment): Specify that this is an + alignment increase, not an override. + * ldlang.c (init_os): Set output section alignment here.. + (lang_add_section): ..rather than here. + (lang_size_sections_1): Consolidate alignment code. Warn if section + alignment affects start address when explicit address given. + 2005-11-07 Steve Ellcey <sje@cup.hp.com> * configure: Regenerate after modifying bfd/warning.m4. diff --git a/ld/ld.texinfo b/ld/ld.texinfo index 87dd20250f..c08f6927c2 100644 --- a/ld/ld.texinfo +++ b/ld/ld.texinfo @@ -3775,9 +3775,7 @@ for (dst = &_bstart; dst< &_bend; dst++) @kindex ALIGN(@var{section_align}) @cindex forcing output section alignment @cindex output section alignment -You can force an output section alignment by using ALIGN. The value -specified overrides any alignment given by input sections, whether -larger or smaller. +You can increase an output section's alignment by using ALIGN. @node Forced Input Alignment @subsubsection Forced Input Alignment diff --git a/ld/ldlang.c b/ld/ldlang.c index 496e9f86d6..8ceb8ad2e0 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -1720,6 +1720,10 @@ init_os (lang_output_section_statement_type *s, asection *isec) if (s->load_base != NULL) exp_init_os (s->load_base); + /* If supplied an alignment, set it. */ + if (s->section_alignment != -1) + s->bfd_section->alignment_power = s->section_alignment; + if (isec) bfd_init_private_section_data (isec->owner, isec, output_bfd, s->bfd_section, @@ -1941,10 +1945,6 @@ lang_add_section (lang_statement_list_type *ptr, if (section->alignment_power > output->bfd_section->alignment_power) output->bfd_section->alignment_power = section->alignment_power; - /* If supplied an alignment, then force it. */ - if (output->section_alignment != -1) - output->bfd_section->alignment_power = output->section_alignment; - if (bfd_get_arch (section->owner) == bfd_arch_tic54x && (section->flags & SEC_TIC54X_BLOCK) != 0) { @@ -4144,6 +4144,8 @@ lang_size_sections_1 } else { + bfd_vma savedot; + if (os->addr_tree == NULL) { /* No address specified for this section, get one @@ -4193,27 +4195,20 @@ lang_size_sections_1 } newdot = os->region->current; - - if (os->section_alignment == -1) - { - bfd_vma savedot = newdot; - newdot = align_power (newdot, - os->bfd_section->alignment_power); - - if (newdot != savedot - && config.warn_section_align - && expld.phase != lang_mark_phase_enum) - einfo (_("%P: warning: changing start of section" - " %s by %lu bytes\n"), - os->name, (unsigned long) (newdot - savedot)); - } } - /* The section starts here. - First, align to what the section needs. */ + /* Align to what the section needs. */ + savedot = newdot; + newdot = align_power (newdot, + os->bfd_section->alignment_power); - if (os->section_alignment != -1) - newdot = align_power (newdot, os->section_alignment); + if (newdot != savedot + && (config.warn_section_align + || os->addr_tree != NULL) + && expld.phase != lang_mark_phase_enum) + einfo (_("%P: warning: changing start of section" + " %s by %lu bytes\n"), + os->name, (unsigned long) (newdot - savedot)); bfd_set_section_vma (0, os->bfd_section, newdot); |