This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
Re: static linking to an older glibc
- From: "Carlos O'Donell" <carlos at systemhalted dot org>
- To: aXqd <axqd001 at gmail dot com>
- Cc: debian-glibc at lists dot debian dot org, libc-help at sourceware dot org
- Date: Tue, 14 Jul 2009 08:37:09 -0400
- Subject: Re: static linking to an older glibc
- References: <9416e6980907132251l28665acfi7eeb84bd9dea4bc8@mail.gmail.com>
On Tue, Jul 14, 2009 at 1:51 AM, aXqd<axqd001@gmail.com> wrote:
> I don't know if I misunderstand the purpose of this mail-list. But I
> don't know somewhere else to ask.
This is not the right place to ask. The correct place is
libc-help@sourceware.org, the GNU C Library help mailing list (added
to the CC). This list is intended for debian-glibc development and
issues. You don't have a debian-glibc issue.
> Recently, I compiled a program on a Debian 5.0.2 system with default
> configurations.
> Then I got 'FATAL: kernel too old' message when I tried the binary
> file on a SLES9 system with the kernel 2.6.5.
>
> 'file foo' said: 'foo: ELF 32-bit LSB executable, Intel 80386, version
> 1 (SYSV), statically linked, for GNU/Linux 2.6.8, not stripped'
> So I guessed the problem might be that GLIBC is not old enough ( with
> --enable-kernel=2.6.8 ).
Correct, every binary compiled with a given version of glibc expects a
given kernel version or newer. The minimum kernel version is encoded
at glibc build time using --enable-kernel. The minimum kernel version
allows glibc to *expect* certain kernel features to be present.
> Then I downloaded libc6-dev_2.3.6.ds1-13etch9+b1_i386.deb, and
> extracted libc.a from it. After that, I compiled again:
> $ gcc -Wall -Wextra -pedantic -O0 -ggdb -std=gnu99 -D_XOPEN_SOURCE=500
> -c -o foo.o foo.c
> $ gcc -Wall -Wextra -pedantic -O0 -ggdb -std=gnu99 -c -o main.o main.c
> $ gcc -Wall -Wextra -pedantic -O0 -ggdb -std=gnu99 -static -nostdlib
> -o foo main.o foo.o old-libc/libc.a `gcc -print-libgcc-file-name`
This procedure is wrong, you can't extract libc.a and use that, there
are many other pieces which are required. You need to unpack all of
libc6-dev and be prepared for some work.
Try the following:
1) Link your application using -v and copy down all the command-line
arguments used by the compiler in the final link.
2) Re-run the final link but instead of using say "crti.o" use
"/path/to/extracted/libc6-dev/crti.o" etc, for all the object files on
the link line that you can find equivalents for in libc6-dev unpacked
package.
This will build you a static application with an old libc6-dev and the
current compiler pieces.
> I got '/usr/bin/ld: warning: cannot find entry symbol _start;
> defaulting to 00000000080480a0' during compilation.
>
> _Q1_: is it safe to ignore this warning, since the program looks good now?
No, it is not safe to ignore this warning.
> _Q2_: what can I do to eliminate this warning?
Follow the steps I just mentioned.
> Then I tried exact the same steps on another Debian 5.0.2 amd64 system.
> Of course, I replaced libc6-dev_2.3.6.ds1-13etch9+b1_i386.deb with
> libc6-dev_2.3.6.ds1-13etch9_amd64.deb.
You are lucky the two glibc's were compatible enough that they worked.
> _Q3_: how can I get rid of the errors below.
Follow the steps I just mentioned.
Cheers,
Carlos.