Bug 6058

Summary: Linker segfaults with undefined weak function descriptors.
Product: binutils Reporter: Daniel Jacobowitz <drow>
Component: ldAssignee: unassigned
Status: RESOLVED FIXED    
Severity: normal CC: aoliva, bug-binutils
Priority: P2    
Version: 2.19   
Target Milestone: ---   
Host: Target: frv-*-*
Build: Last reconfirmed: 2009-01-22 10:56:41
Attachments: Add checks for a NULL section pointer

Description Daniel Jacobowitz 2008-04-08 19:17:40 UTC
This test file segfaults ld:

        .text
        .globl  _start
_start: ret
        .weak   foo
        .weak   foow
        .hidden foow

        # These should both end up zero.
        .data
        .picptr funcdesc(foo)
        .picptr funcdesc(foow)

sec is NULL at the top of _frvfdpic_emit_got_relocs_plt_entries.  Discovered
while cribbing from the FRV port for SH FDPIC - presumably both should be zero
and have no relocations.  That's what happens for the non-hidden one.
Comment 1 Nick Clifton 2008-04-15 14:17:28 UTC
Created attachment 2694 [details]
Add checks for a NULL section pointer
Comment 2 Nick Clifton 2008-04-15 14:18:11 UTC
Hi Daniel,

  Does the uploaded patch work for you ?

Cheers
  Nick
Comment 3 Daniel Jacobowitz 2008-04-19 17:23:58 UTC
Subject: Re:  Linker segfaults with undefined weak function
	descriptors.

On Tue, Apr 15, 2008 at 02:18:14PM -0000, nickc at redhat dot com wrote:
> Hi Daniel,
> 
>   Does the uploaded patch work for you ?

It does fix the crash, but two unnecessary function descriptors appear
to be allocated.  And I get an assertion failure on elf32-frv.c:5867
if I add -shared to the link command (along with a corrupt
relocation in .rel.dyn).

If I link the executable with a shared library I get a dynamic reloc
for the non-hidden undefweak symbol, which IMO is correct.

Comment 4 Alan Modra 2022-08-23 08:23:34 UTC
commit 906e58cab5ef included the attached patch, so segfault fixed.