Nios2 dynobj handling fixes

Sandra Loosemore sandra@codesourcery.com
Tue Feb 28 07:38:00 GMT 2017


On 02/27/2017 07:49 PM, Alan Modra wrote:
> A number of places in elf32-nios.c created dynamic sections but didn't
> set the hash table dynobj.  That meant we could have duplicate dynamic
> sections connected to a number of bfds, so size_dynamic_sections
> didn't properly discard or allocate contents.  All sorts of havoc
> ensued.
>
> Also, the entire set of dynamic sections was created in check_relocs
> on seeing GOT relocs when only .got related sections are needed,
> probably done to hide segfaults later in finish_dynamic_sections.
>
> The patch fixes these issues and makes the assembler emit errors when
> nios2 lacks the necessary pc-relative relocs for subtraction
> expressions, rather than silently generating bad code.  eg.
> ld-elf/merge.  I've also tidied uses of elf32_nios2_hash_table and
> elf_hash_table.

Thanks for helping out with this.  This code has been hacked on by a lot 
of people over the years and I'm starting to think the reason why it's 
been so hard to understand is that it was broken.  ;-)  I really want to 
apologize for not catching the breakage earlier, too --  I've been more 
focused on GCC the past couple of months, and hadn't refreshed the 
binutils checkout in my mainline nios2-linux-gnu build tree since 
mid-December.

Anyway, I've verified that I get working executables again with this 
patch, and I've kicked off some more thorough testing to run overnight.

-Sandra



More information about the Binutils mailing list