Build a modern (4.x) GCC to target the 2.4.x kernel in the same architecture as the host?

The question is relatively simple: how can I build GCC from the 4.x series (along with binutils and friends) that targets 2.4 ABI on the same architecture as the host for the compiler?

The host system will be x86 or x86_64, and the only requirement is that ELF embedded files run on the old kernel as long as it matches ABI. (Kernel sources / headers exist)

A compatible libc is also required to link it. However, I can dynamically communicate with it, since I know the version (g) of libc.

Any pointers would be much appreciated. I am a little familiar with crosstool-ng , but it seems to no longer support 2.4 kernels (for obvious reasons).

+7
source share
2 answers

Probably the easiest way is to install a modern tool chain on an old OS.

RHEL 2.1 or 3 may be the best, as they were supported until recently.

Compiling gcc 4 can be complicated, as you will need math libraries. You may need to take a multi-step approach.

EDIT:

To compile the new gcc:

  • Compile last make - add to PATH
  • Unpack gcc
  • Unpack mpfr, gmp, mpc to gcc directory
  • The symbol for linking directory versions to the base (mpfr, gmp, mpc).
  • Build and install gcc

Something like that:

cd ~/software tar xjf $DOWNLOAD/gcc/gcc-core-${GCCVER}.tar.bz2 || failure "unpack gcc failed" tar xjf $DOWNLOAD/gcc/gcc-g++-${GCCVER}.tar.bz2 || failure "unpack g++ failed" cd gcc-${GCCVER} tar xjf $DOWNLOAD/gmp-5.0.2.tar.bz2 || failure "unpack gmp failed" #tar xjf $DOWNLOAD/gmp-4.3.2.tar.bz2 || failure "unpack gmp failed" ln -s gmp-* gmp tar xjf $DOWNLOAD/mpfr-2.4.2.tar.bz2 || failure "unpack mpfr failed" #tar xjf $DOWNLOAD/mpfr-2.4.2.tar.bz2 || failure "unpack mpfr failed" ln -s mpfr-* mpfr tar xzf $DOWNLOAD/mpc-0.9.tar.gz || failure "unpack mpc failed" ln -s mpc-* mpc cd .. mkdir gcc-build cd gcc-build ../gcc-${GCCVER}/configure --prefix=/opt/tools || failure "configure failed" make || failure "make failed" make install || failure "install failed" 
+1
source

I would believe that in this case you probably should build a GCC cross-compiler and that you should compile GLibc, which will handle dependency on the old 2.4 kernel.

However, you just tried to compile your code and just link it to the old 2.4-core Glibc library? I would suggest that this should work.

And you tried to run your binary (which got an easy way on a recent system using your recent GCC) on the old system? What does not work as expected?

Sincerely.

0
source

All Articles