Re: Which port for armv4l?
On Wed, 2016-08-17 at 00:18 +0200, Adam Wysocki wrote:
> On Tue, 16 Aug 2016, Adam Wysocki wrote:
> > I tested it with a small test program and it generates code with BX
> > instruction (and other BXxx instructions, which - judging from the code -
> > don't seem to be emulated by patch - aren't they needed?).
BX is the only ARM state instruction on ARMv4 that exists for Thumb
> Also a small question about BX emulation. Maybe it's a silly question,
> because I don't know much about Thumb, but I googled that the least
> significant bit of the branch address determines the state (whether
> execution continues in ARM state or Thumb state).
> What will happen if the code tries to enter Thumb state with BX and the
> patch just sets the PC to the odd address (with bit0=1)? An exception, as
> PC can't be odd?
Why would the code be trying to enter Thumb state if it isn't compiled
for Thumb? Anyway, the bit will be ignored on old architectures without
Thumb support. Indeed, even with Thumb support, BX was the only way to
switch to Thumb on ARMv4. It was ARMv5 that added support for things
like LDM and LDR to change state.
> Shouldn't the patch handle addresses with bit0=1 differently?
I haven't looked at the patch so don't see what it does, but if a system
is ARMv4 then trying to load PC with an odd number is fine, that bit
will be ignored and appear as zero if you look at PC. (Likely hardware
doesn't even exist to store bit0 of PC)