static linking to an older glibc

2009-07-14 Thread aXqd
Hi, all:

I don't know if I misunderstand the purpose of this mail-list. But I
don't know somewhere else to ask.

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 ).

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`

I got '/usr/bin/ld: warning: cannot find entry symbol _start;
defaulting to 080480a0' during compilation.

_Q1_: is it safe to ignore this warning, since the program looks good now?
_Q2_: what can I do to eliminate this warning?

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.

_Q3_: how can I get rid of the errors below.

Thanks in advance.

old-libc/libc.a(ioputs.o): In function `puts':
(.text+0x17b): undefined reference to `_Unwind_Resume'
old-libc/libc.a(ioputs.o):(.eh_frame+0x13): undefined reference to
`__gcc_personality_v0'
old-libc/libc.a(putchar.o):(.eh_frame+0x12): undefined reference to
`__gcc_personality_v0'
old-libc/libc.a(iofclose.o): In function `fclose':
(.text+0x1f6): undefined reference to `_Unwind_Resume'
old-libc/libc.a(iofclose.o):(.eh_frame+0x13): undefined reference to
`__gcc_personality_v0'
old-libc/libc.a(iofputs.o): In function `fputs':
(.text+0x135): undefined reference to `_Unwind_Resume'
old-libc/libc.a(iofputs.o):(.eh_frame+0x13): undefined reference to
`__gcc_personality_v0'
old-libc/libc.a(iofwrite.o): In function `fwrite':
(.text+0x15e): undefined reference to `_Unwind_Resume'
old-libc/libc.a(iofwrite.o):(.eh_frame+0x13): undefined reference to
`__gcc_personality_v0'
old-libc/libc.a(wfileops.o): In function `_IO_wfile_underflow':
(.text+0x1193): undefined reference to `_Unwind_Resume'
old-libc/libc.a(wfileops.o):(.eh_frame+0x13): undefined reference to
`__gcc_personality_v0'
old-libc/libc.a(fileops.o): In function `_IO_file_underflow':
(.text+0x10ee): undefined reference to `_Unwind_Resume'
old-libc/libc.a(fileops.o): In function `_IO_file_fopen':
(.text+0x196e): undefined reference to `_Unwind_Resume'
old-libc/libc.a(fileops.o):(.eh_frame+0x13): undefined reference to
`__gcc_personality_v0'
old-libc/libc.a(syslog.o): In function `openlog':
(.text+0x2d7): undefined reference to `_Unwind_Resume'
old-libc/libc.a(syslog.o): In function `vsyslog':
(.text+0x814): undefined reference to `_Unwind_Resume'
old-libc/libc.a(syslog.o): In function `vsyslog':
(.text+0x82c): undefined reference to `_Unwind_Resume'
old-libc/libc.a(syslog.o): In function `closelog':
(.text+0x942): undefined reference to `_Unwind_Resume'
old-libc/libc.a(syslog.o):(.eh_frame+0x13): undefined reference to
`__gcc_personality_v0'
old-libc/libc.a(iofflush.o): In function `fflush':
(.text+0xf0): undefined reference to `_Unwind_Resume'
old-libc/libc.a(iofflush.o):(.eh_frame+0x13): undefined reference to
`__gcc_personality_v0'
old-libc/libc.a(ioftell.o):(.eh_frame+0x12): undefined reference to
`__gcc_personality_v0'
old-libc/libc.a(iogetdelim.o):(.eh_frame+0x12): undefined reference to
`__gcc_personality_v0'
old-libc/libc.a(ioseekoff.o):(.eh_frame+0x12): undefined reference to
`__gcc_personality_v0'
old-libc/libc.a(fseek.o):(.eh_frame+0x12): undefined reference to
`__gcc_personality_v0'
collect2: ld returned 1 exit status

-- 
Regards.
-Tian


-- 
To UNSUBSCRIBE, email to debian-glibc-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Re: static linking to an older glibc

2009-07-14 Thread Carlos O'Donell
On Tue, Jul 14, 2009 at 1:51 AM, aXqdaxqd...@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-h...@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 080480a0' 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.


-- 
To UNSUBSCRIBE, email to debian-glibc-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Re: static linking to an older glibc

2009-07-14 Thread aXqd

2009-7-14,20:37,Carlos O'Donell car...@systemhalted.org

Follow the steps I just mentioned.

Cheers,
Carlos.


I got it. It's very helpful. You, Debian people, are so kind. Thanks  
very much.


Regards.
-Tian
From my iphone

--
To UNSUBSCRIBE, email to debian-glibc-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org