aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>1997-06-11 16:59:00 +0000
committerIan Lance Taylor <ian@airs.com>1997-06-11 16:59:00 +0000
commit8519ea2120056aed56c20011dca7c4d72d806a61 (patch)
tree06039844f5c6bff006dbe5742ef9841c6dfd620f
parentb4a3d2217687d8f8706285ba423dfb3430890f11 (diff)
downloadgdb-8519ea2120056aed56c20011dca7c4d72d806a61.zip
gdb-8519ea2120056aed56c20011dca7c4d72d806a61.tar.gz
gdb-8519ea2120056aed56c20011dca7c4d72d806a61.tar.bz2
* elflink.h (elf_link_output_extsym): Call finish_dynamic_symbol
for a symbol which is being forced to be local. * elf32-i386.c (elf_i386_relocate_section): Write out the relocation value for a GOT reloc for a symbol which is turning into a local symbol. (elf_i386_finish_dynamic_symbol): If a symbol is turning into a local symbol, write out a RELATIVE reloc rather than a GLOB_DAT reloc. * elf32-m68k.c, elf32-sparc.c: Corresponding changes.
-rw-r--r--bfd/ChangeLog12
-rw-r--r--bfd/elf32-i386.c24
-rw-r--r--bfd/elf32-m68k.c26
-rw-r--r--bfd/elf32-sparc.c24
-rw-r--r--bfd/elflink.h29
5 files changed, 66 insertions, 49 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 474a1db..4d827dd 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,15 @@
Wed Jun 11 00:00:07 1997 Ian Lance Taylor <ian@cygnus.com>
+ * elflink.h (elf_link_output_extsym): Call finish_dynamic_symbol
+ for a symbol which is being forced to be local.
+ * elf32-i386.c (elf_i386_relocate_section): Write out the
+ relocation value for a GOT reloc for a symbol which is turning
+ into a local symbol.
+ (elf_i386_finish_dynamic_symbol): If a symbol is turning into a
+ local symbol, write out a RELATIVE reloc rather than a GLOB_DAT
+ reloc.
+ * elf32-m68k.c, elf32-sparc.c: Corresponding changes.
+
* elf32-i386.c (elf_i386_relocate_section): Get the relocation
value if the symbol is turning into a local symbol.
* elf32-m68k.c (elf_m68k_relocate_section): Likewise.
@@ -10,7 +20,7 @@ Wed Jun 11 00:00:07 1997 Ian Lance Taylor <ian@cygnus.com>
* elflink.h (elf_link_add_object_symbols): Also read verneed
information by calling `_bfd_elf_slurp_version_tables'.
(elf_link_add_object_symbols): For undefined symbols look for
- version informaiton in the verneed records.
+ version information in the verneed records.
(elf_link_add_object_symbols): Use soname of shared object
for verneed record if it is available.
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index a871a7f..91f0c50 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -1179,7 +1179,7 @@ elf_i386_relocate_section (output_bfd, info, input_bfd, input_section,
|| (r_type == R_386_GOT32
&& elf_hash_table (info)->dynamic_sections_created
&& (! info->shared
- || ! info->symbolic
+ || (! info->symbolic && h->dynindx != -1)
|| (h->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR) == 0))
|| (info->shared
@@ -1241,15 +1241,16 @@ elf_i386_relocate_section (output_bfd, info, input_bfd, input_section,
if (! elf_hash_table (info)->dynamic_sections_created
|| (info->shared
- && info->symbolic
+ && (info->symbolic || h->dynindx == -1)
&& (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)))
{
/* This is actually a static link, or it is a
-Bsymbolic link and the symbol is defined
- locally. We must initialize this entry in the
- global offset table. Since the offset must
- always be a multiple of 4, we use the least
- significant bit to record whether we have
+ locally, or the symbol was forced to be local
+ because of a version file. We must initialize
+ this entry in the global offset table. Since the
+ offset must always be a multiple of 4, we use the
+ least significant bit to record whether we have
initialized it already.
When doing a dynamic link, we create a .rel.got
@@ -1623,8 +1624,6 @@ elf_i386_finish_dynamic_symbol (output_bfd, info, h, sym)
/* This symbol has an entry in the global offset table. Set it
up. */
- BFD_ASSERT (h->dynindx != -1);
-
sgot = bfd_get_section_by_name (dynobj, ".got");
srel = bfd_get_section_by_name (dynobj, ".rel.got");
BFD_ASSERT (sgot != NULL && srel != NULL);
@@ -1634,11 +1633,12 @@ elf_i386_finish_dynamic_symbol (output_bfd, info, h, sym)
+ (h->got_offset &~ 1));
/* If this is a -Bsymbolic link, and the symbol is defined
- locally, we just want to emit a RELATIVE reloc. The entry in
- the global offset table will already have been initialized in
- the relocate_section function. */
+ locally, we just want to emit a RELATIVE reloc. Likewise if
+ the symbol was forced to be local because of a version file.
+ The entry in the global offset table will already have been
+ initialized in the relocate_section function. */
if (info->shared
- && info->symbolic
+ && (info->symbolic || h->dynindx == -1)
&& (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR))
rel.r_info = ELF32_R_INFO (0, R_386_RELATIVE);
else
diff --git a/bfd/elf32-m68k.c b/bfd/elf32-m68k.c
index fe24d4b..1d763a9 100644
--- a/bfd/elf32-m68k.c
+++ b/bfd/elf32-m68k.c
@@ -1125,7 +1125,7 @@ elf_m68k_relocate_section (output_bfd, info, input_bfd, input_section,
"_GLOBAL_OFFSET_TABLE_") != 0))
&& elf_hash_table (info)->dynamic_sections_created
&& (! info->shared
- || ! info->symbolic
+ || (! info->symbolic && h->dynindx != -1)
|| (h->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR) == 0))
|| (info->shared
@@ -1197,16 +1197,17 @@ elf_m68k_relocate_section (output_bfd, info, input_bfd, input_section,
if (!elf_hash_table (info)->dynamic_sections_created
|| (info->shared
- && info->symbolic
+ && (info->symbolic || h->dynindx == -1)
&& (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)))
{
/* This is actually a static link, or it is a
-Bsymbolic link and the symbol is defined
- locally. We must initialize this entry in the
- global offset table. Since the offset must
- always be a multiple of 4, we use the least
- significant bit to record whether we have
- initialized it already.
+ locally, or the symbol was forced to be local
+ because of a version file.. We must initialize
+ this entry in the global offset table. Since
+ the offset must always be a multiple of 4, we
+ use the least significant bit to record whether
+ we have initialized it already.
When doing a dynamic link, we create a .rela.got
relocation entry to initialize the value. This
@@ -1607,8 +1608,6 @@ elf_m68k_finish_dynamic_symbol (output_bfd, info, h, sym)
/* This symbol has an entry in the global offset table. Set it
up. */
- BFD_ASSERT (h->dynindx != -1);
-
sgot = bfd_get_section_by_name (dynobj, ".got");
srela = bfd_get_section_by_name (dynobj, ".rela.got");
BFD_ASSERT (sgot != NULL && srela != NULL);
@@ -1618,11 +1617,12 @@ elf_m68k_finish_dynamic_symbol (output_bfd, info, h, sym)
+ (h->got_offset &~ 1));
/* If this is a -Bsymbolic link, and the symbol is defined
- locally, we just want to emit a RELATIVE reloc. The entry in
- the global offset table will already have been initialized in
- the relocate_section function. */
+ locally, we just want to emit a RELATIVE reloc. Likewise if
+ the symbol was forced to be local because of a version file.
+ The entry in the global offset table will already have been
+ initialized in the relocate_section function. */
if (info->shared
- && info->symbolic
+ && (info->symbolic || h->dynindx == -1)
&& (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR))
{
rela.r_info = ELF32_R_INFO (0, R_68K_RELATIVE);
diff --git a/bfd/elf32-sparc.c b/bfd/elf32-sparc.c
index 3061515..4f29eeb 100644
--- a/bfd/elf32-sparc.c
+++ b/bfd/elf32-sparc.c
@@ -1050,7 +1050,7 @@ elf32_sparc_relocate_section (output_bfd, info, input_bfd, input_section,
|| r_type == R_SPARC_GOT22)
&& elf_hash_table (info)->dynamic_sections_created
&& (! info->shared
- || ! info->symbolic
+ || (! info->symbolic && h->dynindx != -1)
|| (h->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR) == 0))
|| (info->shared
@@ -1123,15 +1123,16 @@ elf32_sparc_relocate_section (output_bfd, info, input_bfd, input_section,
if (! elf_hash_table (info)->dynamic_sections_created
|| (info->shared
- && info->symbolic
+ && (info->symbolic || h->dynindx == -1)
&& (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)))
{
/* This is actually a static link, or it is a
-Bsymbolic link and the symbol is defined
- locally. We must initialize this entry in the
- global offset table. Since the offset must
- always be a multiple of 4, we use the least
- significant bit to record whether we have
+ locally, or the symbol was forced to be local
+ because of a version file. We must initialize
+ this entry in the global offset table. Since the
+ offset must always be a multiple of 4, we use the
+ least significant bit to record whether we have
initialized it already.
When doing a dynamic link, we create a .rela.got
@@ -1498,8 +1499,6 @@ elf32_sparc_finish_dynamic_symbol (output_bfd, info, h, sym)
/* This symbol has an entry in the global offset table. Set it
up. */
- BFD_ASSERT (h->dynindx != -1);
-
sgot = bfd_get_section_by_name (dynobj, ".got");
srela = bfd_get_section_by_name (dynobj, ".rela.got");
BFD_ASSERT (sgot != NULL && srela != NULL);
@@ -1509,11 +1508,12 @@ elf32_sparc_finish_dynamic_symbol (output_bfd, info, h, sym)
+ (h->got_offset &~ 1));
/* If this is a -Bsymbolic link, and the symbol is defined
- locally, we just want to emit a RELATIVE reloc. The entry in
- the global offset table will already have been initialized in
- the relocate_section function. */
+ locally, we just want to emit a RELATIVE reloc. Likewise if
+ the symbol was forced to be local because of a version file.
+ The entry in the global offset table will already have been
+ initialized in the relocate_section function. */
if (info->shared
- && info->symbolic
+ && (info->symbolic || h->dynindx == -1)
&& (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR))
rela.r_info = ELF32_R_INFO (0, R_SPARC_RELATIVE);
else
diff --git a/bfd/elflink.h b/bfd/elflink.h
index b295e10..0ac27da 100644
--- a/bfd/elflink.h
+++ b/bfd/elflink.h
@@ -4123,6 +4123,24 @@ elf_link_output_extsym (h, data)
((struct elf_link_hash_entry *) h->root.u.i.link, data));
}
+ /* Give the processor backend a chance to tweak the symbol value,
+ and also to finish up anything that needs to be done for this
+ symbol. */
+ if ((h->dynindx != -1
+ || (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0)
+ && elf_hash_table (finfo->info)->dynamic_sections_created)
+ {
+ struct elf_backend_data *bed;
+
+ bed = get_elf_backend_data (finfo->output_bfd);
+ if (! ((*bed->elf_backend_finish_dynamic_symbol)
+ (finfo->output_bfd, finfo->info, h, &sym)))
+ {
+ eoinfo->failed = true;
+ return false;
+ }
+ }
+
/* If this symbol should be put in the .dynsym section, then put it
there now. We have already know the symbol index. We also fill
in the entry in the .hash section. */
@@ -4139,17 +4157,6 @@ elf_link_output_extsym (h, data)
sym.st_name = h->dynstr_index;
- /* Give the processor backend a chance to tweak the symbol
- value, and also to finish up anything that needs to be done
- for this symbol. */
- bed = get_elf_backend_data (finfo->output_bfd);
- if (! ((*bed->elf_backend_finish_dynamic_symbol)
- (finfo->output_bfd, finfo->info, h, &sym)))
- {
- eoinfo->failed = true;
- return false;
- }
-
elf_swap_symbol_out (finfo->output_bfd, &sym,
(PTR) (((Elf_External_Sym *)
finfo->dynsym_sec->contents)