aboutsummaryrefslogtreecommitdiffstats
path: root/com32
diff options
context:
space:
mode:
Diffstat (limited to 'com32')
-rw-r--r--com32/chain/Makefile2
-rw-r--r--com32/cmenu/Makefile13
-rw-r--r--com32/cmenu/menugen.py56
-rw-r--r--com32/elflink/ldlinux/Makefile8
-rw-r--r--com32/elflink/ldlinux/cli.c38
-rw-r--r--com32/elflink/ldlinux/config.h2
-rw-r--r--com32/elflink/ldlinux/eprintf.c36
-rw-r--r--com32/elflink/ldlinux/execute.c8
-rw-r--r--com32/elflink/ldlinux/ldlinux.c3
-rw-r--r--com32/elflink/ldlinux/msg.c86
-rw-r--r--com32/elflink/ldlinux/readconfig.c45
-rw-r--r--com32/gfxboot/Makefile2
-rw-r--r--com32/gpllib/Makefile8
-rw-r--r--com32/hdt/Makefile2
-rw-r--r--com32/hdt/hdt.c2
-rw-r--r--com32/include/sys/exec.h21
-rw-r--r--com32/include/sys/module.h23
-rw-r--r--com32/include/syslinux/config.h2
-rw-r--r--com32/lib/Makefile6
-rw-r--r--com32/lib/sys/module/common.c5
-rw-r--r--com32/lib/sys/module/elf_module.c2
-rw-r--r--com32/lib/sys/module/exec.c49
-rw-r--r--com32/lib/sys/module/i386/elf_module.c8
-rw-r--r--com32/lib/sys/module/i386/shallow_module.c161
-rw-r--r--com32/lib/sys/module/shallow_module.c161
-rw-r--r--com32/lib/sys/module/x86_64/elf_module.c8
-rw-r--r--com32/lib/sys/module/x86_64/shallow_module.c161
-rw-r--r--com32/lib/syslinux/serial.c2
-rw-r--r--com32/libutil/Makefile6
-rw-r--r--com32/lua/src/Makefile7
-rw-r--r--com32/mboot/Makefile2
-rw-r--r--com32/menu/Makefile4
-rw-r--r--com32/modules/Makefile2
-rw-r--r--com32/rosh/Makefile2
-rw-r--r--com32/samples/Makefile2
-rw-r--r--com32/sysdump/Makefile2
36 files changed, 202 insertions, 745 deletions
diff --git a/com32/chain/Makefile b/com32/chain/Makefile
index 32385509..1a7ac9e6 100644
--- a/com32/chain/Makefile
+++ b/com32/chain/Makefile
@@ -18,7 +18,7 @@ OBJS = chain.o partiter.o utility.o options.o mangle.o
all: chain.c32
-chain.c32: $(OBJS) $(C_LIBS)
+chain.elf: $(OBJS) $(C_LIBS)
$(LD) $(LDFLAGS) -o $@ $^
%.o: %.c
diff --git a/com32/cmenu/Makefile b/com32/cmenu/Makefile
index 7ff1ff6e..f4321366 100644
--- a/com32/cmenu/Makefile
+++ b/com32/cmenu/Makefile
@@ -18,7 +18,7 @@
NOGPL := 1
LIBS = libmenu/libmenu.c32 \
- $(objdir)/com32/libutil/libutil_com.c32 \
+ $(objdir)/com32/libutil/libutil.c32 \
$(objdir)/com32/lib/libcom32.c32
VPATH = $(SRC)
@@ -26,7 +26,7 @@ include $(MAKEDIR)/elf.mk
CFLAGS += -I$(SRC)/libmenu
-LIBMENU = $(objdir)/com32/libutil/libutil_com.c32 \
+LIBMENU = $(objdir)/com32/libutil/libutil.c32 \
$(objdir)/com32/lib/libcom32.c32 \
libmenu/syslnx.o libmenu/com32io.o libmenu/tui.o \
libmenu/menu.o libmenu/passwords.o libmenu/des.o libmenu/help.o
@@ -47,14 +47,15 @@ all: makeoutputdirs menus
makeoutputdirs:
@mkdir -p $(OBJ)/libmenu
-libmenu/libmenu.c32: $(LIBMENU)
- $(LD) -shared $(LDFLAGS) -o $@ $^
+libmenu/libmenu.elf: $(LIBMENU)
+ $(LD) -shared $(LDFLAGS) -soname $(patsubst %.elf,%.c32,$(@F)) \
+ -o $@ $^
tidy dist:
- rm -f *.o *.lo *.c32 *.lst *.elf .*.d */.*.d
+ rm -f *.o *.lo *.lst *.elf */*.o */*.elf .*.d */.*.d
libclean:
- rm -f libmenu/*.o libmenu/*.c32
+ rm -f libmenu/*.c32
clean: tidy menuclean libclean
rm -f *.lss *.c32 *.com
diff --git a/com32/cmenu/menugen.py b/com32/cmenu/menugen.py
index 70ec1f87..da64d937 100644
--- a/com32/cmenu/menugen.py
+++ b/com32/cmenu/menugen.py
@@ -72,9 +72,9 @@ class Menusystem:
self.init_entry()
self.init_menu()
self.init_system()
- self.vtypes = " OR ".join(self.types.keys())
- self.vattrs = " OR ".join(filter(lambda x: x[0] != "_", self.entry.keys()))
- self.mattrs = " OR ".join(filter(lambda x: x[0] != "_", self.menu.keys()))
+ self.vtypes = " OR ".join(list(self.types.keys()))
+ self.vattrs = " OR ".join([x for x in list(self.entry.keys()) if x[0] != "_"])
+ self.mattrs = " OR ".join([x for x in list(self.menu.keys()) if x[0] != "_"])
def init_entry(self):
self.entry = self.entry_init.copy()
@@ -100,27 +100,27 @@ class Menusystem:
if not self.entry["info"]:
self.entry["info"] = self.entry["data"]
if not self.menus:
- print "Error before line %d" % self.lineno
- print "REASON: menu must be declared before a menu item is declared"
+ print("Error before line %d" % self.lineno)
+ print("REASON: menu must be declared before a menu item is declared")
sys.exit(1)
self.menus[-1][1].append(self.entry)
self.init_entry()
def set_item(self,name,value):
- if not self.entry.has_key(name):
+ if name not in self.entry:
msg = ["Unknown attribute %s in line %d" % (name,self.lineno)]
msg.append("REASON: Attribute must be one of %s" % self.vattrs)
return "\n".join(msg)
- if name=="type" and not self.types.has_key(value):
+ if name=="type" and value not in self.types:
msg = [ "Unrecognized type %s in line %d" % (value,self.lineno)]
msg.append("REASON: Valid types are %s" % self.vtypes)
return "\n".join(msg)
if name=="shortcut":
- if (value <> "-1") and not re.match("^[A-Za-z0-9]$",value):
+ if (value != "-1") and not re.match("^[A-Za-z0-9]$",value):
msg = [ "Invalid shortcut char '%s' in line %d" % (value,self.lineno) ]
msg.append("REASON: Valid values are [A-Za-z0-9]")
return "\n".join(msg)
- elif value <> "-1": value = "'%s'" % value
+ elif value != "-1": value = "'%s'" % value
elif name in ["state","helpid","ipappend"]:
try:
value = int(value)
@@ -131,14 +131,14 @@ class Menusystem:
return ""
def set_menu(self,name,value):
- if not self.menu.has_key(name):
+ if name not in self.menu:
return "Error: Unknown keyword %s" % name
self.menu[name] = value
self.menu["_updated"] = 1
return ""
def set_system(self,name,value):
- if not self.system.has_key(name):
+ if name not in self.system:
return "Error: Unknown keyword %s" % name
if name == "skipcondn":
try: # is skipcondn a number?
@@ -146,7 +146,7 @@ class Menusystem:
except: # it is a "-" delimited sequence
value = value.lower()
parts = [ self.shift_flags.get(x.strip(),None) for x in value.split("-") ]
- self.system["skipcondn"] = " | ".join(filter(None, parts))
+ self.system["skipcondn"] = " | ".join([_f for _f in parts if _f])
else:
self.system[name] = value
@@ -169,7 +169,7 @@ class Menusystem:
if not err: return
# all errors so return item's error message
- print err
+ print(err)
sys.exit(1)
def print_entry(self,entry,fd):
@@ -211,9 +211,9 @@ class Menusystem:
missing = None
for x in self.reqd_templates:
- if not self.templates.has_key(x): missing = x
+ if x not in self.templates: missing = x
if missing:
- print "Template %s required but not defined in %s" % (missing,self.code_template_filename)
+ print("Template %s required but not defined in %s" % (missing,self.code_template_filename))
if filename == "-":
fd = sys.stdout
@@ -227,8 +227,8 @@ class Menusystem:
fd.write(self.templates["footer"])
fd.close()
if not self.foundmain:
- print "main menu not found"
- print self.menus
+ print("main menu not found")
+ print(self.menus)
sys.exit(1)
def input(self,filename):
@@ -259,26 +259,26 @@ class Menusystem:
# add property of current entry
pos = line.find("=") # find the first = in string
if pos < 0:
- print "Syntax error in line %d" % self.lineno
- print "REASON: non-section lines must be of the form ATTRIBUTE=VALUE"
+ print("Syntax error in line %d" % self.lineno)
+ print("REASON: non-section lines must be of the form ATTRIBUTE=VALUE")
sys.exit(1)
attr = line[:pos].strip().lower()
value = line[pos+1:].strip()
self.set(attr,value)
except:
- print "Error while parsing line %d: %s" % (self.lineno,line)
+ print("Error while parsing line %d: %s" % (self.lineno,line))
raise
fd.close()
self.add_item()
def usage():
- print sys.argv[0]," [options]"
- print "--input=<file> is the name of the .menu file declaring the menu structure"
- print "--output=<file> is the name of generated C source"
- print "--template=<file> is the name of template to be used"
- print
- print "input and output default to - (stdin and stdout respectively)"
- print "template defaults to adv_menu.tpl"
+ print(sys.argv[0]," [options]")
+ print("--input=<file> is the name of the .menu file declaring the menu structure")
+ print("--output=<file> is the name of generated C source")
+ print("--template=<file> is the name of template to be used")
+ print()
+ print("input and output default to - (stdin and stdout respectively)")
+ print("template defaults to adv_menu.tpl")
sys.exit(1)
def main():
@@ -287,7 +287,7 @@ def main():
ofile = "-"
opts,args = getopt.getopt(sys.argv[1:], "hi:o:t:",["input=","output=","template=","help"])
if args:
- print "Unknown options %s" % args
+ print("Unknown options %s" % args)
usage()
for o,a in opts:
if o in ["-i","--input"]:
diff --git a/com32/elflink/ldlinux/Makefile b/com32/elflink/ldlinux/Makefile
index 659aa405..bfec4503 100644
--- a/com32/elflink/ldlinux/Makefile
+++ b/com32/elflink/ldlinux/Makefile
@@ -1,6 +1,6 @@
## -----------------------------------------------------------------------
##
-## Copyright 2011 Intel Corporation - All Rights Reserved
+## Copyright 2011-2013 Intel Corporation - All Rights Reserved
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
@@ -18,14 +18,14 @@ LIBS = --whole-archive $(objdir)/com32/lib/libcom32min.a
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
+ loadhigh.o msg.o
BTARGET = ldlinux.c32
all: $(BTARGET) ldlinux_lnx.a
-ldlinux.c32 : $(OBJS)
- $(LD) $(LDFLAGS) -soname $(@F) -o $@ $^ $(LIBS)
+ldlinux.elf : $(OBJS)
+ $(LD) $(LDFLAGS) -soname $(patsubst %.elf,%.c32,$(@F)) -o $@ $^ $(LIBS)
LNXCFLAGS += -D__export='__attribute__((visibility("default")))'
LNXLIBOBJS = get_key.lo
diff --git a/com32/elflink/ldlinux/cli.c b/com32/elflink/ldlinux/cli.c
index b94c6835..b85357b2 100644
--- a/com32/elflink/ldlinux/cli.c
+++ b/com32/elflink/ldlinux/cli.c
@@ -71,7 +71,7 @@ static const char * cmd_reverse_search(int *cursor, clock_t *kbd_to,
memset(buf, 0, MAX_CMDLINE_LEN);
- eprintf("\033[1G\033[1;36m(reverse-i-search)`': \033[0m");
+ printf("\033[1G\033[1;36m(reverse-i-search)`': \033[0m");
while (1) {
key = mygetkey_timeout(kbd_to, tto);
@@ -105,11 +105,11 @@ static const char * cmd_reverse_search(int *cursor, clock_t *kbd_to,
*cursor = p - last_good->command;
}
- eprintf("\033[?7l\033[?25l");
+ printf("\033[?7l\033[?25l");
/* Didn't handle the line wrap case here */
- eprintf("\033[1G\033[1;36m(reverse-i-search)\033[0m`%s': %s",
+ printf("\033[1G\033[1;36m(reverse-i-search)\033[0m`%s': %s",
buf, last_good->command ? : "");
- eprintf("\033[K\r");
+ printf("\033[K\r");
}
return last_good ? last_good->command : NULL;
@@ -147,7 +147,7 @@ const char *edit_cmdline(const char *input, int top /*, int width */ ,
* so that it follows whatever text has been written to the screen
* previously.
*/
- eprintf("%s ", input);
+ printf("%s ", input);
while (!done) {
if (redraw > 1) {
@@ -158,7 +158,7 @@ const char *edit_cmdline(const char *input, int top /*, int width */ ,
if (pDraw_Menu)
(*pDraw_Menu) (-1, top, 1);
prev_len = 0;
- eprintf("\033[2J\033[H");
+ printf("\033[2J\033[H");
// printf("\033[0m\033[2J\033[H");
}
@@ -168,8 +168,8 @@ const char *edit_cmdline(const char *input, int top /*, int width */ ,
prev_len = max(len, prev_len);
/* Redraw the command line */
- eprintf("\033[?7l\033[?25l");
- eprintf("\033[1G%s ", input);
+ printf("\033[?7l\033[?25l");
+ printf("\033[1G%s ", input);
x = strlen(input);
y = 0;
@@ -179,23 +179,23 @@ const char *edit_cmdline(const char *input, int top /*, int width */ ,
at++;
x++;
if (x >= width) {
- eprintf("\r\n");
+ printf("\r\n");
x = 0;
y++;
}
}
- eprintf("\033[K\r");
+ printf("\033[K\r");
dy = y - (cursor + strlen(input) + 1) / width;
x = (cursor + strlen(input) + 1) % width;
if (dy) {
- eprintf("\033[%dA", dy);
+ printf("\033[%dA", dy);
y -= dy;
}
if (x)
- eprintf("\033[%dC", x);
- eprintf("\033[?25h");
+ printf("\033[%dC", x);
+ printf("\033[?25h");
prev_len = len;
redraw = 0;
}
@@ -288,7 +288,7 @@ const char *edit_cmdline(const char *input, int top /*, int width */ ,
cursor++;
x++;
if (x >= width) {
- eprintf("\r\n");
+ printf("\r\n");
y++;
x = 0;
}
@@ -418,10 +418,10 @@ const char *edit_cmdline(const char *input, int top /*, int width */ ,
}
case KEY_CTRL('V'):
if (BIOSName)
- eprintf("%s%s%s", syslinux_banner,
- MK_PTR(0, BIOSName), copyright_str);
+ printf("%s%s%s", syslinux_banner,
+ (char *)MK_PTR(0, BIOSName), copyright_str);
else
- eprintf("%s%s", syslinux_banner, copyright_str);
+ printf("%s%s", syslinux_banner, copyright_str);
redraw = 1;
break;
@@ -435,7 +435,7 @@ const char *edit_cmdline(const char *input, int top /*, int width */ ,
cursor++;
x++;
if (x >= width) {
- eprintf("\r\n\033[K");
+ printf("\r\n\033[K");
y++;
x = 0;
}
@@ -452,7 +452,7 @@ const char *edit_cmdline(const char *input, int top /*, int width */ ,
}
}
- eprintf("\033[?7h");
+ printf("\033[?7h");
/* Add the command to the history */
comm_counter = malloc(sizeof(struct cli_command));
diff --git a/com32/elflink/ldlinux/config.h b/com32/elflink/ldlinux/config.h
index c551fb19..242b7dc5 100644
--- a/com32/elflink/ldlinux/config.h
+++ b/com32/elflink/ldlinux/config.h
@@ -41,8 +41,6 @@ extern void cat_help_file(int key);
extern struct menu_entry *find_label(const char *str);
extern void print_labels(const char *prefix, size_t len);
-extern void eprintf(const char *filename, ...);
-
extern int new_linux_kernel(char *okernel, char *ocmdline);
extern void pm_load_high(com32sys_t *regs);
diff --git a/com32/elflink/ldlinux/eprintf.c b/com32/elflink/ldlinux/eprintf.c
deleted file mode 100644
index f15edc6e..00000000
--- a/com32/elflink/ldlinux/eprintf.c
+++ /dev/null
@@ -1,36 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include <stdarg.h>
-#include <core.h>
-
-#define BUFFER_SIZE 4096
-
-static void veprintf(const char *format, va_list ap)
-{
- int rv, _rv;
- char buffer[BUFFER_SIZE];
- char *p;
-
- _rv = rv = vsnprintf(buffer, BUFFER_SIZE, format, ap);
-
- if (rv < 0)
- return;
-
- if (rv > BUFFER_SIZE - 1)
- rv = BUFFER_SIZE - 1;
-
- p = buffer;
- while (rv--)
- write_serial(*p++);
-
- _fwrite(buffer, _rv, stdout);
-}
-
-void eprintf(const char *format, ...)
-{
- va_list ap;
-
- va_start(ap, format);
- veprintf(format, ap);
- va_end(ap);
-}
diff --git a/com32/elflink/ldlinux/execute.c b/com32/elflink/ldlinux/execute.c
index 727df50a..5c53b995 100644
--- a/com32/elflink/ldlinux/execute.c
+++ b/com32/elflink/ldlinux/execute.c
@@ -55,11 +55,9 @@ __export void execute(const char *cmdline, uint32_t type)
memset(&ireg, 0, sizeof ireg);
- /* for parameter will be passed to __intcall, we need use
- * lmalloc a block of low memory */
- q = lmalloc(128);
+ q = malloc(strlen(cmdline) + 2);
if (!q) {
- printf("%s(): Fail to lmalloc a buffer to exec %s\n",
+ printf("%s(): Fail to malloc a buffer to exec %s\n",
__func__, cmdline);
return;
}
@@ -147,7 +145,7 @@ __export void execute(const char *cmdline, uint32_t type)
new_linux_kernel((char *)kernel, (char *)cmdline);
}
- lfree((void *)kernel);
+ free((void *)kernel);
/* If this returns, something went bad; return to menu */
}
diff --git a/com32/elflink/ldlinux/ldlinux.c b/com32/elflink/ldlinux/ldlinux.c
index 6f9f20fa..a8b1b386 100644
--- a/com32/elflink/ldlinux/ldlinux.c
+++ b/com32/elflink/ldlinux/ldlinux.c
@@ -12,6 +12,7 @@
#include "config.h"
#include "syslinux/adv.h"
#include "syslinux/boot.h"
+#include "syslinux/config.h"
#include <sys/module.h>
@@ -290,6 +291,8 @@ __export int main(int argc __unused, char **argv __unused)
parse_configs(config_argv);
+ __syslinux_set_serial_console_info();
+
adv = syslinux_getadv(ADV_BOOTONCE, &count);
if (adv && count) {
/*
diff --git a/com32/elflink/ldlinux/msg.c b/com32/elflink/ldlinux/msg.c
index 2efcc792..9ded33ef 100644
--- a/com32/elflink/ldlinux/msg.c
+++ b/com32/elflink/ldlinux/msg.c
@@ -4,7 +4,7 @@
#include <graphics.h>
static uint8_t TextAttribute; /* Text attribute for message file */
-static uint8_t DisplayMask; /* Display modes mask */
+extern uint8_t DisplayMask; /* Display modes mask */
/* Routine to interpret next print char */
static void (*NextCharJump)(uint8_t);
@@ -42,27 +42,27 @@ int get_msg_file(char *filename)
if (ch == 0x1A)
break;
- /*
- * 01h = text mode
- * 02h = graphics mode
- */
- UsingVGA &= 0x1;
- UsingVGA += 1;
-
NextCharJump(ch); /* Do what shall be done */
}
+ DisplayMask = 0x07;
+
fclose(f);
return 0;
}
+static inline int display_mask_vga(void)
+{
+ uint8_t mask = UsingVGA & 0x1;
+ return (DisplayMask & ++mask);
+}
+
static void msg_setbg(uint8_t data)
{
if (unhexchar(&data) == 0) {
data <<= 4;
- if (DisplayMask & UsingVGA) {
+ if (display_mask_vga())
TextAttribute = data;
- }
NextCharJump = msg_setfg;
} else {
@@ -74,7 +74,7 @@ static void msg_setbg(uint8_t data)
static void msg_setfg(uint8_t data)
{
if (unhexchar(&data) == 0) {
- if (DisplayMask & UsingVGA) {
+ if (display_mask_vga()) {
/* setbg set foreground to 0 */
TextAttribute |= data;
}
@@ -89,6 +89,34 @@ static inline void msg_ctrl_o(void)
NextCharJump = msg_setbg;
}
+/* Convert ANSI colors to PC display attributes */
+static int convert_to_pcdisplay[] = { 0, 4, 2, 6, 1, 5, 3, 7 };
+
+static void set_fgbg(void)
+{
+ uint8_t bg, fg;
+
+ fg = convert_to_pcdisplay[(TextAttribute & 0x7)];
+ bg = convert_to_pcdisplay[((TextAttribute >> 4) & 0x7)];
+
+ printf("\033[");
+ if (TextAttribute & 0x8)
+ printf("1;"); /* Foreground bright */
+
+ printf("3%dm\033[", fg);
+
+ if (TextAttribute & 0x80)
+ printf("5;"); /* Foreground blink */
+
+ printf("4%dm", bg);
+}
+
+static void msg_formfeed(void)
+{
+ set_fgbg();
+ printf("\033[2J\033[H\033[0m");
+}
+
static void msg_novga(void)
{
syslinux_force_text_mode();
@@ -138,36 +166,19 @@ static void msg_vga(void)
VGAFilePtr = (uint16_t *)VGAFileBuf;
}
-/* Convert ANSI colors to PC display attributes */
-static int convert_to_pcdisplay[] = { 0, 4, 2, 6, 1, 5, 3, 7 };
-
static void msg_normal(uint8_t data)
{
- uint8_t bg, fg;
-
- /* Write to serial port */
- if (DisplayMask & 0x4)
- write_serial(data);
+ /* 0x1 = text mode, 0x2 = graphics mode */
+ if (!display_mask_vga() || !(DisplayCon & 0x01)) {
+ /* Write to serial port */
+ if (DisplayMask & 0x4)
+ write_serial(data);
- if (!(DisplayMask & UsingVGA))
return; /* Not screen */
+ }
- if (!(DisplayCon & 0x01))
- return;
-
- fg = convert_to_pcdisplay[(TextAttribute & 0x7)];
- bg = convert_to_pcdisplay[((TextAttribute >> 4) & 0x7)];
-
- printf("\033[");
- if (TextAttribute & 0x40)
- printf("1;"); /* Foreground bright */
-
- printf("3%dm\033[", fg);
-
- if (TextAttribute & 0x80)
- printf("5;"); /* Foreground blink */
-
- printf("4%dm%c\033[0m", bg, data);
+ set_fgbg();
+ printf("%c\033[0m", data);
}
static void msg_modectl(uint8_t data)
@@ -191,6 +202,9 @@ static void msg_putchar(uint8_t ch)
break;
case 0x0D: /* Ignore <CR> */
break;
+ case 0x0C: /* <FF> = clear screen */
+ msg_formfeed();
+ break;
case 0x19: /* <EM> = return to text mode */
msg_novga();
break;
diff --git a/com32/elflink/ldlinux/readconfig.c b/com32/elflink/ldlinux/readconfig.c
index 6a419c6d..a2421e95 100644
--- a/com32/elflink/ldlinux/readconfig.c
+++ b/com32/elflink/ldlinux/readconfig.c
@@ -26,6 +26,7 @@
#include <syslinux/config.h>
#include <dprintf.h>
#include <ctype.h>
+#include <bios.h>
#include <core.h>
#include <fs.h>
@@ -79,7 +80,6 @@ short allowoptions = 1; //user-specified options allowed
short includelevel = 1; //nesting level
short defaultlevel = 0; //the current level of default
short vkernel = 0; //have we seen any "label" statements?
-short displaycon = 1; //conio.inc
extern short NoHalt; //idle.c
const char *onerror = NULL; //"onerror" command line
@@ -442,12 +442,12 @@ void print_labels(const char *prefix, size_t len)
{
struct menu_entry *me;
- eprintf("\n");
+ printf("\n");
for (me = all_entries; me; me = me->next ) {
if (!strncmp(prefix, me->label, len))
- eprintf(" %s", me->label);
+ printf(" %s", me->label);
}
- eprintf("\n");
+ printf("\n");
}
struct menu_entry *find_label(const char *str)
@@ -498,18 +498,24 @@ static const char *unlabel(const char *str)
return str;
}
-static const char *refdup_word(char **p)
+static const char *__refdup_word(char *p, char **ref)
{
- char *sp = *p;
+ char *sp = p;
char *ep = sp;
while (*ep && !my_isspace(*ep))
ep++;
- *p = ep;
+ if (ref)
+ *ref = ep;
return refstrndup(sp, ep - sp);
}
+static const char *refdup_word(char **p)
+{
+ return __refdup_word(*p, p);
+}
+
int my_isxdigit(char c)
{
unsigned int uc = c;
@@ -690,7 +696,7 @@ void cat_help_file(int key)
return;
if (cm->fkeyhelp[fkey].textname) {
- eprintf("\n");
+ printf("\n");
get_msg_file((char *)cm->fkeyhelp[fkey].textname);
}
}
@@ -729,12 +735,6 @@ extern void sirq_cleanup_nowipe(void);
extern void sirq_install(void);
extern void write_serial_str(char *);
-static inline void io_delay(void)
-{
- outb(0, 0x80);
- outb(0, 0x80);
-}
-
extern void loadfont(char *);
extern void loadkeys(char *);
@@ -1065,8 +1065,8 @@ do_include:
p = skipspace(p + 5);
/* when first time see "label", it will not really record anything */
record(m, &ld, append);
- ld.label = refstrdup(p);
- ld.kernel = refstrdup(p);
+ ld.label = __refdup_word(p, NULL);
+ ld.kernel = __refdup_word(p, NULL);
/* feng: this is the default type for all */
ld.type = KT_KERNEL;
ld.passwd = NULL;
@@ -1174,7 +1174,7 @@ do_include:
} else if (looking_at(p, "prompt")) {
forceprompt = atoi(skipspace(p + 6));
} else if (looking_at(p, "console")) {
- displaycon = atoi(skipspace(p + 7));
+ DisplayCon = atoi(skipspace(p + 7));
} else if (looking_at(p, "allowoptions")) {
allowoptions = atoi(skipspace(p + 12));
} else if (looking_at(p, "noescape")) {
@@ -1311,8 +1311,9 @@ do_include:
write_serial_str(syslinux_banner);
write_serial_str(copyright_str);
}
+
} else if (looking_at(p, "say")) {
- eprintf("%s\n", p+4);
+ printf("%s\n", p+4);
} else if (looking_at(p, "path")) {
/* PATH-based lookup */
const char *new_path;
@@ -1331,7 +1332,7 @@ do_include:
free(PATH);
PATH = _p;
} else
- eprintf("Failed to realloc PATH\n");
+ printf("Failed to realloc PATH\n");
}
}
}
@@ -1350,15 +1351,15 @@ static int parse_one_config(const char *filename)
if (fd < 0)
return fd;
- f = fdopen(fd, mode);
- parse_config_file(f);
-
if (config_cwd[0]) {
if (chdir(config_cwd) < 0)
printf("Failed to chdir to %s\n", config_cwd);
config_cwd[0] = '\0';
}
+ f = fdopen(fd, mode);
+ parse_config_file(f);
+
return 0;
}
diff --git a/com32/gfxboot/Makefile b/com32/gfxboot/Makefile
index 98d6a032..824d7d0d 100644
--- a/com32/gfxboot/Makefile
+++ b/com32/gfxboot/Makefile
@@ -20,7 +20,7 @@ all: $(MODULES)
OBJS = gfxboot.o realmode_callback.o
-gfxboot.c32 : $(OBJS) $(LIBS) $(C_LIBS)
+gfxboot.elf : $(OBJS) $(LIBS) $(C_LIBS)
$(LD) $(LDFLAGS) -o $@ $^
realmode_callback.o: realmode_callback.asm
diff --git a/com32/gpllib/Makefile b/com32/gpllib/Makefile
index 4d0bb82f..e3e30d76 100644
--- a/com32/gpllib/Makefile
+++ b/com32/gpllib/Makefile
@@ -17,14 +17,14 @@ AUXDIR = $(DATADIR)/syslinux
INCDIR = /usr/include
COM32DIR = $(AUXDIR)/com32
-all: makeoutputdirs libcom32gpl.c32
+all: makeoutputdirs libgpl.c32
makeoutputdirs:
@mkdir -p $(foreach b, \
$(addprefix $(OBJ),$(sort $(dir $(LIBOBJS)))),$(b))
-libcom32gpl.c32 : $(LIBOBJS)
- $(LD) -shared $(LDFLAGS) -soname $(@F) -o $@ $^
+libgpl.elf : $(LIBOBJS)
+ $(LD) -shared $(LDFLAGS) -soname $(patsubst %.elf,%.c32,$(@F)) -o $@ $^
tidy dist clean:
find . \( -name \*.o -o -name .\*.d -o -name \*.tmp \) -print0 | \
@@ -38,7 +38,7 @@ spotless: clean
# there is a better way to do it.
install: all
mkdir -m 755 -p $(INSTALLROOT)$(COM32DIR)
- install -m 644 libcom32gpl.c32 $(INSTALLROOT)$(COM32DIR)
+ install -m 644 libgpl.c32 $(INSTALLROOT)$(COM32DIR)
mkdir -p $(INSTALLROOT)$(COM32DIR)/include/
cp -r $(SRC)/../gplinclude $(INSTALLROOT)$(COM32DIR)/include/
diff --git a/com32/hdt/Makefile b/com32/hdt/Makefile
index 362b4874..80f2d0a0 100644
--- a/com32/hdt/Makefile
+++ b/com32/hdt/Makefile
@@ -51,7 +51,7 @@ QEMU ?= qemu-kvm
all: $(MODULES) $(TESTFILES)
-hdt.c32 : $(OBJS) $(LIBS) $(C_LIBS)
+hdt.elf : $(OBJS) $(LIBS) $(C_LIBS)
$(LD) $(LDFLAGS) -o $@ $^
memtest:
diff --git a/com32/hdt/hdt.c b/com32/hdt/hdt.c
index 653995d0..67b3ab0c 100644
--- a/com32/hdt/hdt.c
+++ b/com32/hdt/hdt.c
@@ -48,7 +48,7 @@ int max_console_lines = MAX_CLI_LINES;
int main(const int argc, const char *argv[])
{
char version_string[256];
- struct s_hardware hardware;
+ static struct s_hardware hardware;
snprintf(version_string, sizeof version_string, "%s %s (%s)",
PRODUCT_NAME, VERSION, CODENAME);
diff --git a/com32/include/sys/exec.h b/com32/include/sys/exec.h
index ac05c276..f4559d15 100644
--- a/com32/include/sys/exec.h
+++ b/com32/include/sys/exec.h
@@ -34,27 +34,6 @@
extern int spawn_load(const char *name, int argc, char **argv);
/**
- * exec_init - Initialize the dynamic execution environment.
- *
- * Among others, it initializes the module subsystem and loads the root
- * module into memory. You should note the difference between the module
- * management API, and the execution API:
- * - the module system is a static one - it only manages the data structures
- * and their relationship. It does not describe the way modules are executed,
- * when and how they are loaded/unloaded, etc. It acts as a service layer for
- * the execution API.
- * - the execution environment is the dynamic part of the SYSLINUX dynamic
- * module API - it implements the behavior of the modules: it
- * triggers the execution of initialization and termination functions for
- * libraries, executes the modules marked as executable, handles dynamic
- * memory cleanup, etc. In other words, at this layer the code and data
- * loaded by the lower module layer gets to be executed by the CPU,
- * thus becoming part of the SYSLINUX environment.
- */
-extern int exec_init(void);
-
-
-/**
* spawnv - Executes a program in the current environment.
* @name: the name of the program to spawn, including the extension
* (e.g. 'hello.c32')
diff --git a/com32/include/sys/module.h b/com32/include/sys/module.h
index 02778fbf..c1d42531 100644
--- a/com32/include/sys/module.h
+++ b/com32/include/sys/module.h
@@ -199,6 +199,17 @@ extern struct list_head modules_head;
list_for_each_entry_safe(m, n, &modules_head, list)
/**
+ * module_current - return the module at the head of the module list.
+ */
+static inline struct elf_module *module_current(void)
+{
+ struct elf_module *head;
+
+ head = list_entry((&modules_head)->next, typeof(*head), list);
+ return head;
+}
+
+/**
* modules_init - initialize the module subsystem.
*
* This function must be called before any module operation is to be performed.
@@ -242,18 +253,6 @@ extern int module_load(struct elf_module *module);
/**
- * module_load_shallow - loads a shallow ELF module into memory.
- * @module: the module descriptor returned by module_alloc.
- *
- * The function reads the module file, checks whether the file has a valid
- * structure, then loads into memory the module metadata. The metadata currently
- * contains a symbol table that describes code & data allocated by other means.
- * Its current use is to describe the root COM32 module to the rest of the
- * module subsystem.
- */
-extern int module_load_shallow(struct elf_module *module, Elf_Addr base_addr);
-
-/**
* module_unload - unloads the module from the system.
* @module: the module descriptor structure.
*
diff --git a/com32/include/syslinux/config.h b/com32/include/syslinux/config.h
index 7bdcdd6b..8f4124ce 100644
--- a/com32/include/syslinux/config.h
+++ b/com32/include/syslinux/config.h
@@ -156,6 +156,8 @@ struct syslinux_serial_console_info {
uint16_t flowctl;
};
+extern void __syslinux_set_serial_console_info(void);
+
extern __nocommon struct syslinux_serial_console_info
__syslinux_serial_console_info;
static inline const struct syslinux_serial_console_info
diff --git a/com32/lib/Makefile b/com32/lib/Makefile
index 2a47fc6f..1624ae78 100644
--- a/com32/lib/Makefile
+++ b/com32/lib/Makefile
@@ -89,9 +89,9 @@ makeoutputdirs:
@mkdir -p $(foreach b, \
$(addprefix $(OBJ)/,$(sort $(dir $(LIBOBJS) $(MINLIBOBJS) $(CORELIBOBJS)))),$(b))
-libcom32.c32 : $(LIBOBJS)
+libcom32.elf : $(LIBOBJS)
rm -f $@
- $(LD) -shared $(LDFLAGS) -soname $(@F) -o $@ $^
+ $(LD) -shared $(LDFLAGS) -soname $(patsubst %.elf,%.c32,$(@F)) -o $@ $^
libcom32min.a : $(MINLIBOBJS)
rm -f $@
@@ -109,7 +109,7 @@ tidy dist clean:
xargs -0r rm -f
spotless: clean
- rm -f *.a
+ rm -f *.a *.c32
rm -f *~ \#* */*~ */\#*
install: all
diff --git a/com32/lib/sys/module/common.c b/com32/lib/sys/module/common.c
index 2ecc9e59..4c83789e 100644
--- a/com32/lib/sys/module/common.c
+++ b/com32/lib/sys/module/common.c
@@ -185,6 +185,11 @@ void modules_term(void) {
struct elf_module *module_alloc(const char *name) {
struct elf_module *result = malloc(sizeof(struct elf_module));
+ if (!result) {
+ dprintf("module: Failed to alloc elf_module\n");
+ return NULL;
+ }
+
memset(result, 0, sizeof(struct elf_module));
INIT_LIST_HEAD(&result->list);
diff --git a/com32/lib/sys/module/elf_module.c b/com32/lib/sys/module/elf_module.c
index 0d27c92b..e3d9928a 100644
--- a/com32/lib/sys/module/elf_module.c
+++ b/com32/lib/sys/module/elf_module.c
@@ -218,7 +218,7 @@ int module_load(struct elf_module *module) {
CHECKED(res, prepare_dynlinking(module), error);
//printf("check... 4\n");
- head = list_entry((&modules_head)->next, typeof(*head), list);
+ head = module_current();
/* Find modules we need to load as dependencies */
if (module->str_table) {
diff --git a/com32/lib/sys/module/exec.c b/com32/lib/sys/module/exec.c
index 559bafc7..18c8306d 100644
--- a/com32/lib/sys/module/exec.c
+++ b/com32/lib/sys/module/exec.c
@@ -18,32 +18,8 @@
#define DBG_PRINT(fmt, args...) dprintf("[EXEC] " fmt, ##args)
-static struct elf_module *mod_root = NULL;
struct elf_module *__syslinux_current = NULL;
-int exec_init(void)
-{
- int res;
-
- res = modules_init();
- if (res != 0)
- return res;
-
- // Load the root module
- mod_root = module_alloc(EXEC_ROOT_NAME);
-
- if (mod_root == NULL)
- return -1;
-
- res = module_load_shallow(mod_root, 0);
- if (res != 0) {
- mod_root = NULL;
- return res;
- }
-
- return 0;
-}
-
int get_module_type(struct elf_module *module)
{
if(module->main_func) return EXEC_MODULE;
@@ -161,8 +137,6 @@ int spawnl(const char *name, const char *arg, ...)
}
#endif
-struct elf_module *cur_module;
-
/*
* Load a module and runs its start function.
*
@@ -185,7 +159,7 @@ int spawn_load(const char *name, int argc, char **argv)
struct elf_module *previous;
//malloc_tag_t prev_mem_tag;
struct elf_module *module = module_alloc(name);
- struct elf_module *prev_module;
+ struct elf_module *cur_module;
int type;
dprintf("enter: name = %s", name);
@@ -200,23 +174,11 @@ int spawn_load(const char *name, int argc, char **argv)
}
}
+ cur_module = module_current();
if (!strcmp(cur_module->name, module->name)) {
dprintf("We is running this module %s already!", module->name);
- /*
- * If we're already running the module and it's of
- * type EXEC_MODULE, then just return. We don't reload
- * the module because that might cause us to re-run
- * the init functions, which will cause us to run the
- * main function, which will take control of this
- * process.
- *
- * This can happen if some other EXEC_MODULE is
- * resolving a symbol that is exported by the current
- * EXEC_MODULE.
- */
- if (get_module_type(module) == EXEC_MODULE)
- return 0;
+ module_unload(cur_module);
}
res = module_load(module);
@@ -224,11 +186,9 @@ int spawn_load(const char *name, int argc, char **argv)
goto out;
type = get_module_type(module);
- prev_module = cur_module;
- cur_module = module;
dprintf("type = %d, prev = %s, cur = %s",
- type, prev_module->name, cur_module->name);
+ type, cur_module->name, module->name);
if(type==EXEC_MODULE)
{
@@ -256,7 +216,6 @@ int spawn_load(const char *name, int argc, char **argv)
// Restore the process context
__syslinux_current = previous;
- cur_module = prev_module;
res = module_unload(module);
if (res != 0)
diff --git a/com32/lib/sys/module/i386/elf_module.c b/com32/lib/sys/module/i386/elf_module.c
index a3792554..d30f4ce2 100644
--- a/com32/lib/sys/module/i386/elf_module.c
+++ b/com32/lib/sys/module/i386/elf_module.c
@@ -46,6 +46,9 @@ int load_segments(struct elf_module *module, Elf_Ehdr *elf_hdr) {
// Load the PHT
pht = malloc(elf_hdr->e_phnum * elf_hdr->e_phentsize);
+ if (!pht)
+ return -1;
+
image_read(pht, elf_hdr->e_phnum * elf_hdr->e_phentsize, module);
// Compute the memory needings of the module
@@ -149,6 +152,11 @@ int load_segments(struct elf_module *module, Elf_Ehdr *elf_hdr) {
// Load the SHT
sht = malloc(elf_hdr->e_shnum * elf_hdr->e_shentsize);
+ if (!sht) {
+ res = -1;
+ goto out;
+ }
+
image_read(sht, elf_hdr->e_shnum * elf_hdr->e_shentsize, module);
// Setup the symtable size
diff --git a/com32/lib/sys/module/i386/shallow_module.c b/com32/lib/sys/module/i386/shallow_module.c
deleted file mode 100644
index fbcf781b..00000000
--- a/com32/lib/sys/module/i386/shallow_module.c
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * shallow_module.c
- *
- * Created on: Aug 11, 2008
- * Author: Stefan Bucur <stefanb@zytor.com>
- */
-
-
-#include <string.h>
-#include <sys/module.h>
-
-#include "common.h"
-#include "elfutils.h"
-
-
-static int check_header_shallow(Elf32_Ehdr *elf_hdr) {
- int res;
-
- res = check_header_common(elf_hdr);
-
- if (res != 0)
- return res;
-
- if (elf_hdr->e_shoff == 0x00000000) {
- DBG_PRINT("SHT missing\n");
- return -1;
- }
-
- return 0;
-}
-
-static int load_shallow_sections(struct elf_module *module, Elf32_Ehdr *elf_hdr) {
- int i;
- int res = 0;
- void *sht = NULL;
- void *buffer = NULL;
- Elf32_Shdr *crt_sht;
- Elf32_Off buff_offset;
-
- Elf32_Off min_offset = 0xFFFFFFFF;
- Elf32_Off max_offset = 0x00000000;
- Elf32_Word max_align = 0x1;
-
- Elf32_Off sym_offset = 0xFFFFFFFF;
- Elf32_Off str_offset = 0xFFFFFFFF;
-
-
- char *sh_strtable;
-
- // We buffer the data up to the SHT
- buff_offset = module->u.l._cr_offset;
-
- buffer = malloc(elf_hdr->e_shoff - buff_offset);
- // Get to the SHT
- image_read(buffer, elf_hdr->e_shoff - buff_offset, module);
-
- // Load the SHT
- sht = malloc(elf_hdr->e_shnum * elf_hdr->e_shentsize);
- image_read(sht, elf_hdr->e_shnum * elf_hdr->e_shentsize, module);
-
- // Get the string table of the section names
- crt_sht = (Elf32_Shdr*)(sht + elf_hdr->e_shstrndx * elf_hdr->e_shentsize);
- sh_strtable = (char*)(buffer + (crt_sht->sh_offset - buff_offset));
-
- for (i = 0; i < elf_hdr->e_shnum; i++) {
- crt_sht = (Elf32_Shdr*)(sht + i*elf_hdr->e_shentsize);
-
- if (strcmp(".symtab", sh_strtable + crt_sht->sh_name) == 0) {
- // We found the symbol table
- min_offset = MIN(min_offset, crt_sht->sh_offset);
- max_offset = MAX(max_offset, crt_sht->sh_offset + crt_sht->sh_size);
- max_align = MAX(max_align, crt_sht->sh_addralign);
-
- sym_offset = crt_sht->sh_offset;
-
- module->syment_size = crt_sht->sh_entsize;
- module->symtable_size = crt_sht->sh_size / crt_sht->sh_entsize;
- }
- if (strcmp(".strtab", sh_strtable + crt_sht->sh_name) == 0) {
- // We found the string table
- min_offset = MIN(min_offset, crt_sht->sh_offset);
- max_offset = MAX(max_offset, crt_sht->sh_offset + crt_sht->sh_size);
- max_align = MAX(max_align, crt_sht->sh_addralign);
-
- str_offset = crt_sht->sh_offset;
-
- module->strtable_size = crt_sht->sh_size;
- }
- }
-
- if (elf_malloc(&module->module_addr, max_align,
- max_offset - min_offset) != 0) {
- DBG_PRINT("Could not allocate sections\n");
- goto out;
- }
-
- // Copy the data
- image_seek(min_offset, module);
- image_read(module->module_addr, max_offset - min_offset, module);
-
- // Setup module information
- module->module_size = max_offset - min_offset;
- module->str_table = (char*)(module->module_addr + (str_offset - min_offset));
- module->sym_table = module->module_addr + (sym_offset - min_offset);
-
-out:
- // Release the SHT
- if (sht != NULL)
- free(sht);
-
- // Release the buffer
- if (buffer != NULL)
- free(buffer);
-
- return res;
-}
-
-
-int module_load_shallow(struct elf_module *module, Elf32_Addr base_addr) {
- int res;
- Elf32_Ehdr elf_hdr;
-
- // Do not allow duplicate modules
- if (module_find(module->name) != NULL) {
- DBG_PRINT("Module already loaded.\n");
- return -1;
- }
-
- res = image_load(module);
-
- if (res < 0)
- return res;
-
- module->shallow = 1;
-
- CHECKED(res, image_read(&elf_hdr, sizeof(Elf32_Ehdr), module), error);
-
- // Checking the header signature and members
- CHECKED(res, check_header_shallow(&elf_hdr), error);
-
- CHECKED(res, load_shallow_sections(module, &elf_hdr), error);
- module->base_addr = base_addr;
-
- // Check the symbols for duplicates / missing definitions
- CHECKED(res, check_symbols(module), error);
-
- // Add the module at the beginning of the module list
- list_add(&module->list, &modules_head);
-
- // The file image is no longer needed
- image_unload(module);
-
- DBG_PRINT("SHALLOW MODULE %s LOADED SUCCESSFULLY\n", module->name);
-
- return 0;
-
-error:
- image_unload(module);
-
- return res;
-}
diff --git a/com32/lib/sys/module/shallow_module.c b/com32/lib/sys/module/shallow_module.c
deleted file mode 100644
index 8a88e403..00000000
--- a/com32/lib/sys/module/shallow_module.c
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * shallow_module.c
- *
- * Created on: Aug 11, 2008
- * Author: Stefan Bucur <stefanb@zytor.com>
- */
-
-
-#include <string.h>
-#include <sys/module.h>
-
-#include "common.h"
-#include "elfutils.h"
-
-
-static int check_header_shallow(Elf32_Ehdr *elf_hdr) {
- int res;
-
- res = check_header_common(elf_hdr);
-
- if (res != 0)
- return res;
-
- if (elf_hdr->e_shoff == 0x00000000) {
- DBG_PRINT("SHT missing\n");
- return -1;
- }
-
- return 0;
-}
-
-static int load_shallow_sections(struct elf_module *module, Elf32_Ehdr *elf_hdr) {
- int i;
- int res = 0;
- char *sht = NULL;
- char *buffer = NULL;
- Elf32_Shdr *crt_sht;
- Elf32_Off buff_offset;
-
- Elf32_Off min_offset = 0xFFFFFFFF;
- Elf32_Off max_offset = 0x00000000;
- Elf32_Word max_align = 0x1;
-
- Elf32_Off sym_offset = 0xFFFFFFFF;
- Elf32_Off str_offset = 0xFFFFFFFF;
-
-
- char *sh_strtable;
-
- // We buffer the data up to the SHT
- buff_offset = module->u.l._cr_offset;
-
- buffer = malloc(elf_hdr->e_shoff - buff_offset);
- // Get to the SHT
- image_read(buffer, elf_hdr->e_shoff - buff_offset, module);
-
- // Load the SHT
- sht = malloc(elf_hdr->e_shnum * elf_hdr->e_shentsize);
- image_read(sht, elf_hdr->e_shnum * elf_hdr->e_shentsize, module);
-
- // Get the string table of the section names
- crt_sht = (Elf32_Shdr*)(sht + elf_hdr->e_shstrndx * elf_hdr->e_shentsize);
- sh_strtable = (char*)(buffer + (crt_sht->sh_offset - buff_offset));
-
- for (i = 0; i < elf_hdr->e_shnum; i++) {
- crt_sht = (Elf32_Shdr*)(sht + i*elf_hdr->e_shentsize);
-
- if (strcmp(".symtab", sh_strtable + crt_sht->sh_name) == 0) {
- // We found the symbol table
- min_offset = MIN(min_offset, crt_sht->sh_offset);
- max_offset = MAX(max_offset, crt_sht->sh_offset + crt_sht->sh_size);
- max_align = MAX(max_align, crt_sht->sh_addralign);
-
- sym_offset = crt_sht->sh_offset;
-
- module->syment_size = crt_sht->sh_entsize;
- module->symtable_size = crt_sht->sh_size / crt_sht->sh_entsize;
- }
- if (strcmp(".strtab", sh_strtable + crt_sht->sh_name) == 0) {
- // We found the string table
- min_offset = MIN(min_offset, crt_sht->sh_offset);
- max_offset = MAX(max_offset, crt_sht->sh_offset + crt_sht->sh_size);
- max_align = MAX(max_align, crt_sht->sh_addralign);
-
- str_offset = crt_sht->sh_offset;
-
- module->strtable_size = crt_sht->sh_size;
- }
- }
-
- if (elf_malloc(&module->module_addr, max_align,
- max_offset - min_offset) != 0) {
- DBG_PRINT("Could not allocate sections\n");
- goto out;
- }
-
- // Copy the data
- image_seek(min_offset, module);
- image_read(module->module_addr, max_offset - min_offset, module);
-
- // Setup module information
- module->module_size = max_offset - min_offset;
- module->str_table = (char *)module->module_addr + (str_offset - min_offset);
- module->sym_table = (char *)module->module_addr + (sym_offset - min_offset);
-
-out:
- // Release the SHT
- if (sht != NULL)
- free(sht);
-
- // Release the buffer
- if (buffer != NULL)
- free(buffer);
-
- return res;
-}
-
-
-int module_load_shallow(struct elf_module *module, Elf32_Addr base_addr) {
- int res;
- Elf32_Ehdr elf_hdr;
-
- // Do not allow duplicate modules
- if (module_find(module->name) != NULL) {
- DBG_PRINT("Module already loaded.\n");
- return -1;
- }
-
- res = image_load(module);
-
- if (res < 0)
- return res;
-
- module->shallow = 1;
-
- CHECKED(res, image_read(&elf_hdr, sizeof(Elf32_Ehdr), module), error);
-
- // Checking the header signature and members
- CHECKED(res, check_header_shallow(&elf_hdr), error);
-
- CHECKED(res, load_shallow_sections(module, &elf_hdr), error);
- module->base_addr = base_addr;
-
- // Check the symbols for duplicates / missing definitions
- CHECKED(res, check_symbols(module), error);
-
- // Add the module at the beginning of the module list
- list_add(&module->list, &modules_head);
-
- // The file image is no longer needed
- image_unload(module);
-
- DBG_PRINT("SHALLOW MODULE %s LOADED SUCCESSFULLY\n", module->name);
-
- return 0;
-
-error:
- image_unload(module);
-
- return res;
-}
diff --git a/com32/lib/sys/module/x86_64/elf_module.c b/com32/lib/sys/module/x86_64/elf_module.c
index 64404a17..dd24bd12 100644
--- a/com32/lib/sys/module/x86_64/elf_module.c
+++ b/com32/lib/sys/module/x86_64/elf_module.c
@@ -46,6 +46,9 @@ int load_segments(struct elf_module *module, Elf_Ehdr *elf_hdr) {
// Load the PHT
pht = malloc(elf_hdr->e_phnum * elf_hdr->e_phentsize);
+ if (!pht)
+ return -1;
+
image_read(pht, elf_hdr->e_phnum * elf_hdr->e_phentsize, module);
// Compute the memory needings of the module
@@ -149,6 +152,11 @@ int load_segments(struct elf_module *module, Elf_Ehdr *elf_hdr) {
// Load the SHT
sht = malloc(elf_hdr->e_shnum * elf_hdr->e_shentsize);
+ if (!sht) {
+ res = -1;
+ goto out;
+ }
+
image_read(sht, elf_hdr->e_shnum * elf_hdr->e_shentsize, module);
// Setup the symtable size
diff --git a/com32/lib/sys/module/x86_64/shallow_module.c b/com32/lib/sys/module/x86_64/shallow_module.c
deleted file mode 100644
index b7248150..00000000
--- a/com32/lib/sys/module/x86_64/shallow_module.c
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * shallow_module.c
- *
- * Created on: Aug 11, 2008
- * Author: Stefan Bucur <stefanb@zytor.com>
- */
-
-
-#include <string.h>
-#include <sys/module.h>
-
-#include "common.h"
-#include "elfutils.h"
-
-
-static int check_header_shallow(Elf64_Ehdr *elf_hdr) {
- int res;
-
- res = check_header_common(elf_hdr);
-
- if (res != 0)
- return res;
-
- if (elf_hdr->e_shoff == 0x00000000) {
- DBG_PRINT("SHT missing\n");
- return -1;
- }
-
- return 0;
-}
-
-static int load_shallow_sections(struct elf_module *module, Elf64_Ehdr *elf_hdr) {
- int i;
- int res = 0;
- void *sht = NULL;
- void *buffer = NULL;
- Elf64_Shdr *crt_sht;
- Elf64_Off buff_offset;
-
- Elf64_Off min_offset = 0xFFFFFFFFFFFFFFFF;
- Elf64_Off max_offset = 0x0000000000000000;
- Elf64_Word max_align = 0x1;
-
- Elf64_Off sym_offset = 0xFFFFFFFFFFFFFFFF;
- Elf64_Off str_offset = 0xFFFFFFFFFFFFFFFF;
-
-
- char *sh_strtable;
-
- // We buffer the data up to the SHT
- buff_offset = module->u.l._cr_offset;
-
- buffer = malloc(elf_hdr->e_shoff - buff_offset);
- // Get to the SHT
- image_read(buffer, elf_hdr->e_shoff - buff_offset, module);
-
- // Load the SHT
- sht = malloc(elf_hdr->e_shnum * elf_hdr->e_shentsize);
- image_read(sht, elf_hdr->e_shnum * elf_hdr->e_shentsize, module);
-
- // Get the string table of the section names
- crt_sht = (Elf64_Shdr*)(sht + elf_hdr->e_shstrndx * elf_hdr->e_shentsize);
- sh_strtable = (char*)(buffer + (crt_sht->sh_offset - buff_offset));
-
- for (i = 0; i < elf_hdr->e_shnum; i++) {
- crt_sht = (Elf64_Shdr*)(sht + i*elf_hdr->e_shentsize);
-
- if (strcmp(".symtab", sh_strtable + crt_sht->sh_name) == 0) {
- // We found the symbol table
- min_offset = MIN(min_offset, crt_sht->sh_offset);
- max_offset = MAX(max_offset, crt_sht->sh_offset + crt_sht->sh_size);
- max_align = MAX(max_align, crt_sht->sh_addralign);
-
- sym_offset = crt_sht->sh_offset;
-
- module->syment_size = crt_sht->sh_entsize;
- module->symtable_size = crt_sht->sh_size / crt_sht->sh_entsize;
- }
- if (strcmp(".strtab", sh_strtable + crt_sht->sh_name) == 0) {
- // We found the string table
- min_offset = MIN(min_offset, crt_sht->sh_offset);
- max_offset = MAX(max_offset, crt_sht->sh_offset + crt_sht->sh_size);
- max_align = MAX(max_align, crt_sht->sh_addralign);
-
- str_offset = crt_sht->sh_offset;
-
- module->strtable_size = crt_sht->sh_size;
- }
- }
-
- if (elf_malloc(&module->module_addr, max_align,
- max_offset - min_offset) != 0) {
- DBG_PRINT("Could not allocate sections\n");
- goto out;
- }
-
- // Copy the data
- image_seek(min_offset, module);
- image_read(module->module_addr, max_offset - min_offset, module);
-
- // Setup module information
- module->module_size = max_offset - min_offset;
- module->str_table = (char*)(module->module_addr + (str_offset - min_offset));
- module->sym_table = module->module_addr + (sym_offset - min_offset);
-
-out:
- // Release the SHT
- if (sht != NULL)
- free(sht);
-
- // Release the buffer
- if (buffer != NULL)
- free(buffer);
-
- return res;
-}
-
-
-int module_load_shallow(struct elf_module *module, Elf64_Addr base_addr) {
- int res;
- Elf64_Ehdr elf_hdr;
-
- // Do not allow duplicate modules
- if (module_find(module->name) != NULL) {
- DBG_PRINT("Module already loaded.\n");
- return -1;
- }
-
- res = image_load(module);
-
- if (res < 0)
- return res;
-
- module->shallow = 1;
-
- CHECKED(res, image_read(&elf_hdr, sizeof(Elf64_Ehdr), module), error);
-
- // Checking the header signature and members
- CHECKED(res, check_header_shallow(&elf_hdr), error);
-
- CHECKED(res, load_shallow_sections(module, &elf_hdr), error);
- module->base_addr = base_addr;
-
- // Check the symbols for duplicates / missing definitions
- CHECKED(res, check_symbols(module), error);
-
- // Add the module at the beginning of the module list
- list_add(&module->list, &modules_head);
-
- // The file image is no longer needed
- image_unload(module);
-
- DBG_PRINT("SHALLOW MODULE %s LOADED SUCCESSFULLY\n", module->name);
-
- return 0;
-
-error:
- image_unload(module);
-
- return res;
-}
diff --git a/com32/lib/syslinux/serial.c b/com32/lib/syslinux/serial.c
index bc41acfc..041e8505 100644
--- a/com32/lib/syslinux/serial.c
+++ b/com32/lib/syslinux/serial.c
@@ -38,7 +38,7 @@
struct syslinux_serial_console_info __syslinux_serial_console_info;
-void __constructor __syslinux_get_serial_console_info(void)
+void __syslinux_set_serial_console_info(void)
{
uint16_t iobase, divisor, flowctl;
diff --git a/com32/libutil/Makefile b/com32/libutil/Makefile
index 5e941658..094f1ff5 100644
--- a/com32/libutil/Makefile
+++ b/com32/libutil/Makefile
@@ -38,10 +38,10 @@ LIBOBJS = ansiline.o ansiraw.o keyname.o \
quicksort.o
LNXLIBOBJS = $(patsubst %.o,%.lo,$(LIBOBJS))
-all: libutil_com.c32 libutil_lnx.a
+all: libutil.c32 libutil_lnx.a
-libutil_com.c32: $(LIBOBJS)
- $(LD) $(LDFLAGS) -soname $(@F) -o $@ $^
+libutil.elf: $(LIBOBJS)
+ $(LD) $(LDFLAGS) -soname $(patsubst %.elf,%.c32,$(@F)) -o $@ $^
libutil_lnx.a: $(LNXLIBOBJS)
rm -f $@
diff --git a/com32/lua/src/Makefile b/com32/lua/src/Makefile
index 70a7e808..f3625e1a 100644
--- a/com32/lua/src/Makefile
+++ b/com32/lua/src/Makefile
@@ -49,10 +49,11 @@ CFLAGS += -DLUA_ANSI
all: $(MODULES) $(TESTFILES)
-$(LIBLUA) : $(LIBLUA_OBJS)
- $(LD) -shared $(LDFLAGS) -o $@ $^
+liblua.elf : $(LIBLUA_OBJS)
+ $(LD) $(LDFLAGS) -shared -soname $(patsubst %.elf,%.c32,$(@F)) \
+ -o $@ $^
-lua.c32 : $(OBJS) $(LIBLUA) $(C_LIBS)
+lua.elf : $(OBJS) $(LIBLUA) $(C_LIBS)
$(LD) $(LDFLAGS) -o $@ $^
tidy dist:
diff --git a/com32/mboot/Makefile b/com32/mboot/Makefile
index a3f61ba8..e9164369 100644
--- a/com32/mboot/Makefile
+++ b/com32/mboot/Makefile
@@ -27,7 +27,7 @@ OBJS = mboot.o map.o mem.o initvesa.o apm.o solaris.o syslinux.o
all: $(MODULES) $(TESTFILES)
-mboot.c32 : $(OBJS) $(C_LIBS)
+mboot.elf : $(OBJS) $(C_LIBS)
$(LD) $(LDFLAGS) -o $@ $^
tidy dist:
diff --git a/com32/menu/Makefile b/com32/menu/Makefile
index 9f7a0e46..7c2d5927 100644
--- a/com32/menu/Makefile
+++ b/com32/menu/Makefile
@@ -27,10 +27,10 @@ COMMONOBJS = menumain.o readconfig.o passwd.o drain.o \
all: $(MODULES) $(TESTFILES)
-vesamenu.c32: vesamenu.o $(COMMONOBJS) $(C_LIBS)
+menu.elf : menu.o $(COMMONOBJS) $(C_LIBS)
$(LD) $(LDFLAGS) -o $@ $^
-menu.c32: menu.o $(COMMONOBJS) $(C_LIBS)
+vesamenu.elf : vesamenu.o $(COMMONOBJS) $(C_LIBS)
$(LD) $(LDFLAGS) -o $@ $^
tidy dist:
diff --git a/com32/modules/Makefile b/com32/modules/Makefile
index e794b3b9..8965f5f0 100644
--- a/com32/modules/Makefile
+++ b/com32/modules/Makefile
@@ -34,7 +34,7 @@ all: $(MODULES) $(TESTFILES)
dmitest.o: dmitest.c
$(CC) $(CFLAGS) $(GPLINCLUDE) -c -o $@ $<
-dmitest.c32 : dmi_utils.o dmitest.o $(C_LIBS)
+dmitest.elf : dmi_utils.o dmitest.o $(C_LIBS)
$(LD) $(LDFLAGS) -o $@ $^
tidy dist:
diff --git a/com32/rosh/Makefile b/com32/rosh/Makefile
index a4c0bc28..4d900f4f 100644
--- a/com32/rosh/Makefile
+++ b/com32/rosh/Makefile
@@ -16,7 +16,7 @@
## ROSH Read Only Shell
##
-LIBS = $(objdir)/com32/libutil/libutil_com.c32 \
+LIBS = $(objdir)/com32/libutil/libutil.c32 \
$(objdir)/com32/lib/libcom32.c32
VPATH = $(SRC)
diff --git a/com32/samples/Makefile b/com32/samples/Makefile
index ca04f644..06e9684b 100644
--- a/com32/samples/Makefile
+++ b/com32/samples/Makefile
@@ -14,7 +14,7 @@
## samples for syslinux users
##
-LIBS = $(objdir)/com32/libutil/libutil_com.c32
+LIBS = $(objdir)/com32/libutil/libutil.c32
VPATH = $(SRC)
include $(MAKEDIR)/elf.mk
diff --git a/com32/sysdump/Makefile b/com32/sysdump/Makefile
index dca5d717..240edaaa 100644
--- a/com32/sysdump/Makefile
+++ b/com32/sysdump/Makefile
@@ -44,7 +44,7 @@ CFLAGS += -DDATE='"$(DATE)"'
all: $(MODULES) $(TESTFILES)
-sysdump.c32 : $(OBJS) $(LIBS) $(C_LIBS)
+sysdump.elf : $(OBJS) $(LIBS) $(C_LIBS)
$(LD) $(LDFLAGS) -o $@ $^
tidy dist: