X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=bfd%2Felflink.c;h=cee59096a522f79d07c95841371829c7b303ca0c;hb=8c37241be3b1baf394090269b4b67babceb83d61;hp=32f42641689637c73f1573b56aae7df2d06c50b0;hpb=42edda508ef24ada777099d51f200a3b674a1724;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/elflink.c b/bfd/elflink.c index 32f4264168..cee59096a5 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -622,8 +622,36 @@ _bfd_elf_link_renumber_dynsyms (bfd *output_bfd, struct bfd_link_info *info) { asection *p; for (p = output_bfd->sections; p ; p = p->next) - if ((p->flags & SEC_EXCLUDE) == 0) - elf_section_data (p)->dynindx = ++dynsymcount; + if ((p->flags & SEC_EXCLUDE) == 0 + && (p->flags & SEC_ALLOC) != 0) + switch (elf_section_data (p)->this_hdr.sh_type) + { + case SHT_PROGBITS: + case SHT_NOBITS: + /* If sh_type is yet undecided, assume it could be + SHT_PROGBITS/SHT_NOBITS. */ + case SHT_NULL: + if (strcmp (p->name, ".got") == 0 + || strcmp (p->name, ".got.plt") == 0 + || strcmp (p->name, ".plt") == 0) + { + asection *ip; + bfd *dynobj = elf_hash_table (info)->dynobj; + + if (dynobj != NULL + && (ip = bfd_get_section_by_name (dynobj, p->name)) + != NULL + && (ip->flags & SEC_LINKER_CREATED) + && ip->output_section == p) + continue; + } + elf_section_data (p)->dynindx = ++dynsymcount; + break; + /* There shouldn't be section relative relocations + against any other section. */ + default: + break; + } } if (elf_hash_table (info)->dynlocal) @@ -4621,6 +4649,7 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd, if (!is_elf_hash_table (info->hash)) return TRUE; + elf_tdata (output_bfd)->relro = info->relro; if (info->execstack) elf_tdata (output_bfd)->stack_flags = PF_R | PF_W | PF_X; else if (info->noexecstack) @@ -7654,16 +7683,18 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info) bfd_byte *dest; long dynindx; - indx = elf_section_data (s)->this_idx; dynindx = elf_section_data (s)->dynindx; + if (dynindx <= 0) + continue; + indx = elf_section_data (s)->this_idx; BFD_ASSERT (indx > 0); sym.st_shndx = indx; sym.st_value = s->vma; dest = dynsym + dynindx * bed->s->sizeof_sym; + if (last_local < dynindx) + last_local = dynindx; bed->s->swap_symbol_out (abfd, &sym, dest, 0); } - - last_local = bfd_count_sections (abfd); } /* Write out the local dynsyms. */