This is the mail archive of the binutils@sourceware.org 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: deleting relocs, objcopy and BFD


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.


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