aboutsummaryrefslogtreecommitdiff
path: root/bfd/linker.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2014-06-10 21:50:21 +0930
committerAlan Modra <amodra@gmail.com>2014-06-10 23:00:22 +0930
commit8a5da09b9e326a19e78b20a1021a5148ea0484b0 (patch)
treee925755d23c841b430e3e5f083c9edb22871ce7b /bfd/linker.c
parent0e58ee40a2cec3c4bf796980fb05f93540e40ec2 (diff)
downloadfsf-binutils-gdb-8a5da09b9e326a19e78b20a1021a5148ea0484b0.zip
fsf-binutils-gdb-8a5da09b9e326a19e78b20a1021a5148ea0484b0.tar.gz
fsf-binutils-gdb-8a5da09b9e326a19e78b20a1021a5148ea0484b0.tar.bz2
Unwrap symbols for debug information
Fixes issues with dwz multi-file (-m) and ld's -wrap option. Symbols referenced from DWARF debug info in a separate file, eg. to specify low and high pc, must use the real symbol. The DWARF info is specifying attributes of the real function, not one interposed with --wrap. include/ * bfdlink.h (unwrap_hash_lookup): Declare. bfd/ * linker.c (unwrap_hash_lookup): New function. * elf-bfd (RELOC_FOR_GLOBAL_SYMBOL): Call unwrap_hash_lookup. * elf32-i370.c (i370_elf_relocate_section): Likewise. * elf32-m32c.c (m32c_elf_relocate_section): Likewise. * elf32-m32r.c (m32r_elf_relocate_section): Likewise. * elf32-score.c (s3_bfd_score_elf_relocate_section): Likewise. * elf32-score7.c (s7_bfd_score_elf_relocate_section): Likewise. * elf32-spu.c (spu_elf_relocate_section): Likewise. * elf64-hppa.c (elf64_hppa_relocate_section): Likewise.
Diffstat (limited to 'bfd/linker.c')
-rw-r--r--bfd/linker.c38
1 files changed, 36 insertions, 2 deletions
diff --git a/bfd/linker.c b/bfd/linker.c
index a20a276..d00238c 100644
--- a/bfd/linker.c
+++ b/bfd/linker.c
@@ -566,8 +566,6 @@ bfd_wrapped_link_hash_lookup (bfd *abfd,
return h;
}
-#undef WRAP
-
#undef REAL
#define REAL "__real_"
@@ -602,6 +600,42 @@ bfd_wrapped_link_hash_lookup (bfd *abfd,
return bfd_link_hash_lookup (info->hash, string, create, copy, follow);
}
+/* If H is a wrapped symbol, ie. the symbol name starts with "__wrap_"
+ and the remainder is found in wrap_hash, return the real symbol. */
+
+struct bfd_link_hash_entry *
+unwrap_hash_lookup (struct bfd_link_info *info,
+ bfd *input_bfd,
+ struct bfd_link_hash_entry *h)
+{
+ const char *l = h->root.string;
+
+ if (*l == bfd_get_symbol_leading_char (input_bfd)
+ || *l == info->wrap_char)
+ ++l;
+
+ if (CONST_STRNEQ (l, WRAP))
+ {
+ l += sizeof WRAP - 1;
+
+ if (bfd_hash_lookup (info->wrap_hash, l, FALSE, FALSE) != NULL)
+ {
+ char save = 0;
+ if (l - sizeof WRAP - 1 != h->root.string)
+ {
+ --l;
+ save = *l;
+ *(char *) l = *h->root.string;
+ }
+ h = bfd_link_hash_lookup (info->hash, l, FALSE, FALSE, FALSE);
+ if (save)
+ *(char *) l = save;
+ }
+ }
+ return h;
+}
+#undef WRAP
+
/* Traverse a generic link hash table. Differs from bfd_hash_traverse
in the treatment of warning symbols. When warning symbols are
created they replace the real symbol, so you don't get to see the