This is the mail archive of the newlib@sources.redhat.com mailing list for the newlib project.


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

Re: [Fwd: Building newlib for arm - setjmp.S and thumb?]


Hi Kurt,

> ../../../../../../../newlib-1.9.0/newlib/libc/sys/arm/setjmp.S:
> Assembler messages:
> ../../../../../../../newlib-1.9.0/newlib/libc/sys/arm/setjmp.S:97:
> Error: r15 not allowed here
> ../../../../../../../newlib-1.9.0/newlib/libc/sys/arm/setjmp.S:117:
> Error: r15 not allowed here

Hmm, these messages appear to be for the FUNC_START macro.  The Thumb
version of this macro uses the code sequence:

        BX PC
        NOP

to switch into ARM mode.

> It looks like it is trying to compile for thumb (note the -mthumb
> flag), but I don't think that the arm thumb architecture lets you
> use register r15.

It does under certain circumstances.  The BX instruction is one of
those instructions which can use r15.

Looking at the assembler sources, this error is only produced when the
BX PC instruction is being assembled in ARM mode,not THUMB mode.  (In
ARM mode the instruction is technically legal, although it has no
effect).  The later versions of the assembler change this error
message to a warning.

The reason that the assembler is confused, and thinks that it is in
ARM mode is that the .thumb_func directive in the 2.10.1 assembelr
sources did not automatically select thumb mode.  You can easily work
around this by editing the setjmp.S source file and changing:

  .macro PROLOGUE name
	bx	pc
	nop	
	.code 32
to:

  .macro PROLOGUE name
        .code 16                        <---- added line
	bx	pc
	nop	
	.code 32

> Does anyone know how can I tell the configure script that I want
> plain arm, and not thumb output? Shouldn't the toolchain be setup
> for plain arm use in the first place?

It does default to ARM mode, but also by default support for producing
THUMB code is enabled.  If you just want the standard ARM toolchain
and nothing fancy, you could try configuring with multilib support
disabled:

        configure --target=arm-elf --enable-multilib=no

Cheers
        Nick


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