是否可以在ARM(Android/Linux)上更改字节序中间执行? [英] Is it possible to change endianness mid-execution on ARM (Android/Linux)?

查看:110
本文介绍了是否可以在ARM(Android/Linux)上更改字节序中间执行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可以更改ARM平台上正在运行的应用程序中间执行程序的字节序.如您所知,ARM是双向的(支持大大小小的),我想知道是否在Android(或一般的linux)上设置单个应用程序以在执行时使用不同的字节序?可以在执行过程中更改处理器字节序.

I am wondering if it is possible to change the endianness of a running application mid-execution on the ARM platform. As some of you know, ARM is bi-endian (supporting both big and little) and I am wondering if on Android (or linux in general) if it is possible to either set a single application to use a different endianness at execution or if it is possible to change the processor endianness mid-execution.

阻止对此的一些可能的响应.改变字节序(如果可能在应用程序级别上)几乎肯定是个坏主意,但是我正在为ARM平台构建工具,并且我想知道我使用固定工具的应用程序是否可以做到这一点.另外,即使这样做可能对其他应用程序/OS造成灾难性的后果,我也想知道是否可以由应用程序完成.

To head off some of the possible responses to this. Changing endianness (if possible on the application level) is almost assuredly a bad idea but I am building tools for the ARM platform and I am wondering if an application that I am using a set tools on could possibly do this. Also even if doing so could cause catastrophic consequences to other applications/OS I would like to know if it can be done by an application.

到目前为止,从我对ARM的观点来看,似乎只有OS可以在这方面设置处理器的模式.但是,我还没有找到关于这个问题的明确答案.提前致谢!

So far from my view of ARM it appears that only the OS can set the mode of the processor in this regard. However I have yet to find a definitive answer on this question. Thanks in Advance!

推荐答案

(至少在ARMv7和更旧的硬件上)肯定有可能,但是您的观点是完全正确的-请其他人, >,出于理智,正向兼容性和恼怒的内核开发人员的目的,请勿在Linux/Android中执行此操作-在REVREV16REVSHVREV上使用数据.

It is (on ARMv7 and older hardware at least) certainly possible, but your sentiment is entirely correct - anyone else, please, please, for the sake of sanity, forward-compatibility and angry kernel developers, don't do this in Linux/Android - use REV, REV16, REVSH or VREV on data as appropriate.

SETEND指令, ARMv6中引入的功能允许在任何特权级别切换当前执行状态的字节顺序,但是从ARMv8开始不推荐使用它,默认情况下将其禁用,并且将来可能会完全消失.在ARMv8中,硬件中支持混合字节序是可选的.

The SETEND instruction, introduced in ARMv6, allows switching the endianness of the current execution state at any privilege level, however from ARMv8 it is deprecated, disabled by default, and likely to disappear entirely in future. Supporting mixed-endianness in hardware is optional in ARMv8.

尽管这是一个糟糕的主意,但它显然在当前普遍使用的Android应用程序中已经很普遍了(除了可能的其他用途之外,它可能是在ARM11上甚至是Cortex-A8上实现strcmp()的最快方法),而SETEND最近必须将32位任务的仿真添加到arm64内核中,因此您的工具至少也应该意识到这一点.

Despite being a terrible idea, it's apparently commonplace enough in Android apps currently in the wild (among possible other uses, it's supposedly the fastest way to implement strcmp() on ARM11, and maybe also Cortex-A8) that SETEND emulation for 32-bit tasks has recently had to be added to the arm64 kernel, so chances are your tools should at least be aware of it, too.

这篇关于是否可以在ARM(Android/Linux)上更改字节序中间执行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