This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: Fix ia64 linker crash when reporting non-pic code error


On Tue, 2005-04-26 at 15:38, H. J. Lu wrote:
> 	* elfxx-ia64.c (elfNN_ia64_relocate_section): Get the local
> 	symbol name when reporting non-pic code error.

I see 3 places that use h->root.root.string to report an error for a
dynamic symbol.  You only fixed one of them.  I think they should all be
fixed.

I see 2 existing places that use bfd_elf_string_from_elf_section.  You
are adding a third.  If you fix the other 2 cases you missed, then we
have 5 copies of this code total.  I think this should be extracted out
into a macro or inline function, so that we only have one copy of this
code.

It isn't clear why the code you added is trivially different than the
existing two cases.  They should all be the same.  Looking at
bfd_elf_string_from_elf_section, I see that it can return NULL, which
looks like it can only happen if there was an error elsewhere, so the
existing code for this seems more correct than your version.

Alternatively, looking at elf32-ppc.c, I see that it doesn't use
bfd_elf_string_from_elf_section for this at all.  That is only used if
it needs to make a bfd_get_section_by_name call.  Instead, there is a
variable sym_name, that gets set from a bfd_elf_sym_name call for local
symbols, and from h->root.root.string for globals.  I see that
bfd_elf_sym_name calls bfd_elf_string_from_elf_section, so effectively
this ends up the same result.  This may be a better solution.  This
nicely avoids the need for 5 copies of this code, though it does mean
that we are calling bfd_elf_sym_name many times, which may make the
linker a little slower.
-- 
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]