Building 32 bit (Intel X86) kernel module on a 64 bit (Intel x86_64) machine

Building 32 bit (Intel X86) kernel module on a 64 bit (Intel x86_64) machine

Dan Shimshoni danshimsh at gmail.com
Tue Jul 14 11:27:53 IDT 2009


Hello,

I want to build an Intel x86 32 bit kernel module on Intel x86_64
machine (64 bit) running Linux.
My goal is to prepare a module on a 64 bit machine, so that I can
insmod this module on a 32
bit machine successfully (and don't tell me that I can build the
module on a 32 bit machine. I of course know that and want to avoid
it).

For that I need to build a 32 bit gcc compiler on the x86_64 machine
(cross compiler).
There are various tools for buildings such a cross compiler. One is
Dan Kegel tool:  http://kegel.com/crosstool/

Another tool is Cross-Compiled Linux From Scratch:
http://cross-lfs.org/view/1.1.0/x86_64/introduction/chapter.html

I want to add that "make ARCH=i686" (on the 64 bit machine) gave me errors
(and also trying to passing various gcc 32 bit arch flags ).

It seems to me that both these tools are more complicated then needed.
Does anyone know a better way for achieving this ? for example, building
binutils on the x86_64 machine (maybe with a specific 32 bit flag, and
maybe also building glibc with a flag specifying the target is intel
x86 machine is a must ?), and then building gcc against this libraries
?

Rgs,
Dan



More information about the Linux-il mailing list