Launchpad has imported 9 comments from the remote bug at
http://sourceware.org/bugzilla/show_bug.cgi?id=12532.

If you reply to an imported comment from within Launchpad, your comment
will be sent to the remote bug automatically. Read more about
Launchpad's inter-bugtracker facilities at
https://help.launchpad.net/InterBugTracking.

------------------------------------------------------------------------
On 2011-03-02T11:26:32+00:00 Dave Martin wrote:

Created attachment 5270
Compiler output demonstrating the problem

Gas sometimes emits a short branch and an R_ARM_THUMB_JUMP11 relocation
for an unqualified branch ("b") to a global symbol defined in the same
source file.

However, there's no guarantee that R_ARM_THM_JUMP11 relocation can be
resolved correctly if the symbol gets preempted.

Observed in binutils-arm-linux-gnueabi 2.20.51.20100908-0ubuntu2cross1.52.
Observed on binutils trunk on 2011-02-25.

The problem seems to strike in practice when the compiler optimises a
sibling call to "b <label>", for which the assembler generates a b.n.
Handed-coded assembler can also cause the same problem.

As a side-effect of the presence of this relocation, Thumb-2 kernel
modules may fail to load, since the kernel doesn't support fixing up
this relocation. I believe the kernel doesn't do any symbol preemption
processing when loading modules -- if so, the relocation is actually
redundant. But there's no way for the kernel to detect at module load
time that the relocation can safely be ignored. In kernel builds, about
1 out every 6 modules suffers from this problem. It's not clear to me
whether the method used by the kernel to link .ko objects is wrong or
not.

It seems that either the tools should support symbol preemption in this
scenario (implying that a short branch is not adequate to guarantee that
preemption will work -- i.e., a gas bug) or not (in this case the fixup
should be done locally and there should presumably be no relocation --
i.e., a different gas bug).

It appears that passing -fno-optimize-sibling-calls to GCC can work
around the problem by avoiding the generation of local branches to
global symbols, but this is clearly not the correct long-term fix.

Reply at: https://bugs.launchpad.net/binutils/+bug/725126/comments/3

------------------------------------------------------------------------
On 2011-03-02T11:27:55+00:00 Dave Martin wrote:

Created attachment 5271
sample disassembly and relocation info

Reply at: https://bugs.launchpad.net/binutils/+bug/725126/comments/4

------------------------------------------------------------------------
On 2011-04-11T16:18:01+00:00 Nickc wrote:

Created attachment 5662
Do not relax relocations to preemptable global symbols

Reply at: https://bugs.launchpad.net/binutils/+bug/725126/comments/6

------------------------------------------------------------------------
On 2011-04-11T16:19:38+00:00 Nickc wrote:

Hi Dave,

  I think that we should be supporting the possibility of symbol
preemption. So please could you try out the uploaded patch and let me
know if it resolves the problem for you.

Cheers
  Nick

PS.  Hmm, I wonder if we should support a command line feature to
enable/disable this behaviour, and what the default setting should be...

Reply at: https://bugs.launchpad.net/binutils/+bug/725126/comments/7

------------------------------------------------------------------------
On 2011-04-12T10:39:08+00:00 Dave Martin wrote:

(In reply to comment #3)
> Hi Dave,
> 
>   I think that we should be supporting the possibility of symbol preemption. 
> So
> please could you try out the uploaded patch and let me know if it resolves the
> problem for you.
> 
> Cheers
>   Nick
> 
> PS.  Hmm, I wonder if we should support a command line feature to
> enable/disable this behaviour, and what the default setting should be...

Your patch in http://sourceware.org/bugzilla/show_bug.cgi?id=12532#c2
seems to fix my instance of the problem.

Do you know when this is likely to get merged?  I don't see it in
binutils trunk yet.

Cheers
---Dave

Reply at: https://bugs.launchpad.net/binutils/+bug/725126/comments/8

------------------------------------------------------------------------
On 2011-04-12T11:47:41+00:00 Cvs-commit wrote:

CVSROOT:        /cvs/src
Module name:    src
Changes by:     [email protected]    2011-04-12 11:47:38

Modified files:
        gas            : ChangeLog 
        gas/config     : tc-arm.c 

Log message:
        PR gas/12532
        * config/tc-arm.c (relax_branch): Do not relax branches to
        preemptable global symbols.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/ChangeLog.diff?cvsroot=src&r1=1.4464&r2=1.4465
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/config/tc-arm.c.diff?cvsroot=src&r1=1.479&r2=1.480

Reply at: https://bugs.launchpad.net/binutils/+bug/725126/comments/9

------------------------------------------------------------------------
On 2011-04-12T11:49:05+00:00 Nickc wrote:

Hi Dave

> Do you know when this is likely to get merged?  I don't see it in binutils
> trunk yet.

That would be because I was waiting for your agreement that the patch
worked...

Anyway it is all checked in now.

Cheers
  Nick

Reply at: https://bugs.launchpad.net/binutils/+bug/725126/comments/10

------------------------------------------------------------------------
On 2011-04-12T12:14:19+00:00 Dave Martin wrote:

On Tue, Apr 12, 2011 at 12:49 PM, nickc at redhat dot com
<[email protected]> wrote:
> http://sourceware.org/bugzilla/show_bug.cgi?id=12532
>
> Nick Clifton <nickc at redhat dot com> changed:
>
>           What    |Removed                     |Added
> ----------------------------------------------------------------------------
>             Status|WAITING                     |RESOLVED
>         Resolution|                            |FIXED
>
> --- Comment #6 from Nick Clifton <nickc at redhat dot com> 2011-04-12 
> 11:49:05 UTC ---
> Hi Dave
>
>> Do you know when this is likely to get merged?  I don't see it in binutils
>> trunk yet.
>
> That would be because I was waiting for your agreement that the patch 
> worked...
>
> Anyway it is all checked in now.

OK!  Thanks

---Dave

Reply at: https://bugs.launchpad.net/binutils/+bug/725126/comments/11

------------------------------------------------------------------------
On 2011-04-12T15:44:40+00:00 Cvs-commit wrote:

CVSROOT:        /cvs/src
Module name:    src
Changes by:     [email protected]    2011-04-12 15:44:36

Modified files:
        gas/testsuite  : ChangeLog 
        gas/testsuite/gas/arm: weakdef-1.d plt-1.d thumb2_bcond.d 

Log message:
        PR gas/12532
        * gas/arm/plt-1.d: Update expected disassembly.
        * gas/arm/thumb2_bcond.d: Likewise.
        * gas/arm/weakdef-1.d: Likewise.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/testsuite/ChangeLog.diff?cvsroot=src&r1=1.1882&r2=1.1883
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/testsuite/gas/arm/weakdef-1.d.diff?cvsroot=src&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/testsuite/gas/arm/plt-1.d.diff?cvsroot=src&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/testsuite/gas/arm/thumb2_bcond.d.diff?cvsroot=src&r1=1.6&r2=1.7

Reply at: https://bugs.launchpad.net/binutils/+bug/725126/comments/12


** Changed in: binutils
       Status: Unknown => Fix Released

** Changed in: binutils
   Importance: Unknown => Medium

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/725126

Title:
  gas may assemble b to locally-defined, preemptible global symbol as
  "b.n"

-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to