This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libgcc/58660] New: ARM/Thumb non-interworking code broken in libgcc


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58660

            Bug ID: 58660
           Summary: ARM/Thumb non-interworking code broken in libgcc
           Product: gcc
           Version: 4.7.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libgcc
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jifl-bugzilla at jifvik dot org

Created attachment 30966
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30966&action=edit
libgcc patch to correct operation with non-interworking thumb builds

I have included a multilib in my GCC for ARM to generate thumb code with
interworking disabled, intended for an ARMv4T CPU (e.g. ARM7T or ARM9). In
other words, -mcpu=arm9 -mthumb -mno-thumb-interwork.

However this fails to work because of a problem in libgcc making it incorrect
for non-interworking operation. A specific example is aeabi_uldivmod in bpabi.S
which is an ARM (not thumb) function, which includes a bl to
__gnu_uldivmod_helper. __gnu_uldivmod_helper is from bpabi.c and is in Thumb
mode.

The linker helpfully adds a little trampoline to switch to Thumb mode  with the
bx instruction (____gnu_uldivmod_helper_from_arm). However GCC returns from
__gnu_uldivmod_helper with:

  pop     {r3, r4, r5, r6, r7, pc}

This means that no mode switch happens on the return from the Thumb mode
function to the ARM mode aeabi_uldivmod function.

As well as the obvious aeabi_ldivmod, someone may want to double-check whether
this sort of problem may apply to other functions (although I haven't found any
others yet myself, but I'm not sure about how functions like those in
unaligned-funcs.c would be called).

I am attaching a potential fix for the problem with aeabi_ldivmod and
aeabi_uldivmod, so it would be good for that to be applied at least, including
on the 4.7 branch.

2013-10-07  Jonathan Larmour  <jifl@eCosCentric.com>

    * config/arm/bpabi.S (aeabi_ldivmod, aeabi_uldivmod): Allow for
    non-interworking Thumb builds.

Thanks,

Jifl


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]