This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: deleting relocs, objcopy and BFD
- From: jose dot marchesi at oracle dot com (Jose E. Marchesi)
- To: Nick Clifton <nickc at redhat dot com>
- Cc: binutils at sourceware dot org
- Date: Tue, 02 May 2017 18:47:07 +0200
- Subject: Re: deleting relocs, objcopy and BFD
- Authentication-results: sourceware.org; auth=none
- References: <878tmluaag.fsf@oracle.com> <303e32fb-9b29-7959-24e1-056d8042be35@redhat.com>
Hi Nick.
> Problem 1: incoherence with internal relocs and external relocs breaks> the API.
I am checking in the attached patch in order to stop objcopy from attempting
to merge notes when the internal reloc count is greater than the external
reloc count. This does not fix the underlying problem, but it should at
least make objcopy safe, for now.
That hack doesn't fix the problem for SPARC, nor the regression in the
testsuite.
This is because in SPARC in most cases (everything other than
R_SPARC_OLO10) there are the same number of internal relocs than
external relocs, and thus `relcount == sec->reloc_count' in this case.
However, in SPARC bfd_canonicalize_reloc always returns
((struct _bfd_sparc_elf_section_data *) elf_section_data (sec))->reloc_count
and not sec->reloc_count, so the segfault is still there..
> b) To remove the API limitation/bug in BFD, somehow. Maybe adding
> end-of-list sentinels to `sec->relocation' and `sec->orelocation',
> adjusting `bfd_set_reloc' to install it according to its `relcount'
> argument, leaving `sec->reloc_count' untouched, and also making
> `elfNN_BE_write_relocs' to use the sentinel when writing.
I think that option b) would be better. I wonder though whether it might
be simpler to just let targets override the bfd_set_reloc () function with
their own implementation, should they have special requirements. I have not
investigated this yet, but it seems like it would be the simplest solution,
provided that it can be made to work.
Yeah... I agree it would probably be easier, and keeps the current API,
so no code rewrite is hopefully needed.
If nobody objects to this approach I will give it a try.