This is the mail archive of the
mailing list for the binutils project.
Re: Problems with branch-to-arm-from-thumb for typeless symbol
- From: Richard Earnshaw <rearnsha at arm dot com>
- To: Hans-Peter Nilsson <hans-peter dot nilsson at axis dot com>
- Cc: "binutils at sourceware dot org" <binutils at sourceware dot org>
- Date: Fri, 01 Mar 2013 14:16:39 +0000
- Subject: Re: Problems with branch-to-arm-from-thumb for typeless symbol
- References: <201303010523.r215NWNm013581@ignucius.se.axis.com>
On 01/03/13 05:23, Hans-Peter Nilsson wrote:
See <http://sourceware.org/bugzilla/show_bug.cgi?id=15217>. Are
target symbols required to have a type specified in order for
arm/thumb stubs to work?
(where lib_func2 is in arm mode but with no type decoration)
The assumption is that if you call an untyped symbol the code knows what
it is doing and that special processing for interworking is not
required. Furthermore, the guarantee that IP (r12) is free as an
interworking register is not available for untyped symbol interfaces.
If so, would it be an improvement to emit errors when finding
calls to symbols that have no type specified? That'd at least
warn people inheriting sloppily hand-written assembly code as to
what goes wrong.
That would break existing use cases where the code is correct.
There may be a small number of cases where you could safely say that the
user is being silly, but it would need careful thought to ensure that it
doesn't break valid cases.
FWIW, I tried the following patch (to set the default stub for
defined untyped symbols), which seems to work for the specific
test-case, but causes some stub names to change from
"__func_to_branch_to_from_thumb", causing these tests to fail:
Running /expvol/pp_slask/hp/ticket44165/trunkbinu/src/ld/testsuite/ld-arm/arm-elf.exp ...
FAIL: erratum 760522 fix (default for v6z)
FAIL: erratum 760522 fix (explicitly on at v6z)
FAIL: erratum 760522 fix (explicitly off at v6z)
FAIL: erratum 760522 fix (default for v5)
FAIL: erratum 760522 fix (default for v7-a)
FAIL: erratum 760522 fix (default for ARM1156)
and also munges the "C" symbol in the
ld-elf/extract-symbol-1sym.d test-case to:
00020122 T C
Running /expvol/pp_slask/hp/ticket44165/trunkbinu/src/ld/testsuite/ld-elf/elf.exp ...
FAIL: --extract-symbol test 1 (symbols)
so the patch is at least incomplete. Thoughts?
diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index aba1814..a53c64f 100644
@@ -15457,9 +15457,12 @@ elf32_arm_swap_symbol_in (bfd * abfd,
/* New EABI objects mark thumb function symbols by setting the low bit of
- the address. */
+ the address. Hand-written assembly-code may lack specification of
+ the symbol type. */
if (ELF_ST_TYPE (dst->st_info) == STT_FUNC
- || ELF_ST_TYPE (dst->st_info) == STT_GNU_IFUNC)
+ || ELF_ST_TYPE (dst->st_info) == STT_GNU_IFUNC
+ || (ELF_ST_TYPE (dst->st_info) == STT_NOTYPE
+ && dst->st_info != STN_UNDEF))
if (dst->st_value & 1)