This is the mail archive of the binutils@sourceware.org mailing list for the binutils 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]

Re: latest ld not inserting arm interworking shims?


On 10/03/12 17:36, Dave Murphy wrote:
> Hi,
> 
> I've recently managed to track down a problem with some code that
> turned out to be ld from binutils 2.22 (both release and CVS HEAD) not
> inserting a shin when calling arm code from thumb. Has something
> changed recently in how the linker is used for this situation or is
> this a bug? Binutils 2.21.1 behaves as I'd expect.
> 
> monalisa:interworktest davem$ arm-eabi-ld --version
> GNU ld (GNU Binutils) 2.22.52.20120310
> Copyright 2012 Free Software Foundation, Inc.
> This program is free software; you may redistribute it under the terms of
> the GNU General Public License version 3 or (at your option) a later version.
> This program has absolutely no warranty.
> monalisa:interworktest davem$ cat armasm.s
> 	.arm
> 	.global armasm
> armasm:
> 	bx	lr
> 

This is wrong, you need to mark 'armasm' as being a function entry
point.  ie, you need to add

	.type armasm, %function

The linker only inserts interworking veneers at points where the ABI
says it is safe to do so (as, amongst other things, to put them in at
other times might corrupt registers containing live values).  Such
permission is only granted to symbols which are marked as type 'function'.

R.

> monalisa:interworktest davem$ cat callarmfromthumb.c
> void armasm();
> 
> void _start() {
> 	armasm();
> 	while(1);
> }
> 
> monalisa:interworktest davem$ arm-eabi-as -mthumb-interwork armasm.s
> monalisa:interworktest davem$ arm-eabi-gcc -mthumb -mthumb-interwork
> -c callarmfromthumb.c
> monalisa:interworktest davem$ arm-eabi-gcc -nostartfiles -nostdlib
> callarmfromthumb.o armasm.o
> monalisa:interworktest davem$ arm-eabi-objdump -d a.out
> 
> a.out:     file format elf32-littlearm
> 
> 
> Disassembly of section .text:
> 
> 00008000 <_start>:
>     8000:	b580      	push	{r7, lr}
>     8002:	af00      	add	r7, sp, #0
>     8004:	f000 f802 	bl	800c <armasm>
>     8008:	e7fe      	b.n	8008 <_start+0x8>
>     800a:	46c0      	nop			; (mov r8, r8)
> 
> 0000800c <armasm>:
>     800c:	e12fff1e 	bx	lr
> 
> 
> ld from binutils 2.21.1 inserts a shim
> 
> $ arm-eabi-ld --version
> GNU ld (GNU Binutils) 2.21.1
> Copyright 2011 Free Software Foundation, Inc.
> This program is free software; you may redistribute it under the terms of
> the GNU General Public License version 3 or (at your option) a later version.
> This program has absolutely no warranty.
> 
> davem@Godfreyjnr ~
> $ arm-eabi-objdump.exe -d a.out
> 
> a.out:     file format elf32-littlearm
> 
> 
> Disassembly of section .text:
> 
> 00008000 <_start>:
>     8000:       b580            push    {r7, lr}
>     8002:       af00            add     r7, sp, #0
>     8004:       f000 f804       bl      8010 <__armasm_from_thumb>
>     8008:       e7fe            b.n     8008 <_start+0x8>
>     800a:       46c0            nop                     ; (mov r8, r8)
> 
> 0000800c <armasm>:
>     800c:       e12fff1e        bx      lr
> 
> 00008010 <__armasm_from_thumb>:
>     8010:       4778            bx      pc
>     8012:       46c0            nop                     ; (mov r8, r8)
>     8014:       eafffffc        b       800c <armasm>
> 
> Dave
> 
> 



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