|
|
This patch is really for EABI compliance, but it also fixes PR 7525.
The EABI requires that a strictly conforming object should not rely on
compiler helper functions that are not part of the standard list
(strictly speaking it just requires that any functions it does use must
be freely redistributable with the object, but we really don't want to
be doing that unless it's really necessary, and in this case it isn't).
The Thumb instruction set in v4t does not have a call-indirect
instruction (v5t does, blx <reg>), and what is more, an ARM-style
sequence, like
mov lr, pc
bx reg
does not work because the Thumb bit is stripped from the return address
by the mov. The previous solution to this was to call a stub library
function (a trampoline) using a normal bl instruction. That trampoline
could then safely do the bx <reg> since the bl instruction will have
already established the return value in lr.
However, given that there is no such function in the portable library,
we need another way. The solution adopted here is to embed the
trampolines into object files that need them; we can then use local
branches to the targets and avoid any problems with reachability as well
as with names.
To avoid excessive code bloat we try to optimize the number of
trampolines we emit; for code that is emitted in text_section() we can
just emit one trampoline per file per register used for indirect
calling. For code that is emitted into a named section we have to be
more careful to ensure that the stub remains reachable, in this case we
emit one stub per function.
Tested on arm-elf with no regressions in the compiler. There are two
regressions triggered in GDB, but these appear to be the debugger
failing to detect the new trampoline sequence.
R.
2005-01-14 Richard Earnshaw <rearnsha@xxxxxxx>
PR target/7525
* arm.h (struct machine_function): Add call_via field.
(thumb_call_via_label): Declare.
* arm.c (thumb_call_via_label): New variable.
(thumb_call_reg_needed): New variable.
(arm_output_function_epilogue): For Thumb code, output any per-function
call-indirect trampolines.
(thumb_call_via_reg): New function.
(arm_file_end): New function.
(TARGET_ASM_FILE_END): Call arm_file_end.
(aof_file_end): Likewise.
* arm-protos.h (thumb_call_via_reg): Declare.
* arm.md (call_reg_thumb, call_value_reg_thumb): Call
thumb_call_via_reg in normal case.
thumb-ind-call.patch
Description: Text Data
|
|