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

ld emitting blx immdetiate for Cortex M3

Hi all,

the following simple program causes the linker to emit 'blx immediate':

#include <stdlib.h>

int main(int argc, char **argv)
	int x = atoi("123");
	return x;

compilation with

% arm-none-eabi-gcc -o toolchain-test.elf -Wall -nostartfiles -msoft-float -mlittle-endian -Wl,-t -mthumb -mcpu=cortex-m3 -Wl,--entry=main main.c
/Users/benjamin/sat_bleeding/bin/../lib/gcc/arm-none-eabi/4.6.3/../../../../arm-none-eabi/bin/ld: mode armelf

arm-none-eabi-objdump -d shows in strtol_r (which is internally called from newlib) blx instructions:

    80a2:       1c30            adds    r0, r6, #0
    80a4:       4651            mov     r1, sl
    80a6:       f000 e910       blx     82c8 <__aeabi_uidivmod>
    80aa:       1c30            adds    r0, r6, #0
    80ac:       4689            mov     r9, r1
    80ae:       4651            mov     r1, sl
    80b0:       f000 e88c       blx     81cc <__aeabi_uidiv>
    80b4:       2603            movs    r6, #3

arm-non-eabi-objdump -d of this section of lib_a-strtol.o:

  5a:   1c30            adds    r0, r6, #0
  5c:   4651            mov     r1, sl
  5e:   f7ff fffe       bl      0 <__aeabi_uidivmod>
  62:   1c30            adds    r0, r6, #0
  64:   4689            mov     r9, r1
  66:   4651            mov     r1, sl
  68:   f7ff fffe       bl      0 <__aeabi_uidiv>
  6c:   2603            movs    r6, #3

What am I doing wrong, and what can I do to avoid this issue?

Best regards

used versions:
gcc: 4.6.3
binutils: 2.22
newlib 1.20


Benjamin Hase
Forschung & Entwicklung
Tel.:	+49 (0) 23 24 / 96 48-0
RESOL - Elektronische Regelungen GmbH
Heiskampstr. 10 - 45527 Hattingen / Germany
Sitz Hattingen - Geschäftsführer: Rudolf Pfeil
Amtsgericht - Registergericht - Essen - HRB 15674

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