3 # Copyright (C) 2000 by Lineo, inc.
4 # Copyright (C) 2000-2002 Erik Andersen <andersen@uclibc.org>
6 # This program is free software; you can redistribute it and/or modify it under
7 # the terms of the GNU Library General Public License as published by the Free
8 # Software Foundation; either version 2 of the License, or (at your option) any
11 # This program is distributed in the hope that it will be useful, but WITHOUT
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 # FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
16 # You should have received a copy of the GNU Library General Public License
17 # along with this program; if not, write to the Free Software Foundation, Inc.,
18 # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 # Derived in part from the Linux-8086 C library, the GNU C Library, and several
21 # other sundry sources. Files within this library are copyright by their
22 # respective copyright holders.
27 include $(TOPDIR)Rules.mak
28 LDSO_FULLNAME=ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so
29 LIBGCC:=$(shell $(CC) -print-libgcc-file-name)
31 # Enable this to enable all the code needed to support traditional ldd
32 # (i.e. where the shared library loader does all the heavy lifting)
33 # Since this currently only saves about 300 bytes, I'm going to leave
37 # Enable this to enable all the code needed for debugging the runtime
38 # linking of an application using the LD_DEBUG environment variable:
39 # LD_DEBUG=token1,token2,.. prog
40 # enables diagnostics to the stderr.
41 # For now there are these tokens possible:
42 # bindings displays the resolve processing (function calls); detail shows the relocation patch
43 # detail provide more information for some options
44 # move display copy processings
45 # reloc display relocation processing; detail shows the relocation patch
46 # symbols display symbol table processing
48 # The additional environment variable:
49 # LD_DEBUG_OUTPUT=file
50 # redirects the diagnostics to an output file created using
51 # the specified name and the process id as a suffix.
54 # $ LD_DEBUG=binding,move,symbols,reloc,detail LD_DEBUG_OUTPUT=appname ./appname
56 #XXFLAGS+= -DSUPPORT_LD_DEBUG
58 # Enable this for the very very early debugging. Really only useful
59 # for people porting to new architectures.
62 # Enable this to never actually fixup symbols...
63 #XXFLAGS+= -DLD_NEVER_FIXUP_SYMBOLS
65 XXFLAGS+=-DUCLIBC_TARGET_PREFIX=\"$(TARGET_PREFIX)\" \
66 -DUCLIBC_DEVEL_PREFIX=\"$(DEVEL_PREFIX)\" \
67 -DUCLIBC_BUILD_DIR=\"$(shell cd $(TOPDIR) && pwd)\"
68 LDFLAGS=-shared --warn-common --export-dynamic --sort-common \
69 -z combreloc --discard-locals --discard-all
70 CSRC= ldso.c #hash.c readelflib1.c $(TARGET_ARCH)/elfinterp.c
71 COBJS=$(patsubst %.c,%.o, $(CSRC))
72 ASRC=$(shell ls $(TARGET_ARCH)/*.S)
73 AOBJS=$(patsubst %.S,%.o, $(ASRC))
74 OBJS=$(AOBJS) $(COBJS)
76 ifeq ($(strip $(TARGET_ARCH)),cris)
80 ifneq ($(strip $(DODEBUG)),true)
86 lib:: ldso.h $(OBJS) $(DLINK_OBJS)
87 $(LD) $(LDFLAGS) -e _dl_boot -soname=$(UCLIBC_LDSO) \
88 -o $(LDSO_FULLNAME) $(OBJS) $(LIBGCC);
89 install -d $(TOPDIR)lib
90 install -m 755 $(LDSO_FULLNAME) $(TOPDIR)lib
91 (cd $(TOPDIR)lib && ln -sf $(LDSO_FULLNAME) $(UCLIBC_LDSO))
94 echo "const char *_dl_progname=\""$(UCLIBC_LDSO)"\";" > ldso.h
95 echo "#include \"$(TARGET_ARCH)/elfinterp.c\"" >> ldso.h
99 $(CC) $(CFLAGS) $(XXFLAGS) -I. -I./$(TARGET_ARCH) -I../libdl -c $< -o $@
100 $(STRIPTOOL) -x -R .note -R .comment $*.o
103 $(CC) $(CFLAGS) -I. -I./$(TARGET_ARCH) -I../libdl -c $< -o $@
104 $(STRIPTOOL) -x -R .note -R .comment $*.o
106 ldso.o: ldso.c hash.c readelflib1.c $(TARGET_ARCH)/elfinterp.c \
107 ld_hash.h ld_string.h ld_syscall.h ldso.h linuxelf.h
110 $(RM) -f $(UCLIBC_LDSO)* $(OBJS) $(LDSO_FULLNAME)* core *.o *.a *.s *.i ldso.h *~