insmod broken in 1.1.1

Robert P. J. Day rpjday at mindspring.com
Sun Mar 26 07:20:16 PST 2006


On Fri, 24 Mar 2006, Rob Landley wrote:

> On Friday 24 March 2006 1:50 pm, stephane.billiart wrote:
> > I tried to upgrade my system today with busybox and realized that
> > insmod systematically fails with the messages: insmod: ELF file
> > not for this architecture insmod: Could not load the module:
> > Success
> >
> > I added some debug output and saw that the error comes from line
> > 3334 of modutils/insmod.c because of ELFDATAM is wrongly set on
> > line 519 because BB_LITTLE_ENDIAN is not defined (although I am on
> > a P3 compiling for an Elan processor which are little endians).
> >
> > I haven't looked at how BB_LITTLE_ENDIAN is supposed to be
> > calculated but there's apparently something wrong there. I am not
> > sure how to best fix this so I'm asking the list first.
> >
> > In 1.1.0 everything worked ok and the test was #if __BYTE_ORDER ==
> > __LITTLE_ENDIAN
>
> And _this_ is why you want to use if(ENABLE_BLAH) instead of #if
> ENABLE_BLAH, so the compiler barfs if you get the symbol wrong
> rather than silently ignoring it.  (And no, "#ifdef UNKNOWN_SYMBOL"
> never caught this sort of thing either.)

looking at this a bit closer, would it not be possible to move all
endian-ness checking into include/platform.h and get that sort of
thing out of the source files themselves?  you know -- like how it's
done in the header file <netinet/in.h>:

# if __BYTE_ORDER == __BIG_ENDIAN
# define ntohl(x)       (x)
# define ntohs(x)       (x)
# define htonl(x)       (x)
# define htons(x)       (x)
# else
#  if __BYTE_ORDER == __LITTLE_ENDIAN
#   define ntohl(x)     __bswap_32 (x)
#   define ntohs(x)     __bswap_16 (x)
#   define htonl(x)     __bswap_32 (x)
#   define htons(x)     __bswap_16 (x)
#  endif
# endif

and implement the source files in terms of *these* primitives.  i
mean, does libbb/md5.c really need to define its own "swap" routines
based on endianness?

# if !BB_BIG_ENDIAN
#  define SWAP(n) (n)
# elif defined(bswap_32)
#  define SWAP(n) bswap_32(n)
# else
#  define SWAP(n) ((n << 24) | ((n&65280)<<8) | ((n&16711680)>>8) | (n>>24))
# endif


rday


More information about the busybox mailing list