From f1a3c588e8098ed08da5347c6a6124211dc7f6a2 Mon Sep 17 00:00:00 2001 From: dgutson Date: Fri, 12 Feb 2010 20:52:51 +0000 Subject: [PATCH] 2010-02-12 Daniel Gutson bfd/ * elf32-arm.c (elf32_arm_output_arch_local_syms): add missing mapping symbol to data only sections. ld/testsuite/ * ld-arm/arm-elf.exp (armelftests): New test case added. * ld-arm/data-only-map.s: New file. * ld-arm/data-only-map.d: New file. * ld-arm/data-only-map.ld: New file. --- bfd/ChangeLog | 5 +++++ bfd/elf32-arm.c | 31 ++++++++++++++++++++++++++++++- ld/testsuite/ChangeLog | 7 +++++++ ld/testsuite/ld-arm/arm-elf.exp | 3 +++ ld/testsuite/ld-arm/data-only-map.d | 13 +++++++++++++ ld/testsuite/ld-arm/data-only-map.ld | 16 ++++++++++++++++ ld/testsuite/ld-arm/data-only-map.s | 20 ++++++++++++++++++++ 7 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 ld/testsuite/ld-arm/data-only-map.d create mode 100644 ld/testsuite/ld-arm/data-only-map.ld create mode 100644 ld/testsuite/ld-arm/data-only-map.s diff --git a/bfd/ChangeLog b/bfd/ChangeLog index fd505bcfb9..a3bec444c6 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,8 @@ +2010-02-12 Daniel Gutson + + * elf32-arm.c (elf32_arm_output_arch_local_syms): add + missing mapping symbol to data only sections. + 2010-02-11 David S. Miller * elfxx-sparc.c (_bfd_sparc_elf_check_relocs): For R_SPARC_GOTDATA_OP_HIX22 diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index 8f8d32c664..06613692e7 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -13004,7 +13004,9 @@ arm_map_one_stub (struct bfd_hash_entry * gen_entry, return TRUE; } -/* Output mapping symbols for linker generated sections. */ +/* Output mapping symbols for linker generated sections, + and for those data-only sections that do not have a + $d. */ static bfd_boolean elf32_arm_output_arch_local_syms (bfd *output_bfd, @@ -13019,6 +13021,7 @@ elf32_arm_output_arch_local_syms (bfd *output_bfd, struct elf32_arm_link_hash_table *htab; bfd_vma offset; bfd_size_type size; + bfd *input_bfd; htab = elf32_arm_hash_table (info); if (htab == NULL) @@ -13030,6 +13033,32 @@ elf32_arm_output_arch_local_syms (bfd *output_bfd, osi.info = info; osi.func = func; + /* Add a $d mapping symbol to data-only sections that + don't have any mapping symbol. This may result in (harmless) redundant + mapping symbols. */ + for (input_bfd = info->input_bfds; + input_bfd != NULL; + input_bfd = input_bfd->link_next) + { + if ((input_bfd->flags & (BFD_LINKER_CREATED | HAS_SYMS)) == HAS_SYMS) + for (osi.sec = input_bfd->sections; + osi.sec != NULL; + osi.sec = osi.sec->next) + { + if (osi.sec->output_section != NULL + && (osi.sec->flags & (SEC_HAS_CONTENTS | SEC_LINKER_CREATED)) + == SEC_HAS_CONTENTS + && get_arm_elf_section_data (osi.sec) != NULL + && get_arm_elf_section_data (osi.sec)->mapcount == 0) + { + osi.sec_shndx = _bfd_elf_section_from_bfd_section + (output_bfd, osi.sec->output_section); + if (osi.sec_shndx != (int)SHN_BAD) + elf32_arm_output_map_sym (&osi, ARM_MAP_DATA, 0); + } + } + } + /* ARM->Thumb glue. */ if (htab->arm_glue_size > 0) { diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index b67acb02d5..0b00887fd1 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2010-02-12 Daniel Gutson + + * ld-arm/arm-elf.exp (armelftests): New test case added. + * ld-arm/data-only-map.s: New file. + * ld-arm/data-only-map.d: New file. + * ld-arm/data-only-map.ld: New file. + 2010-02-11 David S. Miller * ld-sparc/gotop32.s: Add local symbol case. diff --git a/ld/testsuite/ld-arm/arm-elf.exp b/ld/testsuite/ld-arm/arm-elf.exp index 9d600846f0..a207a79a95 100644 --- a/ld/testsuite/ld-arm/arm-elf.exp +++ b/ld/testsuite/ld-arm/arm-elf.exp @@ -241,6 +241,9 @@ set armelftests { {"Relocation boundaries" "-defsym x=0 -defsym y=0 -defsym _start=0" "" {reloc-boundaries.s} {{objdump -s reloc-boundaries.d}} "reloc-boundaries"} + {"Data only mapping symbols" "-T data-only-map.ld -Map map" "" {data-only-map.s} + {{objdump -dr data-only-map.d}} + "data-only-map"} } run_ld_link_tests $armelftests diff --git a/ld/testsuite/ld-arm/data-only-map.d b/ld/testsuite/ld-arm/data-only-map.d new file mode 100644 index 0000000000..39eed874bb --- /dev/null +++ b/ld/testsuite/ld-arm/data-only-map.d @@ -0,0 +1,13 @@ + +[^:]*: file format elf32-littlearm + + +Disassembly of section \.text: + +00000000 <_start>: + 0: eb01 0002 add\.w r0, r1, r2 + 4: eb010002 \.word 0xeb010002 + 8: eb01 0002 add\.w r0, r1, r2 + c: eb01 0200 add\.w r2, r1, r0 + 10: eb010002 \.word 0xeb010002 + 14: eb010002 \.word 0xeb010002 diff --git a/ld/testsuite/ld-arm/data-only-map.ld b/ld/testsuite/ld-arm/data-only-map.ld new file mode 100644 index 0000000000..7d6ea92371 --- /dev/null +++ b/ld/testsuite/ld-arm/data-only-map.ld @@ -0,0 +1,16 @@ +/* Script for ld testsuite */ +OUTPUT_ARCH(arm) +ENTRY(_start) +SECTIONS +{ + .text : + { + *(.text) + *(.after1) + *(.after2) + *(.after3) + *(.after4) + *(.after5) + } =0 +} + diff --git a/ld/testsuite/ld-arm/data-only-map.s b/ld/testsuite/ld-arm/data-only-map.s new file mode 100644 index 0000000000..0c5e7978b5 --- /dev/null +++ b/ld/testsuite/ld-arm/data-only-map.s @@ -0,0 +1,20 @@ +.syntax unified +.thumb +.global _start +_start: +add.w r0, r1, r2 + +.section .after1 +.word 0xeb010002 + +.section .after2 +add.w r0, r1, r2 + +.section .after3 +add.w r2, r1, r0 + +.section .after4 +.word 0xeb010002 + +.section .after5 +.word 0xeb010002 -- 2.11.0