瀏覽代碼

Fixup build a bit. Be sneaky and include everything into
a single .c file, making stuff be even smaller.

Eric Andersen 23 年之前
父節點
當前提交
a5e190ebf3
共有 8 個文件被更改,包括 21 次插入50 次删除
  1. 1 1
      ldso/ldso/.cvsignore
  2. 15 5
      ldso/ldso/Makefile
  3. 0 11
      ldso/ldso/dl-elf.c
  4. 0 6
      ldso/ldso/dl-hash.c
  5. 0 6
      ldso/ldso/hash.c
  6. 0 7
      ldso/ldso/i386/elfinterp.c
  7. 5 3
      ldso/ldso/ldso.c
  8. 0 11
      ldso/ldso/readelflib1.c

+ 1 - 1
ldso/ldso/.cvsignore

@@ -1,2 +1,2 @@
 ld-uclibc.so*
-ld-uClibc.h
+ldso.h

+ 15 - 5
ldso/ldso/Makefile

@@ -29,34 +29,44 @@ include $(TOPDIR)Rules.mak
 
 LDSO_FULLNAME=ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).so
 
-CFLAGS += -fPIC -D__PIC__
 #XXFLAGS += #-DDL_DEBUG #-funroll-loops
 XXFLAGS+=-DUCLIBC_TARGET_PREFIX=\"$(TARGET_PREFIX)\" \
 	-DUCLIBC_DEVEL_PREFIX=\"$(DEVEL_PREFIX)\" \
 	-DUCLIBC_BUILD_DIR=\"$(shell cd $(TOPDIR) && pwd)\"
-CSRC= ldso.c hash.c readelflib1.c $(TARGET_ARCH)/elfinterp.c
+LDFLAGS=-nostdlib -shared --warn-common --export-dynamic --warn-once \
+	-z combreloc --sort-common --discard-locals --discard-all
+CSRC= ldso.c #hash.c readelflib1.c $(TARGET_ARCH)/elfinterp.c
 COBJS=$(patsubst %.c,%.o, $(CSRC))
 ASRC=$(shell ls $(TARGET_ARCH)/*.S)
 AOBJS=$(patsubst %.S,%.o, $(ASRC))
 OBJS=$(AOBJS) $(COBJS)
 
+ifneq ($(strip $(DODEBUG)),true)
+LDFLAGS+=-s
+endif
 
 all: lib
 
 lib:: ldso.h $(OBJS) $(DLINK_OBJS)
-	$(LD) -e _dl_boot $(LDFLAGS) -nostdlib -shared -o $(LDSO_FULLNAME) \
-	    -soname=$(UCLIBC_LDSO) -Bstatic $(OBJS)
+	$(CC) -e _dl_boot $(LDFLAGS) -o $(LDSO_FULLNAME) \
+	    -Wl,-soname=$(UCLIBC_LDSO) $(OBJS)
 	install -d $(TOPDIR)lib 
 	install -m 755 $(LDSO_FULLNAME) $(TOPDIR)lib
 	(cd $(TOPDIR)lib && ln -sf $(LDSO_FULLNAME) $(UCLIBC_LDSO))
 
 ldso.h: Makefile
-	echo "#define _dl_static_progname \""$(UCLIBC_LDSO)"\"" > ld-uClibc.h
+	echo "const char *_dl_progname=\""$(UCLIBC_LDSO)"\";" > ldso.h
+	echo "#include \"$(TARGET_ARCH)/elfinterp.c\"" >> ldso.h
+
 
 $(COBJS): %.o : %.c
 	$(CC) $(CFLAGS) $(XXFLAGS) -I. -I./$(TARGET_ARCH) -I../libdl -c $< -o $@
 	$(STRIPTOOL) -x -R .note -R .comment $*.o
 
+$(AOBJS): %.o : %.S
+	$(CC) $(CFLAGS) -I. -I./$(TARGET_ARCH) -I../libdl -c $< -o $@
+	$(STRIPTOOL) -x -R .note -R .comment $*.o
+
 clean::
 	$(RM) -f $(UCLIBC_LDSO)* $(OBJS) $(LDSO_FULLNAME)* core *.o *.a *.s *.i ldso.h *~
 

+ 0 - 11
ldso/ldso/dl-elf.c

@@ -21,17 +21,6 @@
 /* This file contains the helper routines to load an ELF sharable
    library into memory and add the symbol table info to the chain. */
 
-#include "linuxelf.h"
-#include "ld_hash.h"
-#include "ld_syscall.h"
-#include "ld_string.h"
-#include <sys/mman.h>
-#ifdef USE_CACHE
-#include "../config.h"
-#endif
-
-extern char *_dl_progname;
-
 #ifdef USE_CACHE
 
 static caddr_t _dl_cache_addr = NULL;

+ 0 - 6
ldso/ldso/dl-hash.c

@@ -20,12 +20,6 @@
 
 /* Various symbol table handling functions, including symbol lookup */
 
-#include "dlfcn.h"
-#include "linuxelf.h"
-#include "ld_hash.h"
-#include "ld_syscall.h"
-#include "ld_string.h"
-
 /*
  * This is the start of the linked list that describes all of the files present
  * in the system with pointers to all of the symbol, string, and hash tables, 

+ 0 - 6
ldso/ldso/hash.c

@@ -20,12 +20,6 @@
 
 /* Various symbol table handling functions, including symbol lookup */
 
-#include "dlfcn.h"
-#include "linuxelf.h"
-#include "ld_hash.h"
-#include "ld_syscall.h"
-#include "ld_string.h"
-
 /*
  * This is the start of the linked list that describes all of the files present
  * in the system with pointers to all of the symbol, string, and hash tables, 

+ 0 - 7
ldso/ldso/i386/elfinterp.c

@@ -39,13 +39,6 @@ static char *_dl_reltypes[] =
    a more than adequate job of explaining everything required to get this
    working. */
 
-#include "linuxelf.h"
-#include "ld_hash.h"
-#include "ld_syscall.h"
-#include "ld_string.h"
-
-extern char *_dl_progname;
-
 extern int _dl_linux_resolve(void);
 
 unsigned long _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry)

