[syslinux] [PATCH 16/20] elflink: ldlinux should not have any dependencies

Matt Fleming matt at console-pimps.org
Sat Apr 16 07:17:44 PDT 2011


From: Matt Fleming <matt.fleming at linux.intel.com>

ldlinux currently requires the get_key() symbol, which means it has a
dependency on libutil_com.c32. ldlinux.c32 really should be a
standalone module so let's move get_key.c into ldlinux/.

However, moving get_key.c creates a new problem - native linux
applications such as com32/samples/keytest.c require the get_key()
symbol which is currently exported by libutil_lnx.a. To fix this, we
create a new native linux library that exports any required symbols
from ldlinux. With this change we need to update com32/Makefile so
that we build com32/elfink/ldlinux before com32/samples, and seeing as
ldlinux now has no dependencies, we may as well move it to the front
of $SUBDIRS.

Also, update elf_gen_dep.sh to skip ldlinux.c32 and not search for
dependencies for any of its unresolved symbols. This way, if anyone
inadvertently introduces a dependency that cannot be resolved by the
core, ldlinux.c32 will fail to load at runtime (which guarantees that
the newly introduced dependency won't go unnoticed).

Signed-off-by: Matt Fleming <matt.fleming at linux.intel.com>
---
 com32/Makefile                               |    4 ++--
 com32/elflink/ldlinux/Makefile               |   10 ++++++++--
 com32/{libutil => elflink/ldlinux}/get_key.c |    0
 com32/libutil/Makefile                       |    2 +-
 elf_gen_dep.sh                               |    1 +
 mk/elf.mk                                    |    3 ++-
 6 files changed, 14 insertions(+), 6 deletions(-)
 rename com32/{libutil => elflink/ldlinux}/get_key.c (100%)

diff --git a/com32/Makefile b/com32/Makefile
index 7506521..8fa40b6 100644
--- a/com32/Makefile
+++ b/com32/Makefile
@@ -1,4 +1,4 @@
-SUBDIRS = tools lib gpllib libutil modules mboot menu samples elflink rosh cmenu \
-	  hdt gfxboot sysdump lua/src elflink/ldlinux
+SUBDIRS = elflink/ldlinux tools lib gpllib libutil modules mboot menu samples elflink rosh cmenu \
+	  hdt gfxboot sysdump lua/src
 all tidy dist clean spotless install:
 	set -e; for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
diff --git a/com32/elflink/ldlinux/Makefile b/com32/elflink/ldlinux/Makefile
index 8fe4d71..318b3ac 100644
--- a/com32/elflink/ldlinux/Makefile
+++ b/com32/elflink/ldlinux/Makefile
@@ -16,12 +16,18 @@ include $(MAKEDIR)/elf.mk
 
 CFLAGS += -I$(topdir)/core/elflink -I$(topdir)/core/include
 
-all: ldlinux.c32
+all: ldlinux.c32 ldlinux_lnx.a
 
 ldlinux.c32 : ldlinux.o cli.o readconfig.o refstr.o colors.o getadv.o \
-		adv.o ipappend.o execute.o kernel.o
+		adv.o ipappend.o execute.o kernel.o get_key.o 
 	$(LD) $(LDFLAGS) -o $@ $^
 
+LNXLIBOBJS = get_key.lo
+ldlinux_lnx.a: $(LNXLIBOBJS)
+	rm -f $@
+	$(AR) cq $@ $(LNXLIBOBJS)
+	$(RANLIB) $@
+
 tidy dist:
 	rm -f *.o *.lo *.a *.lst .*.d 
 
diff --git a/com32/libutil/get_key.c b/com32/elflink/ldlinux/get_key.c
similarity index 100%
rename from com32/libutil/get_key.c
rename to com32/elflink/ldlinux/get_key.c
diff --git a/com32/libutil/Makefile b/com32/libutil/Makefile
index c76433a..8dcede9 100644
--- a/com32/libutil/Makefile
+++ b/com32/libutil/Makefile
@@ -33,7 +33,7 @@ topdir = ../..
 MAKEDIR = $(topdir)/mk
 include $(MAKEDIR)/elf.mk
 
-LIBOBJS	   = ansiline.o ansiraw.o get_key.o sha1hash.o unbase64.o \
+LIBOBJS	   = ansiline.o ansiraw.o sha1hash.o unbase64.o \
 	     md5.o crypt-md5.o sha256crypt.o sha512crypt.o base64.o \
 	     quicksort.o
 LNXLIBOBJS = $(patsubst %.o,%.lo,$(LIBOBJS))
diff --git a/elf_gen_dep.sh b/elf_gen_dep.sh
index 1c357db..9a26c92 100755
--- a/elf_gen_dep.sh
+++ b/elf_gen_dep.sh
@@ -51,6 +51,7 @@ rm_cr ()
 		echo $line | grep extlinux > /dev/null && continue
 		echo $line | grep isolinux > /dev/null && continue
 		echo $line | grep pxelinux > /dev/null && continue
+		echo $line | grep ldlinux > /dev/null && continue
 
 		all_dep=$all_dep$space$line
 		echo $all_dep > rmcr.tmp
diff --git a/mk/elf.mk b/mk/elf.mk
index 4a0b5a6..5a2ce2d 100644
--- a/mk/elf.mk
+++ b/mk/elf.mk
@@ -55,7 +55,8 @@ LNXLDFLAGS = -g
 
 C_LIBS	   = $(com32)/libutil/libutil_com.c32 $(GPLLIB) \
 	     $(com32)/lib/libcom32.c32 $(LIBGCC)
-C_LNXLIBS  = $(com32)/libutil/libutil_lnx.a
+C_LNXLIBS  = $(com32)/libutil/libutil_lnx.a \
+	     $(com32)/elflink/ldlinux/ldlinux_lnx.a
 
 .SUFFIXES: .lss .c .o
 
-- 
1.7.4.2




More information about the Syslinux mailing list