Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aTQrxzMf5a9qrClj@intrepid>
Date: Sat, 6 Dec 2025 14:12:39 +0100
From: Markus Wichmann <nullplan@....net>
To: musl@...ts.openwall.com
Subject: Re: How supported is Thumb 1?

Am Fri, Dec 05, 2025 at 10:25:54PM +0100 schrieb Markus Wichmann:
> A word on instruction set selection: It appears that the assembler,
> confronted with "-mthumb", will scan the source file for any instructions
> that cannot be represented in thumb mode (for the desired architecture
> version), and if any are found, will assemble in ARM mode. This is
> independent of the preprocessor, so the existance of the __thumb__ macro
> doesn't say we are actually in Thumb mode. This is also different from
> the ".thumb" directive, which forces it into Thumb mode and gives errors
> when something cannot be represented.
> 

OK, I just found out that that's wrong. What's actually going on is
nothing quite so fancy: The -mthumb option is an option to the
preprocessor, the compiler, and the assembler.

In the preprocessor, it causes the macro __thumb__ to be defined, and
__thumb2__ as well if the architecture level is high enough. In the
compiler, it causes it to emit Thumb code explicitly (starting with
.thumb in front of every function for good measure). And in the
assembler it does what the documentation says and switches the
instruction set to Thumb until a directive to the contrary is
encountered.

But GCC doesn't automatically pass -mthumb on to the assembler. Instead,
musl's configure script reacts to finding the __thumb2__ macro defined
by adding -Wa,-mthumb to the command line. This also means that
evaluating the __thumb__ macro by itself in an assembler file is likely
wrong. In embedded assembler it reliably indicates the mode in use, but
in standalone assembler it only indicates a desire to assemble as thumb
that isn't necessarily heeded.

Ciao,
Markus

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.