This is the mail archive of the 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]

Fix ARM/Thumb non-interworking problem in libgcc

This is forwarded from PR58660
(<>). Please CC me on
replies as I am not on the list.

In doing some testing of GCC 4.7.3 on a target with an ARMv4T CPU (e.g.
ARM7T or ARM9) I encountered a problem if using Thumb mode with
interworking disabled. For that, obviously I had to created a libgcc
multilib for this combination; for example: -mcpu=arm9 -mthumb

However this fails to work in GCC 4.7.3 because of a problem in libgcc
making it fail to handle modes correctly 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.

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

2013-10-07  Jonathan Larmour  <>

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

Someone may also 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).


eCosCentric Limited     The eCos experts
Barnwell House, Barnwell Drive, Cambridge, UK.       Tel: +44 1223 245571
Registered in England and Wales: Reg No 4422071.
------["Si fractum non sit, noli id reficere"]------       Opinions==mine

Description: Text document

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