diff options
author | Matt Fleming <matt.fleming@intel.com> | 2013-05-16 10:16:17 +0100 |
---|---|---|
committer | Matt Fleming <matt.fleming@intel.com> | 2013-05-16 11:01:55 +0100 |
commit | 2bd94fb6ed5f7f7472319cd6adaa25ccf9819230 (patch) | |
tree | 243d4733e1d319b5b0536eb4fc7a1383028c5219 | |
parent | 34eeaa3d747284fea6eb44ebc971cb513816cb5e (diff) | |
download | syslinux-2bd94fb6ed5f7f7472319cd6adaa25ccf9819230.tar.gz syslinux-2bd94fb6ed5f7f7472319cd6adaa25ccf9819230.tar.xz syslinux-2bd94fb6ed5f7f7472319cd6adaa25ccf9819230.zip |
ldlinux: use platform filename extension
Users are starting to package all Syslinux versions on one boot medium
and are running into problems because all versions of ldlinux have the
same filename, ldlinux.c32. The version of ldlinux.c32 compiled for bios
will not work with efi32 or efi64, and vice versa. What we need is a way
for the Syslinux core to know exactly which filename to load.
Use the following extensions for the corresponding platforms,
.c32 - bios
.e32 - efi32
.e64 - efi64
Now all ldlinux variants can be kept in the same directory without
causing any conflicts.
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
-rw-r--r-- | Makefile | 8 | ||||
-rw-r--r-- | com32/elflink/ldlinux/Makefile | 12 | ||||
-rw-r--r-- | com32/elflink/ldlinux/execute.c | 6 | ||||
-rw-r--r-- | core/Makefile | 2 | ||||
-rw-r--r-- | core/elflink/load_env32.c | 9 | ||||
-rw-r--r-- | mk/efi.mk | 2 | ||||
-rw-r--r-- | mk/elf.mk | 2 |
7 files changed, 25 insertions, 16 deletions
@@ -239,19 +239,21 @@ bios: @mkdir -p $(OBJ)/bios $(MAKE) -C $(OBJ)/bios -f $(SRC)/Makefile SRC="$(SRC)" \ objdir=$(OBJ)/bios OBJ=$(OBJ)/bios HAVE_FIRMWARE=1 \ - ARCH=i386 $(MAKECMDGOALS) + ARCH=i386 LDLINUX=ldlinux.c32 $(MAKECMDGOALS) efi32: @mkdir -p $(OBJ)/efi32 $(MAKE) -C $(OBJ)/efi32 -f $(SRC)/Makefile SRC="$(SRC)" \ objdir=$(OBJ)/efi32 OBJ=$(OBJ)/efi32 HAVE_FIRMWARE=1 \ - ARCH=i386 BITS=32 EFI_BUILD=1 $(MAKECMDGOALS) + ARCH=i386 BITS=32 EFI_BUILD=1 LDLINUX=ldlinux.e32 \ + $(MAKECMDGOALS) efi64: @mkdir -p $(OBJ)/efi64 $(MAKE) -C $(OBJ)/efi64 -f $(SRC)/Makefile SRC="$(SRC)" \ objdir=$(OBJ)/efi64 OBJ=$(OBJ)/efi64 HAVE_FIRMWARE=1 \ - ARCH=x86_64 BITS=64 EFI_BUILD=1 $(MAKECMDGOALS) + ARCH=x86_64 BITS=64 EFI_BUILD=1 LDLINUX=ldlinux.e64 \ + $(MAKECMDGOALS) else # ifeq($(HAVE_FIRMWARE),) diff --git a/com32/elflink/ldlinux/Makefile b/com32/elflink/ldlinux/Makefile index bfec4503..d948da43 100644 --- a/com32/elflink/ldlinux/Makefile +++ b/com32/elflink/ldlinux/Makefile @@ -20,12 +20,20 @@ OBJS = ldlinux.o cli.o readconfig.o refstr.o colors.o getadv.o adv.o \ execute.o chainboot.o kernel.o get_key.o advwrite.o setadv.o \ loadhigh.o msg.o -BTARGET = ldlinux.c32 +BTARGET = $(LDLINUX) + +ifdef EFI_BUILD +%.e$(BITS): %.elf + $(OBJCOPY) --strip-debug --strip-unneeded $< $@ +SONAME = $(patsubst %.elf,%.e$(BITS),$(@F)) +else +SONAME = $(patsubst %.elf,%.c32,$(@F)) +endif all: $(BTARGET) ldlinux_lnx.a ldlinux.elf : $(OBJS) - $(LD) $(LDFLAGS) -soname $(patsubst %.elf,%.c32,$(@F)) -o $@ $^ $(LIBS) + $(LD) $(LDFLAGS) -soname $(SONAME) -o $@ $^ $(LIBS) LNXCFLAGS += -D__export='__attribute__((visibility("default")))' LNXLIBOBJS = get_key.lo diff --git a/com32/elflink/ldlinux/execute.c b/com32/elflink/ldlinux/execute.c index bf0bd8ce..653c880d 100644 --- a/com32/elflink/ldlinux/execute.c +++ b/com32/elflink/ldlinux/execute.c @@ -131,14 +131,14 @@ __export void execute(const char *cmdline, uint32_t type, bool sysappend) * irrespective of how the COM32 module was loaded, * e.g. from vesamenu.c32. */ - unload_modules_since("ldlinux.c32"); + unload_modules_since(LDLINUX); /* Restore the console */ ldlinux_console_init(); ldlinux_enter_command(); } else if (type == IMAGE_TYPE_CONFIG) { - char *argv[] = { "ldlinux.c32", NULL, NULL }; + char *argv[] = { LDLINUX, NULL, NULL }; char *config; int rv; @@ -155,7 +155,7 @@ __export void execute(const char *cmdline, uint32_t type, bool sysappend) argv[1] = config; rv = start_ldlinux(2, argv); - printf("Failed to exec ldlinux.c32: %s\n", strerror(rv)); + printf("Failed to exec %s: %s\n", LDLINUX, strerror(rv)); } else if (type == IMAGE_TYPE_LOCALBOOT) { local_boot(strtoul(kernel, NULL, 0)); } else if (type == IMAGE_TYPE_PXE || type == IMAGE_TYPE_BSS || diff --git a/core/Makefile b/core/Makefile index 87cf44b4..eaf12443 100644 --- a/core/Makefile +++ b/core/Makefile @@ -97,7 +97,7 @@ NASMOPT += $(NASMDEBUG) PREPCORE = $(OBJ)/../lzo/prepcore -CFLAGS += -D__SYSLINUX_CORE__ -I$(objdir) +CFLAGS += -D__SYSLINUX_CORE__ -I$(objdir) -DLDLINUX=\"$(LDLINUX)\" # The DATE is set on the make command line when building binaries for # official release. Otherwise, substitute a hex string that is pretty much diff --git a/core/elflink/load_env32.c b/core/elflink/load_env32.c index 5f797d67..470bd154 100644 --- a/core/elflink/load_env32.c +++ b/core/elflink/load_env32.c @@ -22,8 +22,6 @@ #include <sys/module.h> #include "common.h" -#define LDLINUX "ldlinux.c32" - extern char __dynstr_start[]; extern char __dynstr_end[], __dynsym_end[]; extern char __dynsym_start[]; @@ -66,7 +64,7 @@ again: if (rv == EEXIST) { /* * If a COM32 module calls execute() we may need to - * unload all the modules loaded since ldlinux.c32, + * unload all the modules loaded since ldlinux.*, * and restart initialisation. This is especially * important for config files. * @@ -159,7 +157,7 @@ void load_env32(com32sys_t * regs __unused) /* * search_dirs() sets the current working directory if * it successfully opens the file. Add the directory - * in which we found ldlinux.c32 to PATH. + * in which we found ldlinux.* to PATH. */ if (!core_getcwd(path, sizeof(path))) goto out; @@ -188,7 +186,8 @@ void load_env32(com32sys_t * regs __unused) out: free(PATH); - writestr("\nFailed to load ldlinux.c32"); + writestr("\nFailed to load "); + writestr(LDLINUX); } static const char *__cmdline; @@ -40,7 +40,7 @@ CFLAGS = -I$(EFIINC) -I$(EFIINC)/$(EFI_SUBARCH) \ -I$(core)/include -I$(core)/ $(CARCHOPT) \ -I$(com32)/lib/ -I$(com32)/libutil/include -std=gnu99 \ -DELF_DEBUG -DSYSLINUX_EFI -I$(objdir) \ - $(GCCWARN) -D__COM32__ -mno-red-zone + $(GCCWARN) -D__COM32__ -mno-red-zone -DLDLINUX=\"$(LDLINUX)\" # gnuefi sometimes installs these under a gnuefi/ directory, and sometimes not CRT0 := $(shell find $(LIBDIR) -name crt0-efi-$(EFI_SUBARCH).o 2>/dev/null | tail -n1) @@ -59,7 +59,7 @@ CFLAGS = $(GCCOPT) -W -Wall \ -nostdinc -iwithprefix include \ -I$(com32)/libutil/include -I$(com32)/include \ -I$(com32)/include/sys $(GPLINCLUDE) -I$(core)/include \ - -I$(objdir) + -I$(objdir) -DLDLINUX=\"$(LDLINUX)\" SFLAGS = $(GCCOPT) -D__COM32__ LDFLAGS = -m elf_$(ARCH) -shared --hash-style=gnu -T $(com32)/lib/$(ARCH)/elf.ld --as-needed LIBGCC := $(shell $(CC) $(GCCOPT) --print-libgcc) |