Fix segfault when .plt section does not exist

Andrew Waterman andrew@sifive.com
Wed Feb 8 22:02:00 GMT 2017


If that is indeed the case, this appears to be handled incorrectly in
several implementations of elf_backend_finish_dynamic_sections -- the
first three I looked at, tilegx, alpha, and ppc64, also seem to rely
only splt->size and do not check if the output section is the absolute
section.  (Actually, tilegx looks like it should segfault on
ld/20828).

We'll construct a test case and look into this more shortly.

On Wed, Feb 8, 2017 at 1:29 AM, Maciej W. Rozycki <macro@imgtec.com> wrote:
> On Fri, 3 Feb 2017, Palmer Dabbelt wrote:
>
>> Sorry to take a while to get back to you, how does this new version look?
>
>  I see you've committed the change already -- however I'd like to point
> out that I am fairly sure (although not absolutely certain offhand) that
> `splt->size' can actually be non-zero for a discarded `.plt' section, as
> normal processing is done internally as if the section was to be included
> in output, except that ->output_section points to the absolute section.
> You'd have to create a small test case to verify that (mine for PR
> ld/20828 isn't enough as it doesn't actually create a PLT), which could
> then serve as a part of the test suite too.
>
>  NB, although we do handle such a situation in many places across BFD, I
> have identified a couple where we don't, one in the MIPS backend and
> another in generic ELF linker code.  I have made patches to adjust those
> places and intend to publish them sometime, however I'm yet thinking what
> to do about some dynamic entries like DT_PLTGOT which are set incorrectly
> when the corresponding section has been removed from output.
>
>   Maciej



More information about the Binutils mailing list