[LLVMdev] Remaining big-endian host issues in RuntimeDyld
Ulrich Weigand
Ulrich.Weigand at de.ibm.com
Tue Nov 25 05:09:27 PST 2014
Daniel Sanders wrote:
>David: There's one more patch after r221047. I've just submitted it to
>llvm-commits and you can find it at http://reviews.llvm.org/D6130.
>I haven't touched the PowerPC path of createStubFunction() in that
>patch since I'm not sure whether PowerPC's opcodes are endian-dependant
>and (unlike the other paths) it currently specifies an endianness.
I just noticed this. PowerPC opcodes are indeed endian-dependant.
However, the current implementation of createStubFunction for PowerPC
should be correct for any combination of host and target endianness.
The functions named (somewhat misleadingly) writeInt32BE etc. actually
do take the target endianness into account:
void writeInt32BE(uint8_t *Addr, uint32_t Value) {
if (IsTargetLittleEndian)
sys::swapByteOrder(Value);
*Addr = (Value >> 24) & 0xFF;
*(Addr + 1) = (Value >> 16) & 0xFF;
*(Addr + 2) = (Value >> 8) & 0xFF;
*(Addr + 3) = Value & 0xFF;
}
Calling them with an explicit uint32_t value automatically takes host
endianness into account, so everything will work out OK.
It seems that these days, the writeInt32BE etc. routines are actually
equivalent to writeBytesUnaligned, so maybe those can now be merged.
Back when I added PowerPC LE support, IIRC writeBytesUnaligned didn't
do the right thing on some host/target combinations ...
Bye,
Ulrich
More information about the llvm-dev
mailing list