This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [RFC] Fix PR 16910: Relocate symbol correctly if it is wrapped
- From: Yao Qi <yao at codesourcery dot com>
- To: <binutils at sourceware dot org>
- Cc: <amodra at gmail dot com>
- Date: Fri, 9 May 2014 15:50:58 +0800
- Subject: Re: [RFC] Fix PR 16910: Relocate symbol correctly if it is wrapped
- Authentication-results: sourceware.org; auth=none
- References: <1399541408-12698-1-git-send-email-yao at codesourcery dot com> <20140509040512 dot GG5162 at bubble dot grove dot modra dot org>
On 05/09/2014 12:05 PM, Alan Modra wrote:
> The above function call is looking up the name of the .symtab section,
> but using .strtab rather than the correct string table for section
> names, .shstrtab. I'm sure that's not what you intended, and it says
Ur, I must do something wrong in the cleanup and the this mistake isn't
found by running the example in PR 16910 on x86-linux and arm-linux.
> that this patch hasn't been tested very well, if at all..
>
> I suspect that the right approach is
>
> h = sym_hashes[r_symndx - symtab_hdr->sh_info];
> if (info->wrap_hash != NULL
> && (input_section->flags & SEC_DEBUGGING) != 0)
> {
> retrieve name from h->root.root.string, strip off possible
> prefix (see bfd_wrapped_link_hash_lookup)
> if we now have a string starting with "__wrap_", look up
> the remainder in wrap_hash, and if that matches, look up
> the remainder in the main hash.
> }
Patch below is updated per your advice here. I configured binutils as
"--disable-gdb --enable-targets=all --enable-64-bit-bfd" on
x86_64-linux and run 'make check'. There is no change in binutils.sum,
gas.sum and ld.sum. Let me know if testing in other ways is needed.
--
Yao (éå)
bfd:
2014-05-09 Yao Qi <yao@codesourcery.com>
PR ld/16910
* elf-bfd.h (RELOC_FOR_GLOBAL_SYMBOL): If the symbol is from a
debug section and is wrapped, look for it instead of the wrapped
one.
---
bfd/elf-bfd.h | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index 2c02135..791ece9 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -2431,6 +2431,33 @@ extern asection _bfd_elf_large_com_section;
\
h = sym_hashes[r_symndx - symtab_hdr->sh_info]; \
\
+ if (info->wrap_hash != NULL \
+ && (input_section->flags & SEC_DEBUGGING) != 0) \
+ { \
+ const char *l; \
+ \
+ l = h->root.root.string; \
+ if (*l == bfd_get_symbol_leading_char (input_bfd) \
+ || *l == info->wrap_char) \
+ ++l; /* Strip off possible prefix. */ \
+ \
+ if (CONST_STRNEQ (l, "__wrap_") \
+ && bfd_hash_lookup (info->wrap_hash, \
+ l + sizeof "__wrap_" - 1, FALSE, \
+ FALSE) != NULL) \
+ { \
+ /* If the string L starts with "__wrap_" and the \
+ remainder is found in wrap_hash, the symbol is \
+ wrapped. The attributes of debugging information \
+ are about the original symbol instead of the wrapped \
+ one. Look up the remainder in the main hash. */ \
+ h = ((struct elf_link_hash_entry *) \
+ bfd_link_hash_lookup (info->hash, \
+ l + sizeof "__wrap_" - 1, \
+ FALSE, TRUE, FALSE)); \
+ } \
+ } \
+ \
while (h->root.type == bfd_link_hash_indirect \
|| h->root.type == bfd_link_hash_warning) \
h = (struct elf_link_hash_entry *) h->root.u.i.link; \
--
1.9.0