开发者

iPhone -mthumb-interlinking

开发者 https://www.devze.com 2022-12-16 08:07 出处:网络
os i figured out how to use the -mthumb and -mno-thumb compiler flag and more or less understand what it\'s doing.

os i figured out how to use the -mthumb and -mno-thumb compiler flag and more or less understand what it's doing.

But what is the -mthumb-interlinking flag doing? when is it needed, and is开发者_Python百科 it set for the whole project if i set 'compile for thumb' in my project settings?

thanks for the info!


Open a terminal and type man gcc

Do you mean -mthumb-interwork ?

   -mthumb-interwork
       Generate code which supports calling between the ARM and Thumb
       instruction sets.  Without this option the two instruction sets
       cannot be reliably used inside one program.  The default is
       -mno-thumb-interwork, since slightly larger code is generated when
       -mthumb-interwork is specified.

If this is related to a build configuration, you should be able to set it separately for each configuration "such as Release or Debug".

Why do you want to change these settings? I know using thumb instructions save some memory but will it save enough to matter in this case?


my application uses both, thumb and vfp code but i never specifically set -thumb-interwork flag.. how is that possible?

According to man page, without that flag the two instructions sets

cannot be reliably used inside one program.

It says "reliably"; so without that option, it seems they still can be mixed within a single program but it might be "unreliably". I think normally mixing both instructions sets works, the compiler is smart enough to figure out when it has to switch from one set to another one. However, there might be border cases the compiler just doesn't understand correctly and it might fail to see that it should switch instruction sets here, causing the application to fail (most likely it will crash). This option generates special code, so that no matter what your code does, the switching always happens correctly and reliably; the downside is that this extra code is needed for every global visible function and thus increases the binary side (I have no idea if it also might slow down function calls a little bit, I personally would expect that).

Please also note the following two settings:

-mcallee-super-interworking
Gives all externally visible functions in the file being compiled an ARM instruction set header which switches to Thumb mode before executing the rest of the function. This allows these functions to be called from non-interworking code.

-mcaller-super-interworking
Allows calls via function pointers (including virtual functions) to execute correctly regardless of whether the target code has been compiled for interworking or not. There is a small overhead in the cost of executing a function pointer if this option is enabled.

Though I think you only need those, when building libraries to be used with other projects; but I don't know for sure. The GCC thumb handling is definitely "underdocumented".

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号