PIG: Byteswap the function pointers on LE-machines when relocating
@@ -551,6 +551,14 @@ ProgramImageGenerator::writeDataSection(
try {
unsigned int memAddress = compressor_->memoryAddress(
instruction);
+ if (compressor_->machine().isLittleEndian()){
+ // Byteswap the pointer
+ unsigned int num = memAddress;
+ memAddress = ((num>>24)&0xff) |
+ ((num<<8)&0xff0000) |
+ ((num>>8)&0xff00) |
+ ((num<<24)&0xff000000);
+ }
dataBits.pushBack(memAddress, 32);
offset += 4;
} catch (const Exception& e) {
