aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile8
-rw-r--r--com32/elflink/ldlinux/Makefile12
-rw-r--r--com32/elflink/ldlinux/execute.c6
-rw-r--r--core/Makefile2
-rw-r--r--core/elflink/load_env32.c9
-rw-r--r--mk/efi.mk2
-rw-r--r--mk/elf.mk2
7 files changed, 25 insertions, 16 deletions
diff --git a/Makefile b/Makefile
index e039e347..115ed8f1 100644
--- a/Makefile
+++ b/Makefile
@@ -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;
diff --git a/mk/efi.mk b/mk/efi.mk
index 24cca8c1..3c134450 100644
--- a/mk/efi.mk
+++ b/mk/efi.mk
@@ -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)
diff --git a/mk/elf.mk b/mk/elf.mk
index bd8775cf..faca4e1a 100644
--- a/mk/elf.mk
+++ b/mk/elf.mk
@@ -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)