[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ARM/THUMB] Incorrect branch generated for long calls

From: Rafaël Carré
Subject: [ARM/THUMB] Incorrect branch generated for long calls
Date: Fri, 11 Jun 2010 15:35:16 +0200


I just met a possible bug in binutils 2.20.1 when mixing ARM/Thumb code
under some conditions.

I wouldn't mind a confirmation that it's a real bug before opening an
entry in bugzilla.

This happens when the target function is:
        - ARM (32bits) code
        - not accessible with a short call (B or BL instruction)
        - called from Thumb at some place
        - called from ARM at some other place (and here the bug happens)

ld inserts a __func_from_thumb veneer to be called by Thumb code, but
this veneer is also called from ARM code, while ARM code should use a
different veneer.
(or even point directly to the ARM code of the veneer, after "bx pc"
and "nop")

I've attached a small commented test case:
Just put the 4 files somewhere, edit Makefile to match your ARM
compiler and run make test to build, link, and print commented objdump
disassembly (look for "BUG" in the output).

The linker script is necessary to put the function out of reach from
short calls, I met the bug when building rockbox on targets with
different RAMs which can't access each other with a short call (and
there's no MMU on these devices to remap the memory regions close to
each other).

I had a look at bfd/elf32-arm.c but it's just too long for me to
handle :)


Rafaël Carré

Attachment: f.i
Description: Binary data

Attachment: Makefile
Description: Binary data

Attachment: start.i
Description: Binary data

Attachment: test.lds
Description: Binary data

Attachment: signature.asc
Description: PGP signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]