aboutsummaryrefslogtreecommitdiff
path: root/bfd/elflink.c
diff options
context:
space:
mode:
authorRichard Henderson <rth@redhat.com>1999-07-13 18:21:29 +0000
committerRichard Henderson <rth@redhat.com>1999-07-13 18:21:29 +0000
commit30b30c21815a6f23b0db7b135926f988ddff22a3 (patch)
tree3a29e627f94610eba3a177b83acd0ed54f8913d7 /bfd/elflink.c
parente1ee1229a2384e923b73ef5943141fa39d51fdff (diff)
downloadgdb-30b30c21815a6f23b0db7b135926f988ddff22a3.zip
gdb-30b30c21815a6f23b0db7b135926f988ddff22a3.tar.gz
gdb-30b30c21815a6f23b0db7b135926f988ddff22a3.tar.bz2
* elf-bfd.h (struct elf_link_local_dynamic_entry): New.
(struct elf_link_hash_table): Add dynlocal. (_bfd_elf_link_lookup_local_dynindx): Prototype. (_bfd_elf_link_adjust_dynindx): Delete. (_bfd_elf_link_renumber_dynsyms): Prototype. (_bfd_elf,link_record_local_dynamic_symbol): Prototype. * elfcode.h (elf_link_record_local_dynamic_symbol): New alias. * elflink.c (_bfd_elf_link_adjust_dynindx): Delete. (_bfd_elf_link_lookup_local_dynindx): New function. (elf_link_renumber_hash_table_dynsyms): New function. (_bfd_elf_link_renumber_dynsyms): New function. * elflink.h (elf_link_record_local_dynamic_symbol): New function. (struct elf_assign_sym_version_info): Delete removed_dynamic. (bfd_elf,size_dynamic_sections): Use _bfd_strip_section_from_output instead of elf_link_remove_section_and_adjust_dynindices. Remove removed_dynamic code. Use _bfd_elf_link_renumber_dynsyms. (elf_link_assign_sym_version): Remove removed_dynamic code. (elf_link_renumber_dynsyms): Delete. (elf_bfd_final_link): Install section and local symbols into .dynsym. * elf32-m68k.c (elf_m68k_adjust_dynindx): Delete. (elf_m68k_size_dynamic_sections): Don't set section dynindicies. (elf_m68k_finish_dynamic_sections): Don't write section dynsyms. * elf32-mips.c: Similarly. * elf32-ppc.c: Similarly. * elf32-sparc.c: Similarly. * elf64-alpha.c: Similarly. * elf64-sparc.c: Similarly.
Diffstat (limited to 'bfd/elflink.c')
-rw-r--r--bfd/elflink.c79
1 files changed, 70 insertions, 9 deletions
diff --git a/bfd/elflink.c b/bfd/elflink.c
index e26dedd..93155b1 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -260,22 +260,83 @@ _bfd_elf_link_record_dynamic_symbol (info, h)
return true;
}
-/* Increase the index at which H will appear in the dynamic symbol
- table by INCREMENT (which is really an `int *'). Called via
- elf_link_hash_traverse. */
+/* Return the dynindex of a local dynamic symbol. */
-boolean
-_bfd_elf_link_adjust_dynindx (h, increment)
+long
+_bfd_elf_link_lookup_local_dynindx (info, input_bfd, input_indx)
+ struct bfd_link_info *info;
+ bfd *input_bfd;
+ long input_indx;
+{
+ struct elf_link_local_dynamic_entry *e;
+
+ for (e = elf_hash_table (info)->dynlocal; e ; e = e->next)
+ if (e->input_bfd == input_bfd && e->input_indx == input_indx)
+ return e->dynindx;
+ return -1;
+}
+
+/* This function is used to renumber the dynamic symbols, if some of
+ them are removed because they are marked as local. This is called
+ via elf_link_hash_traverse. */
+
+static boolean elf_link_renumber_hash_table_dynsyms
+ PARAMS ((struct elf_link_hash_entry *, PTR));
+
+static boolean
+elf_link_renumber_hash_table_dynsyms (h, data)
struct elf_link_hash_entry *h;
- PTR increment;
+ PTR data;
{
+ size_t *count = (size_t *) data;
+
if (h->dynindx != -1)
- h->dynindx += *((int *) increment);
-
+ h->dynindx = ++(*count);
+
return true;
}
+
+/* Assign dynsym indicies. In a shared library we generate a section
+ symbol for each output section, which come first. Next come all of
+ the back-end allocated local dynamic syms, followed by the rest of
+ the global symbols. */
+
+unsigned long
+_bfd_elf_link_renumber_dynsyms (output_bfd, info)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+{
+ unsigned long dynsymcount = 0;
+
+ if (info->shared)
+ {
+ asection *p;
+ for (p = output_bfd->sections; p ; p = p->next)
+ elf_section_data (p)->dynindx = ++dynsymcount;
+ }
+
+ if (elf_hash_table (info)->dynlocal)
+ {
+ struct elf_link_local_dynamic_entry *p;
+ for (p = elf_hash_table (info)->dynlocal; p ; p = p->next)
+ p->dynindx = ++dynsymcount;
+ }
+
+ elf_link_hash_traverse (elf_hash_table (info),
+ elf_link_renumber_hash_table_dynsyms,
+ &dynsymcount);
+
+ /* There is an unused NULL entry at the head of the table which
+ we must account for in our count. Unless there weren't any
+ symbols, which means we'll have no table at all. */
+ if (dynsymcount != 0)
+ ++dynsymcount;
+
+ return elf_hash_table (info)->dynsymcount = dynsymcount;
+}
-/* Create a special linker section, or return a pointer to a linker section already created */
+/* Create a special linker section, or return a pointer to a linker
+ section already created */
elf_linker_section_t *
_bfd_elf_create_linker_section (abfd, info, which, defaults)