This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Build malloc.c shared object?

> On Tue, Aug 12, 2008 at 1:08 PM, Ryan Arnold <> wrote:
>> On Tue, Aug 12, 2008 at 8:05 AM, Carlos O'Donell
>> <> 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.
>> 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 -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?

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]