Christian Schilmöller
2006-Jun-02 21:49 UTC
[syslinux] Compilation on PPC/bigendian machine
Hi list! Sometimes I need to make boot floppies for an i386 based Linux router. Just for interest, I tried to use syslinux together with my iMac G4 (PPC) with Yellow Dog Linux to create the floppy. I know that this is generally difficult because it requires cross- compiler and cross-assembler. Nevertheless, I tried it because I only needed the disk installer, the loader binaries for i386 were already there. I've found out that the installer was intended to be portable, but in fact wasn't due to some typos and missing typecasts in the file libfat/ulint.h. I was able to correct them and tested the installer successfully. For the case that someone comes across the same problem (or maybe for the next version), I'll attach the diff-file of my changes here. Regards, Christian ---------- cut here ------------------------------------- --- syslinux-3.11/libfat/ulint.h 2004-12-20 05:57:44.000000000 +0100 +++ syslinux-3.11-new/libfat/ulint.h 2006-06-02 20:45:47.350219424 +0200 @@ -79,35 +79,37 @@ { uint16_t _v; - _v = p[0]; - _v |= p[1] << 8; + _v = ((const uint8_t *)_p)[0]; + _v |= ((const uint8_t *)_p)[1] << 8; return _v; } static inline void write16(le16_t *_p, uint16_t _v) { - _p[0] = _v & 0xFF; - _p[1] = (_v >> 8) & 0xFF; + ((uint8_t *)_p)[0] = _v & 0xFF; + ((uint8_t *)_p)[1] = (_v >> 8) & 0xFF; } static inline unsigned int read32(le32_t *_p) { - _v = _p[0]; - _v |= _p[1] << 8; - _v |= _p[2] << 16; - _v |= _p[3] << 24; + uint32_t _v; + + _v = ((const uint8_t *)_p)[0]; + _v |= ((const uint8_t *)_p)[1] << 8; + _v |= ((const uint8_t *)_p)[2] << 16; + _v |= ((const uint8_t *)_p)[3] << 24; return _v; } static inline void write32(le32_t *_p, uint32_t _v) { - _p[0] = _v & 0xFF; - _p[1] = (_v >> 8) & 0xFF; - _p[2] = (_v >> 16) & 0xFF; - _p[3] = (_v >> 24) & 0xFF; + ((uint8_t *)_p)[0] = _v & 0xFF; + ((uint8_t *)_p)[1] = (_v >> 8) & 0xFF; + ((uint8_t *)_p)[2] = (_v >> 16) & 0xFF; + ((uint8_t *)_p)[3] = (_v >> 24) & 0xFF; } #endif
Christian Schilm?ller wrote:> Hi list! > > Sometimes I need to make boot floppies for an i386 based Linux router. > Just for interest, I tried to use syslinux together with my iMac G4 > (PPC) with Yellow Dog Linux to create the floppy. > I know that this is generally difficult because it requires > cross-compiler and cross-assembler. Nevertheless, I tried it because I > only needed the disk installer, the loader binaries for i386 were > already there. > I've found out that the installer was intended to be portable, but in > fact wasn't due to some typos and missing typecasts in the file > libfat/ulint.h. > I was able to correct them and tested the installer successfully. > > For the case that someone comes across the same problem (or maybe for > the next version), I'll attach the diff-file of my changes here. >Uhm... this doesn't make sense, le16_t is defined as an array of uint8_t's, so the casts should have meant nothing. I wonder if the typedefs at the top of ulint.h need __attribute__((packed)). -hpa
Seemingly Similar Threads
- 3.53-pre5 released - release candidate
- [LLVMdev] Bug in optimization pass related to strcmp and bigendian back-ends
- [LLVMdev] Bug in optimization pass related to strcmp and bigendian back-ends
- [LLVMdev] Bug in optimization pass related to strcmp and bigendian back-ends
- [LLVMdev] Bug in optimization pass related to strcmp and bigendian back-ends