This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
Re: Build malloc.c shared object?
- From: sam shepperd <samshepperd at gmail dot com>
- To: Ryan Arnold <ryan dot arnold at gmail dot com>
- Cc: "Carlos O'Donell" <carlos at systemhalted dot org>, libc-help at sourceware dot org
- Date: Sun, 1 Nov 2009 23:27:16 -0600
- Subject: Re: Build malloc.c shared object?
- References: <9a0bd7f70808110639o18360c59ya51837a1ba57a808@mail.gmail.com> <119aab440808120605x1b071987oc5b4e5e84a873e40@mail.gmail.com> <ff4da150808121108n3f149f1nd125cf6d72120ad1@mail.gmail.com> <9a0bd7f70808121442w785a502dybffbd3b205f50adf@mail.gmail.com>
> On Tue, Aug 12, 2008 at 1:08 PM, Ryan Arnold <ryan.arnold@gmail.com> wrote:
>> On Tue, Aug 12, 2008 at 8:05 AM, Carlos O'Donell
>> <carlos@systemhalted.org> wrote:
>>
>>> I recommend you build glibc for your target, saving the build log
>>> file, and examine the command line used to build malloc.os and then
>>> use that as the basis for your work.
>>
>> Sam, I've written a piece for the GLIBC wiki that has instructions on
>> how to do this. ?The actual article isn't entirely relevant but the
>> steps it presents will show how to extract the bit out of the build
>> log.
>>
>> http://sources.redhat.com/glibc/wiki/Debugging/Development_Debugging#head-edb51941f7995183fbe506af7154519ad0fa9fc4
>>
>> Regards,
>> Ryan
This no longer works [glibc 2.11: --with-tls --with-__thread
--enable-shared --enable-add-ons=nptl] :-(
>From build log:
gcc malloc.c -c -std=gnu99 -fgnu89-inline -O2 -U_FORTIFY_SOURCE -Wall
-Wbad-function-cast -Wcast-qual -Wcomment -Wcomments -Wfloat-equal
-Winline -Wmissing-declarations -Wmissing-noreturn
-Wmissing-prototypes -Wmultichar -Wsign-compare -Wtrigraphs
-Wwrite-strings -fmerge-all-constants -fno-stack-protector
-Wstrict-prototypes -fPIC -DMORECORE_CLEARS=2 -I../include
-I/home/sam/build/malloc -I/home/sam/build -I../sysdeps/x86_64/elf
-I../nptl/sysdeps/unix/sysv/linux/x86_64
-I../sysdeps/unix/sysv/linux/x86_64
-I../sysdeps/unix/sysv/linux/wordsize-64
-I../nptl/sysdeps/unix/sysv/linux -I../nptl/sysdeps/pthread
-I../sysdeps/pthread -I../sysdeps/unix/sysv/linux -I../sysdeps/gnu
-I../sysdeps/unix/common -I../sysdeps/unix/mman -I../sysdeps/unix/inet
-I../nptl/sysdeps/unix/sysv -I../sysdeps/unix/sysv
-I../sysdeps/unix/x86_64 -I../nptl/sysdeps/unix -I../sysdeps/unix
-I../sysdeps/posix -I../sysdeps/x86_64/fpu -I../nptl/sysdeps/x86_64
-I../sysdeps/x86_64 -I../sysdeps/wordsize-64
-I../sysdeps/ieee754/ldbl-96 -I../sysdeps/ieee754/dbl-64
-I../sysdeps/ieee754/flt-32 -I../sysdeps/ieee754
-I../sysdeps/generic/elf -I../sysdeps/generic -I../nptl -I..
-I../libio -I. -D_LIBC_REENTRANT -include ../include/libc-symbols.h
-DPIC -DSHARED -o /home/sam/build/malloc/malloc.os
$ file malloc.os
malloc/malloc.os: ELF 64-bit LSB relocatable, x86-64, version 1
(SYSV), not stripped
$ gcc -shared malloc.os
/usr/bin/ld: malloc.os: relocation R_X86_64_PC32 against undefined
symbol `__libc_multiple_threads' can not be used when making a shared
object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: ld returned 1 exit status
$ nm malloc.os | grep __libc_multiple_threads
U __libc_multiple_threads
-fPIC is already in build log?