aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf32-i386.c
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>1994-10-27 21:25:31 +0000
committerIan Lance Taylor <ian@airs.com>1994-10-27 21:25:31 +0000
commit14cac507a88e921a16b8847ffe8ade8e7e8160b3 (patch)
treec05a389c67f4a9cca9ec34989e065b75df2dc731 /bfd/elf32-i386.c
parentc51975113da1ac36f42768dbbeb6bc90545be5f8 (diff)
downloadgdb-14cac507a88e921a16b8847ffe8ade8e7e8160b3.zip
gdb-14cac507a88e921a16b8847ffe8ade8e7e8160b3.tar.gz
gdb-14cac507a88e921a16b8847ffe8ade8e7e8160b3.tar.bz2
* libelf.h (struct bfd_elf_section_data): Add field dynindx.
* elfcode.h (NAME(bfd_elf,size_dynamic_sections)): Don't finalize the .dynsym, .dynstr or .hash sections until after the backend size_dynamic_sections routine, so that it can add dynamic symbols if it wants to. * elf32-i386.c (elf_i386_adjust_dynamic_symbol): Don't define the symbol to be in the .plt section when generating a shared library if it is a defined symbol. * elf32-sparc.c (elf32_sparc_adjust_dynamic_symbol): Likewise. (elf32_sparc_size_dynamic_sections): When generating a shared library, allocate space for a dynamic symbol for each output section, storing the index in the dynindx field of the ELF section data. Adjust the other dynindx fields to account for this. (elf32_sparc_adjust_dynindx): New static function. (elf32_sparc_relocate_section): When copying a reloc into a shared library, use the original addend as appropriate. Convert an R_SPARC_32 reloc into an R_SPARC_RELATIVE reloc. Use the dynamic symbol index of the output section, not the normal symbol index. (elf32_sparc_finish_dynamic_sections): Don't die if a section does not exist when setting the value of the dynamic tags. Write out a dynamic symbol for each output section.
Diffstat (limited to 'bfd/elf32-i386.c')
-rw-r--r--bfd/elf32-i386.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index 14f4b71..60c0f45 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -542,9 +542,9 @@ elf_i386_check_relocs (abfd, info, sec, relocs)
if (info->shared
&& (sec->flags & SEC_ALLOC) != 0)
{
- /* When creating a shared object, we must output a
- R_386_RELATIVE reloc for this location. We create a
- reloc section in dynobj and make room for this reloc. */
+ /* When creating a shared object, we must copy these
+ reloc types into the output file. We create a reloc
+ section in dynobj and make room for this reloc. */
if (sreloc == NULL)
{
const char *name;
@@ -647,9 +647,15 @@ elf_i386_adjust_dynamic_symbol (info, h)
if (s->_raw_size == 0)
s->_raw_size += PLT_ENTRY_SIZE;
- /* Set the symbol to this location in the .plt. */
- h->root.u.def.section = s;
- h->root.u.def.value = s->_raw_size;
+ /* If we are not generating a shared library, or if the symbol
+ is not defined, set the symbol to this location in the .plt.
+ This is required to make function pointers compare as equal
+ between the normal executable and the shared library. */
+ if (! info->shared || h->root.type != bfd_link_hash_defined)
+ {
+ h->root.u.def.section = s;
+ h->root.u.def.value = s->_raw_size;
+ }
h->plt_offset = s->_raw_size;