+ 5 - 3
ldso/ldso/ldso.c

@@ -91,11 +91,12 @@
  * can transfer control to the user's application.
  */
 
-#include "linuxelf.h"
 #include <stdarg.h>
+#include "linuxelf.h"
 #include "ld_hash.h"
 #include "ld_syscall.h"
 #include "ld_string.h"
+#include "dlfcn.h"
 #include "../config.h"
 
 #define ALLOW_ZERO_PLTGOT
@@ -115,8 +116,6 @@
 static char *_dl_malloc_addr, *_dl_mmap_zero;
 char *_dl_library_path = 0;		/* Where we look for libraries */
 char *_dl_preload = 0;			/* Things to be loaded before the libs. */
-#include "ld-uClibc.h"			/* Pull in the name of ld.so */
-const char *_dl_progname=_dl_static_progname;
 static char *_dl_not_lazy = 0;
 #ifdef DL_TRACE
 static char *_dl_trace_loaded_objects = 0;
@@ -134,6 +133,7 @@ void _dl_debug_state(void);
 char *_dl_get_last_path_component(char *path);
 
 #include "boot1_arch.h"
+#include "ldso.h"			/* Pull in the name of ld.so */
 
 
 /* When we enter this piece of code, the program stack looks like this:
@@ -1210,3 +1210,5 @@ void _dl_dprintf(int fd, const char *fmt, ...)
     return;
 }
 
+#include "hash.c"
+#include "readelflib1.c"

+ 0 - 11
ldso/ldso/readelflib1.c

@@ -21,17 +21,6 @@
 /* This file contains the helper routines to load an ELF sharable
    library into memory and add the symbol table info to the chain. */
 
-#include "linuxelf.h"
-#include "ld_hash.h"
-#include "ld_syscall.h"
-#include "ld_string.h"
-#include <sys/mman.h>
-#ifdef USE_CACHE
-#include "../config.h"
-#endif
-
-extern char *_dl_progname;
-
 #ifdef USE_CACHE
 
 static caddr_t _dl_cache_addr = NULL;