aboutsummaryrefslogtreecommitdiffstats
path: root/com32
diff options
context:
space:
mode:
authorMatt Fleming <matt.fleming@intel.com>2013-01-08 16:09:03 +0000
committerMatt Fleming <matt.fleming@intel.com>2013-01-08 16:29:05 +0000
commitaf75baf78acda2f8d1b463cb3c155ab67200e128 (patch)
tree38cfd25a692e2a8a6586881b2ff16bc09bf003de /com32
parent7eda4ce3c7ad2b3ea4ab104e007b3be30b33e4cf (diff)
parent90b5864fc7935362b797ea33307aaa7c37a52753 (diff)
downloadsyslinux-af75baf78acda2f8d1b463cb3c155ab67200e128.tar.gz
syslinux-af75baf78acda2f8d1b463cb3c155ab67200e128.tar.xz
syslinux-af75baf78acda2f8d1b463cb3c155ab67200e128.zip
Merge branch 'elflink' into firmware
Merge the changes since Syslinux-5.00. The main reason behind this merge is to pull in the following bug fix, commit 90b5864fc793 ("core/kaboom.c: Export __bad_SEG()"), which allows us to turn on debugging in mk/devel.mk without ldlinux.c32 failing to load. Conflicts: com32/elflink/ldlinux/Makefile version
Diffstat (limited to 'com32')
-rw-r--r--com32/elflink/ldlinux/Makefile12
-rw-r--r--com32/elflink/ldlinux/kernel.c64
-rw-r--r--com32/gpllib/Makefile2
-rw-r--r--com32/lib/Makefile2
-rw-r--r--com32/libutil/Makefile2
5 files changed, 55 insertions, 27 deletions
diff --git a/com32/elflink/ldlinux/Makefile b/com32/elflink/ldlinux/Makefile
index aa35f475..659aa405 100644
--- a/com32/elflink/ldlinux/Makefile
+++ b/com32/elflink/ldlinux/Makefile
@@ -20,10 +20,12 @@ 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 \
eprintf.o loadhigh.o msg.o
-all: ldlinux.c32 ldlinux_lnx.a
+BTARGET = ldlinux.c32
+
+all: $(BTARGET) ldlinux_lnx.a
ldlinux.c32 : $(OBJS)
- $(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
+ $(LD) $(LDFLAGS) -soname $(@F) -o $@ $^ $(LIBS)
LNXCFLAGS += -D__export='__attribute__((visibility("default")))'
LNXLIBOBJS = get_key.lo
@@ -36,14 +38,14 @@ tidy dist:
rm -f *.o *.lo *.a *.lst .*.d
clean: tidy
- rm -f *.lss *.lnx *.com *.c32
+ rm -f *.lss *.lnx *.com
spotless: clean
- rm -f *~ \#*
+ rm -f *~ \#* $(BTARGET)
install: all
mkdir -m 755 -p $(INSTALLROOT)$(AUXDIR)
- install -m 644 ldlinux.c32 $(INSTALLROOT)$(AUXDIR)
+ install -m 644 $(BTARGET) $(INSTALLROOT)$(AUXDIR)
-include .*.d
diff --git a/com32/elflink/ldlinux/kernel.c b/com32/elflink/ldlinux/kernel.c
index 1cfb6508..920246fc 100644
--- a/com32/elflink/ldlinux/kernel.c
+++ b/com32/elflink/ldlinux/kernel.c
@@ -15,35 +15,45 @@ const char *append = NULL;
/* Will be called from readconfig.c */
int new_linux_kernel(char *okernel, char *ocmdline)
{
- const char *kernel_name = NULL;
+ const char *kernel_name = NULL, *args = NULL;
struct initramfs *initramfs = NULL;
char *temp;
void *kernel_data;
- size_t kernel_len;
+ size_t kernel_len, cmdline_len;
bool opt_quiet = false;
- char initrd_name[256];
- char cmdline_buf[256], *cmdline;
+ char *initrd_name, *cmdline;
dprintf("okernel = %s, ocmdline = %s", okernel, ocmdline);
- cmdline = cmdline_buf;
-
- temp = cmdline;
-
if (okernel)
kernel_name = okernel;
else if (globaldefault)
kernel_name = globaldefault;
- strcpy(temp, kernel_name);
- temp += strlen(kernel_name);
-
- *temp = ' ';
- temp++;
if (ocmdline)
- strcpy(temp, ocmdline);
+ args = ocmdline;
else if (append)
- strcpy(temp, append);
+ args = append;
+
+ cmdline_len = strlen(kernel_name);
+ if (args) {
+ /* +1 for the space (' ') between kernel and args */
+ cmdline_len += strlen(args) + 1;
+ }
+
+ /* +1 for NUL termination */
+ cmdline_len++;
+
+ cmdline = malloc(cmdline_len);
+ if (!cmdline) {
+ printf("Failed to alloc memory for cmdline\n");
+ return 1;
+ }
+
+ if (args)
+ snprintf(cmdline, cmdline_len, "%s %s", kernel_name, args);
+ else
+ snprintf(cmdline, cmdline_len, "%s", kernel_name);
/* "keeppxe" handling */
#if IS_PXELINUX
@@ -79,13 +89,25 @@ int new_linux_kernel(char *okernel, char *ocmdline)
temp += 6; /* strlen("initrd") */
do {
- char *p = initrd_name;
+ size_t n = 0;
+ char *p;
temp++; /* Skip = or , */
- while (*temp != ' ' && *temp != ',' && *temp)
- *p++ = *temp++;
- *p = '\0';
+ p = temp;
+ while (*p != ' ' && *p != ',' && *p) {
+ p++;
+ n++;
+ }
+
+ initrd_name = malloc(n + 1);
+ if (!initrd_name) {
+ printf("Failed to allocate space for initrd\n");
+ goto bail;
+ }
+
+ snprintf(initrd_name, n + 1, "%s", temp);
+ temp += n;
if (!opt_quiet)
printf("Loading %s...", initrd_name);
@@ -93,10 +115,13 @@ int new_linux_kernel(char *okernel, char *ocmdline)
if (initramfs_load_archive(initramfs, initrd_name)) {
if (opt_quiet)
printf("Loading %s ", initrd_name);
+ free(initrd_name);
printf("failed: ");
goto bail;
}
+ free(initrd_name);
+
if (!opt_quiet)
printf("ok\n");
} while (*temp == ',');
@@ -107,6 +132,7 @@ int new_linux_kernel(char *okernel, char *ocmdline)
printf("Booting kernel failed: ");
bail:
+ free(cmdline);
printf("%s\n", strerror(errno));
return 1;
}
diff --git a/com32/gpllib/Makefile b/com32/gpllib/Makefile
index 71f335da..4d0bb82f 100644
--- a/com32/gpllib/Makefile
+++ b/com32/gpllib/Makefile
@@ -24,7 +24,7 @@ makeoutputdirs:
$(addprefix $(OBJ),$(sort $(dir $(LIBOBJS)))),$(b))
libcom32gpl.c32 : $(LIBOBJS)
- $(LD) -shared $(LDFLAGS) -o $@ $^
+ $(LD) -shared $(LDFLAGS) -soname $(@F) -o $@ $^
tidy dist clean:
find . \( -name \*.o -o -name .\*.d -o -name \*.tmp \) -print0 | \
diff --git a/com32/lib/Makefile b/com32/lib/Makefile
index f83e8179..2a47fc6f 100644
--- a/com32/lib/Makefile
+++ b/com32/lib/Makefile
@@ -91,7 +91,7 @@ makeoutputdirs:
libcom32.c32 : $(LIBOBJS)
rm -f $@
- $(LD) -shared $(LDFLAGS) -o $@ $^
+ $(LD) -shared $(LDFLAGS) -soname $(@F) -o $@ $^
libcom32min.a : $(MINLIBOBJS)
rm -f $@
diff --git a/com32/libutil/Makefile b/com32/libutil/Makefile
index 535b4aba..5e941658 100644
--- a/com32/libutil/Makefile
+++ b/com32/libutil/Makefile
@@ -41,7 +41,7 @@ LNXLIBOBJS = $(patsubst %.o,%.lo,$(LIBOBJS))
all: libutil_com.c32 libutil_lnx.a
libutil_com.c32: $(LIBOBJS)
- $(LD) $(LDFLAGS) -o $@ $^
+ $(LD) $(LDFLAGS) -soname $(@F) -o $@ $^
libutil_lnx.a: $(LNXLIBOBJS)
rm -f $@