make arm crt_arch.h compatible with thumb code generation
authorRich Felker <dalias@aerifal.cx>
Thu, 14 May 2015 22:26:16 +0000 (18:26 -0400)
committerRich Felker <dalias@aerifal.cx>
Thu, 14 May 2015 22:26:16 +0000 (18:26 -0400)
commit83340c7a580e91b22f58321b7cf6d976af61084c
treef230ee7eba74d07521f3f104660b0d318863fbc2
parentdbf74a98be1e5c7564566c2ad30ce85dcf768df6
make arm crt_arch.h compatible with thumb code generation

compilers targeting armv7 may be configured to produce thumb2 code
instead of arm code by default, and in the future we may wish to
support targets where only the thumb instruction set is available.

the changes made here avoid operating directly on the sp register,
which is not possible in thumb code, and address an issue with the way
the address of _DYNAMIC is computed.

previously, the relative address of _DYNAMIC was stored with an
additional offset of -8 versus the pc-relative add instruction, since
on arm the pc register evaluates to ".+8". in thumb code, it instead
evaluates to ".+4". both are two (normal-size) instructions beyond "."
in the current execution mode, so the numbered label 2 used in the
relative address expression is simply moved two instructions ahead to
be compatible with both instruction sets.
arch/arm/crt_arch.h