Date: Thu, 3 Apr 1997 19:12:09 +0200 From: Ollivier Robert <roberto@keltia.freenix.fr> To: "Nickolay N. Dudorov" <nnd@info.itfs.nsk.su> Cc: "FreeBSD Hackers' list" <freebsd-hackers@FreeBSD.ORG> Subject: Re: FreeBSD Elf-Kit and dynamic loading Message-ID: <19970403191209.52889@keltia.freenix.fr> In-Reply-To: <5i0j1d$jtk@news.itfs.nsk.su>; from Nickolay N. Dudorov on Thu, Apr 03, 1997 at 03:40:29PM %2B0000 References: <5i0j1d$jtk@news.itfs.nsk.su>
next in thread | previous in thread | raw e-mail | index | archive | help
According to Nickolay N. Dudorov:
> And after that I discovered that 'file hello'
> says:
> hello: ELF 32-bit LSB executable, Intel 80386, version 1 (FreeBSD)
>
> and file 'hello' is 47761 bytes long.
>
> So, there is a question - is there any possibility to
> build "dynamic ELF" program ? My elf-gcc produce identical results
> with and without '-static' flag.
Are you sure you have the right naming for the libraries ?
258 [19:05] roberto@keltia:/tmp> cat foo.c
main(){}
260 [19:06] roberto@keltia:/tmp> cc foo.c -o foo -v
Reading specs from
/usr/local/elf/lib/gcc-lib/i386-unknown-freebsdelf/2.7.2.1/specs
gcc version 2.7.2.1
/usr/local/elf/lib/gcc-lib/i386-unknown-freebsdelf/2.7.2.1/cpp -lang-c -v
-undef -D__GNUC__=2 -D__GNUC_MINOR__=7 -Dunix -Di386 -D__ELF__
-D__FreeBSD__=2 -D__unix__ -D__i386__ -D__ELF__ -D__FreeBSD__=2 -D__unix
-D__i386 -Asystem(unix) -Asystem(FreeBSD) -Acpu(i386) -Amachine(i386) foo.c
/tmp/cc029804.i
GNU CPP version 2.7.2.1 (i386 FreeBSD/ELF)
#include "..." search starts here:
#include <...> search starts here:
/usr/local/elf/lib/gcc-lib/i386-unknown-freebsdelf/2.7.2.1/include
/usr/local/elf/lib/gcc-lib/i386-unknown-freebsdelf/2.7.2.1/sys-include
/usr/local/elf/i386-unknown-freebsdelf/include
End of search list.
/usr/local/elf/lib/gcc-lib/i386-unknown-freebsdelf/2.7.2.1/cc1
/tmp/cc029804.i -quiet -dumpbase foo.c -version -o /tmp/cc029804.s
GNU C version 2.7.2.1 (i386 FreeBSD/ELF) compiled by GNU C version 2.7.2.1.
/usr/local/elf/i386-unknown-freebsdelf/bin/as -V -Qy -o /tmp/cc0298041.o
/tmp/cc029804.s
GNU assembler version 2.7 (i386-unknown-freebsdelf), using BFD version 2.7
/usr/local/elf/i386-unknown-freebsdelf/bin/ld -m elf_i386 -dynamic-linker
/usr/libexec/ld-elf.so.1 -o foo
/usr/local/elf/i386-unknown-freebsdelf/lib/crt1.o
/usr/local/elf/i386-unknown-freebsdelf/lib/crti.o
/usr/local/elf/i386-unknown-freebsdelf/lib/crtbegin.o
-L/usr/local/elf/lib/gcc-lib/i386-unknown-freebsdelf/2.7.2.1
-L/usr/local/elf/i386-unknown-freebsdelf/lib /tmp/cc0298041.o -lgcc -lc
-lgcc /usr/local/elf/i386-unknown-freebsdelf/lib/crtend.o
/usr/local/elf/i386-unknown-freebsdelf/lib/crtn.o
261 [19:06] roberto@keltia:/tmp> ll foo
-rwxr-xr-x 1 roberto wheel 4124 Apr 3 19:06 foo
262 [19:07] roberto@keltia:/tmp> size foo
text data bss dec hex filename
652 811 8 1471 5bf foo
In /usr/local/elf/lib:
-r--r--r-- 1 bin bin 939192 Apr 3 19:01 libc.a
-r--r--r-- 2 bin bin 465883 Apr 3 18:59 libc.so
-r--r--r-- 2 bin bin 465883 Apr 3 18:59 libc.so.1
-r--r--r-- 1 bin bin 1009454 Apr 3 19:01 libc_pic.a
With -static the executable is
-rwxr-xr-x 1 roberto wheel 44788 Apr 3 19:11 foo
objdump --all-headers gives:
foo: file format elf32-i386
foo
architecture: i386, flags 0x00000112:
EXEC_P, HAS_SYMS, D_PAGED
start address 0x080482e0
...
Dynamic Section:
NEEDED libc.so.1
INIT 0x8048294
FINI 0x8048520
...
Sections:
Idx Name Size VMA LMA File off Algn
0 .interp 00000019 080480d4 080480d4 000000d4 2**0
CONTENTS, ALLOC, LOAD, READONLY, DATA
1 .hash 00000048 080480f0 080480f0 000000f0 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
2 .dynsym 000000d0 08048138 08048138 00000138 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
3 .dynstr 00000071 08048208 08048208 00000208 2**0
CONTENTS, ALLOC, LOAD, READONLY, DATA
4 .rel.plt 00000018 0804827c 0804827c 0000027c 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
...
--
Ollivier ROBERT -=- FreeBSD: There are no limits -=- roberto@keltia.freenix.fr
Usenet Canal Historique
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19970403191209.52889>
