Bug 6058 - Linker segfaults with undefined weak function descriptors.
Summary: Linker segfaults with undefined weak function descriptors.
Status: NEW
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.19
: P2 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-04-08 19:17 UTC by Daniel Jacobowitz
Modified: 2009-01-22 10:56 UTC (History)
2 users (show)

See Also:
Host:
Target: frv-*-*
Build:
Last reconfirmed: 2009-01-22 10:56:41


Attachments
Add checks for a NULL section pointer (475 bytes, patch)
2008-04-15 14:17 UTC, Nick Clifton
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.