diff options
author | Ian Lance Taylor <ian@airs.com> | 1994-07-22 18:53:23 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@airs.com> | 1994-07-22 18:53:23 +0000 |
commit | 7c6da9cade1c47d725fac11ddc9aaf921f85c22d (patch) | |
tree | 50cc77e306108de96cf41f87a4c731bdbae277c6 /bfd/elf32-sparc.c | |
parent | 36c6e8c37fc1ebc698b8d260c6ef09fe2d18ea69 (diff) | |
download | gdb-7c6da9cade1c47d725fac11ddc9aaf921f85c22d.zip gdb-7c6da9cade1c47d725fac11ddc9aaf921f85c22d.tar.gz gdb-7c6da9cade1c47d725fac11ddc9aaf921f85c22d.tar.bz2 |
* aoutx.h (aout_link_check_ar_symbols): When changing a symbol to
common, set the alignment.
(aout_link_add_symbols): Restrict the alignment of a common symbol
to the alignment power given by the architecture.
* elf.c (_bfd_elf_link_hash_newfunc): Don't initialize align. Do
initialize copy_offset.
* elf32-i386.c (elf_i386_adjust_dynamic_symbol): Use copy_offset
field rather than align field. Get alignment using bfd_log2
rather than switch.
* elf32-sparc.c (elf32_sparc_adjust_dynamic_symbol): Likewise.
* elf32-i386.c (elf_i386_finish_dynamic_symbol): Use copy_offset,
not align.
* elf32-sparc.c (elf32_sparc_finish_dynamic_symbol): Likewise.
Diffstat (limited to 'bfd/elf32-sparc.c')
-rw-r--r-- | bfd/elf32-sparc.c | 60 |
1 files changed, 16 insertions, 44 deletions
diff --git a/bfd/elf32-sparc.c b/bfd/elf32-sparc.c index 2733a1e..ec6d204 100644 --- a/bfd/elf32-sparc.c +++ b/bfd/elf32-sparc.c @@ -37,7 +37,7 @@ static boolean elf32_sparc_size_dynamic_sections PARAMS ((bfd *, struct bfd_link_info *)); static boolean elf32_sparc_relocate_section PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, - Elf_Internal_Rela *, Elf_Internal_Sym *, asection **)); + Elf_Internal_Rela *, Elf_Internal_Sym *, asection **, char *)); static boolean elf32_sparc_finish_dynamic_symbol PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *, Elf_Internal_Sym *)); @@ -294,7 +294,6 @@ elf32_sparc_adjust_dynamic_symbol (info, h) bfd *dynobj; asection *s; unsigned int power_of_two; - size_t align; dynobj = elf_hash_table (info)->dynobj; @@ -349,7 +348,7 @@ elf32_sparc_adjust_dynamic_symbol (info, h) BFD_ASSERT (h->weakdef->root.type == bfd_link_hash_defined); h->root.u.def.section = h->weakdef->root.u.def.section; h->root.u.def.value = h->weakdef->root.u.def.value; - h->align = (bfd_size_type) -1; + h->copy_offset = (bfd_vma) -1; return true; } @@ -373,55 +372,28 @@ elf32_sparc_adjust_dynamic_symbol (info, h) R_SPARC_COPY reloc to tell the dynamic linker to copy the initial value out of the dynamic object and into the runtime process image. We need to remember the offset into the .rel.bss section - we are going to use, and we coopt the align field for this - purpose (the align field is only used for common symbols, and - these symbols are always defined). It would be cleaner to use a - new field, but that would waste memory. */ + we are going to use. */ if ((h->root.u.def.section->flags & SEC_LOAD) == 0) - h->align = (bfd_size_type) -1; + h->copy_offset = (bfd_vma) -1; else { asection *srel; srel = bfd_get_section_by_name (dynobj, ".rela.bss"); BFD_ASSERT (srel != NULL); - h->align = srel->_raw_size; + h->copy_offset = srel->_raw_size; srel->_raw_size += sizeof (Elf32_External_Rela); } /* We need to figure out the alignment required for this symbol. I have no idea how ELF linkers handle this. */ - switch (h->size) - { - case 0: - case 1: - power_of_two = 0; - align = 1; - break; - case 2: - power_of_two = 1; - align = 2; - break; - case 3: - case 4: - power_of_two = 2; - align = 4; - break; - case 5: - case 6: - case 7: - case 8: - power_of_two = 3; - align = 8; - break; - default: - power_of_two = 4; - align = 16; - break; - } + power_of_two = bfd_log2 (h->size); + if (power_of_two > 3) + power_of_two = 3; /* Apply the required alignment. */ - s->_raw_size = BFD_ALIGN (s->_raw_size, align); + s->_raw_size = BFD_ALIGN (s->_raw_size, + (bfd_size_type) (1 << power_of_two)); if (power_of_two > bfd_get_section_alignment (dynobj, s)) { if (! bfd_set_section_alignment (dynobj, s, power_of_two)) @@ -517,7 +489,8 @@ elf32_sparc_size_dynamic_sections (output_bfd, info) static boolean elf32_sparc_relocate_section (output_bfd, info, input_bfd, input_section, - contents, relocs, local_syms, local_sections) + contents, relocs, local_syms, local_sections, + output_names) bfd *output_bfd; struct bfd_link_info *info; bfd *input_bfd; @@ -526,6 +499,7 @@ elf32_sparc_relocate_section (output_bfd, info, input_bfd, input_section, Elf_Internal_Rela *relocs; Elf_Internal_Sym *local_syms; asection **local_sections; + char *output_names; { Elf_Internal_Shdr *symtab_hdr; struct elf_link_hash_entry **sym_hashes; @@ -633,9 +607,7 @@ elf32_sparc_relocate_section (output_bfd, info, input_bfd, input_section, name = h->root.root.string; else { - name = elf_string_from_elf_section (input_bfd, - symtab_hdr->sh_link, - sym->st_name); + name = output_names + sym->st_name; if (name == NULL) return false; if (*name == '\0') @@ -724,7 +696,7 @@ elf32_sparc_finish_dynamic_symbol (output_bfd, info, h, sym) /* This is not a function. We have already allocated memory for it in the .bss section (via .dynbss). All we have to do here is create a COPY reloc if required. */ - if (h->align != (bfd_size_type) -1) + if (h->copy_offset != (bfd_vma) -1) { asection *s; Elf_Internal_Rela rela; @@ -740,7 +712,7 @@ elf32_sparc_finish_dynamic_symbol (output_bfd, info, h, sym) rela.r_addend = 0; bfd_elf32_swap_reloca_out (output_bfd, &rela, ((Elf32_External_Rela *) - (s->contents + h->align))); + (s->contents + h->copy_offset))); } } |