From 2f4754876fee13c0bed40782e439e1a589f5caae Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Thu, 19 Oct 2006 02:10:41 +0000 Subject: [PATCH] bfd/ * elf32-arm.c (bfd_elf32_arm_allocate_interworking_sect): Check, don't set, glue section size. (record_arm_to_thumb_glue): Set glue section size here. (record_thumb_to_arm_glue): Likewise. (bfd_elf32_arm_add_glue_sections_to_bfd): Formatting. (bfd_elf32_arm_process_before_allocation): Ignore exluded sections. ld/ * emultempl/armelf.em (arm_elf_before_allocation): Run gld${EMULATION_NAME}_before_allocation later. * ldlang.c (lang_size_sections_1): Revert 2006-09-15 change. --- bfd/ChangeLog | 9 +++++++++ bfd/elf32-arm.c | 23 ++++++++++++++++------- ld/ChangeLog | 9 ++++++++- ld/ldlang.c | 18 ++++++------------ 4 files changed, 39 insertions(+), 20 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index c558fac..dde37b4 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,12 @@ +2006-10-19 Alan Modra + + * elf32-arm.c (bfd_elf32_arm_allocate_interworking_sect): Check, + don't set, glue section size. + (record_arm_to_thumb_glue): Set glue section size here. + (record_thumb_to_arm_glue): Likewise. + (bfd_elf32_arm_add_glue_sections_to_bfd): Formatting. + (bfd_elf32_arm_process_before_allocation): Ignore exluded sections. + 2006-10-18 Roy Marples * elf64-sparc.c: Add FreeBSD support. diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index f9f668f..06adaef 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -2565,7 +2565,7 @@ bfd_elf32_arm_allocate_interworking_sections (struct bfd_link_info * info) foo = bfd_alloc (globals->bfd_of_glue_owner, globals->arm_glue_size); - s->size = globals->arm_glue_size; + BFD_ASSERT (s->size == globals->arm_glue_size); s->contents = foo; } @@ -2580,7 +2580,7 @@ bfd_elf32_arm_allocate_interworking_sections (struct bfd_link_info * info) foo = bfd_alloc (globals->bfd_of_glue_owner, globals->thumb_glue_size); - s->size = globals->thumb_glue_size; + BFD_ASSERT (s->size == globals->thumb_glue_size); s->contents = foo; } @@ -2600,6 +2600,7 @@ record_arm_to_thumb_glue (struct bfd_link_info * link_info, struct bfd_link_hash_entry * bh; struct elf32_arm_link_hash_table * globals; bfd_vma val; + bfd_size_type size; globals = elf32_arm_hash_table (link_info); @@ -2643,9 +2644,12 @@ record_arm_to_thumb_glue (struct bfd_link_info * link_info, free (tmp_name); if ((link_info->shared || globals->root.is_relocatable_executable)) - globals->arm_glue_size += ARM2THUMB_PIC_GLUE_SIZE; + size = ARM2THUMB_PIC_GLUE_SIZE; else - globals->arm_glue_size += ARM2THUMB_STATIC_GLUE_SIZE; + size = ARM2THUMB_STATIC_GLUE_SIZE; + + s->size += size; + globals->arm_glue_size += size; return myh; } @@ -2721,6 +2725,7 @@ record_thumb_to_arm_glue (struct bfd_link_info *link_info, free (tmp_name); + s->size += THUMB2ARM_GLUE_SIZE; hash_table->thumb_glue_size += THUMB2ARM_GLUE_SIZE; return; @@ -2748,7 +2753,8 @@ bfd_elf32_arm_add_glue_sections_to_bfd (bfd *abfd, /* Note: we do not include the flag SEC_LINKER_CREATED, as this will prevent elf_link_input_bfd() from processing the contents of this section. */ - flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_CODE | SEC_READONLY; + flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY + | SEC_CODE | SEC_READONLY); sec = bfd_make_section_with_flags (abfd, ARM2THUMB_GLUE_SECTION_NAME, @@ -2767,8 +2773,8 @@ bfd_elf32_arm_add_glue_sections_to_bfd (bfd *abfd, if (sec == NULL) { - flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY - | SEC_CODE | SEC_READONLY; + flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY + | SEC_CODE | SEC_READONLY); sec = bfd_make_section_with_flags (abfd, THUMB2ARM_GLUE_SECTION_NAME, @@ -2865,6 +2871,9 @@ bfd_elf32_arm_process_before_allocation (bfd *abfd, if (sec->reloc_count == 0) continue; + if ((sec->flags & SEC_EXCLUDE) != 0) + continue; + symtab_hdr = &elf_tdata (abfd)->symtab_hdr; /* Load the relocs. */ diff --git a/ld/ChangeLog b/ld/ChangeLog index 33bbe3d..99b3340 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,6 +1,13 @@ +2006-10-19 Alan Modra + + * emultempl/armelf.em (arm_elf_before_allocation): Run + gld${EMULATION_NAME}_before_allocation later. + * ldlang.c (lang_size_sections_1): Revert 2006-09-15 change. + 2006-10-18 Roy Marples - * emulparams/elf64_sparc_fbsd.sh (OUTPUT_FORMAT): Define as elf64-sparc-freebsd. + * emulparams/elf64_sparc_fbsd.sh (OUTPUT_FORMAT): Define as + elf64-sparc-freebsd. 2006-10-18 Joseph Myers diff --git a/ld/ldlang.c b/ld/ldlang.c index d9b8ac9..2c9426e 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -4368,18 +4368,12 @@ lang_size_sections_1 os->processed_vma = TRUE; if (bfd_is_abs_section (os->bfd_section) || os->ignored) - { - if (os->bfd_section->size > 0) - { - /* PR ld/3107: Do not abort when a buggy linker script - causes a non-empty section to be discarded. */ - if (bfd_is_abs_section (os->bfd_section)) - einfo (_("%P%X: internal error: attempting to take the size of the non-section *ABS*\n")); - else - einfo (_("%P: warning: discarding non-empty, well known section %A\n"), - os->bfd_section); - } - } + /* Except for some special linker created sections, + no output section should change from zero size + after strip_excluded_output_sections. A non-zero + size on an ignored section indicates that some + input section was not sized early enough. */ + ASSERT (os->bfd_section->size == 0); else { dot = os->bfd_section->vma; -- 2.7.4