Bug 13099 - Incorrect check for .gnu.linkonce section
Summary: Incorrect check for .gnu.linkonce section
Status: RESOLVED INVALID
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.22
: P2 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-16 18:18 UTC by H.J. Lu
Modified: 2012-02-22 04:02 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2011-08-16 18:18:53 UTC
elflink.c has

     if (CONST_STRNEQ (name, ".gnu.linkonce.")
          && ((p = strchr (name + sizeof (".gnu.linkonce.") - 1, '.')) 
              != NULL))
        p++;  

For

(gdb) p name
$12 = 0x8750ba ".gnu.linkonce.this_module"
(gdb)

strchr is called on

(gdb) p name + sizeof (".gnu.linkonce.") - 1
$13 = 0x8750c8 "this_module"
(gdb) 

Instead we should pass

(gdb) p name + sizeof (".gnu.linkonce.") - 2
$14 = 0x8750c7 ".this_module"
(gdb) 

to strchr.
Comment 1 Andreas Schwab 2011-08-16 18:49:42 UTC
name + sizeof (".gnu.linkonce.") - 2 always starts with a dot, so the check would become pointless.
Comment 2 H.J. Lu 2011-08-16 19:00:38 UTC
gnu.linkonce section name usually is .gnu.linkonce.TYPE.KEY.
But kernel driver may have .gnu.linkonce.this_module. What
should be key here?
Comment 3 Alan Modra 2011-08-17 00:07:52 UTC
The only reason you would want a key of "this_module" is to match a group with signature "this_module".  I don't think that makes a great deal of sense.

Hmm, I suppose we are hitting the assert.  Feel free to remove it.