[syslinux] [GIT PULL] elflink fixes
Matt Fleming
matt at console-pimps.org
Wed Sep 5 01:34:03 PDT 2012
Hi Peter,
Please pull the following changes. The one from Mouli fixes a
particularly nasty bug where we walk out of the symbol table bounds and
start accessing bits of memory, which caused hangs on some machines.
The following changes since commit d1d03dee6bc961b0afd8dfc68fd35772ecded8be:
ldlinux: Use findpath() to lookup filenames (2012-08-07 10:40:12 +0100)
are available in the git repository at:
git://git.zytor.com/users/mfleming/syslinux.git elflink
Chandramouli Narayanan (1):
module: Fixed the upper limit in symbol table walk through
Matt Fleming (1):
console: Close stdin, stdout, stderr on ldlinux.c32 unload
com32/elflink/ldlinux/ldlinux.c | 12 ++++++++++++
com32/lib/Makefile | 2 +-
com32/lib/sys/module/common.c | 6 +++---
core/extern.inc | 2 --
core/hello.c | 5 -----
core/init.c | 2 --
6 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/com32/elflink/ldlinux/ldlinux.c b/com32/elflink/ldlinux/ldlinux.c
index 1c261cd..f82b166 100644
--- a/com32/elflink/ldlinux/ldlinux.c
+++ b/com32/elflink/ldlinux/ldlinux.c
@@ -252,6 +252,18 @@ cmdline:
goto auto_boot;
}
+
+/*
+ * Undo the work we did in openconsole().
+ */
+static void __destructor close_console(void)
+{
+ int i;
+
+ for (i = 0; i <= 2; i++)
+ close(i);
+}
+
int main(int argc __unused, char **argv __unused)
{
const void *adv;
diff --git a/com32/lib/Makefile b/com32/lib/Makefile
index 5d270a4..fc5defc 100644
--- a/com32/lib/Makefile
+++ b/com32/lib/Makefile
@@ -170,7 +170,7 @@ CORELIBOBJS = \
sprintf.o strlcat.o strchr.o strlcpy.o strncasecmp.o ctypes.o \
fputs.o fwrite2.o fwrite.o fgetc.o fclose.o errno.o lmalloc.o \
sys/err_read.o sys/err_write.o sys/null_read.o \
- sys/stdcon_write.o sys/openconsole.o \
+ sys/stdcon_write.o \
syslinux/memscan.o strrchr.o \
libgcc/__ashldi3.o libgcc/__udivdi3.o \
libgcc/__negdi2.o libgcc/__ashrdi3.o libgcc/__lshrdi3.o \
diff --git a/com32/lib/sys/module/common.c b/com32/lib/sys/module/common.c
index 6e63907..30c57b4 100644
--- a/com32/lib/sys/module/common.c
+++ b/com32/lib/sys/module/common.c
@@ -47,7 +47,7 @@ void print_elf_symbols(struct elf_module *module) {
unsigned int i;
Elf32_Sym *crt_sym;
- for (i = 1; i < module->symtable_size; i++)
+ for (i = 1; i < module->symtable_size/module->syment_size; i++)
{
crt_sym = (Elf32_Sym*)(module->sym_table + i*module->syment_size);
@@ -315,7 +315,7 @@ int check_symbols(struct elf_module *module)
int strong_count;
int weak_count;
- for(i = 1; i < module->symtable_size; i++)
+ for (i = 1; i < module->symtable_size/module->syment_size; i++)
{
crt_sym = symbol_get_entry(module, i);
crt_name = module->str_table + crt_sym->st_name;
@@ -535,7 +535,7 @@ static Elf32_Sym *module_find_symbol_iterate(const char *name,struct elf_module
unsigned int i;
Elf32_Sym *crt_sym;
- for (i=1; i < module->symtable_size; i++)
+ for (i = 1; i < module->symtable_size/module->syment_size; i++)
{
crt_sym = symbol_get_entry(module, i);
if (strcmp(name, module->str_table + crt_sym->st_name) == 0)
diff --git a/core/extern.inc b/core/extern.inc
index 3cde286..953be42 100644
--- a/core/extern.inc
+++ b/core/extern.inc
@@ -27,8 +27,6 @@
extern hexdump, mydump
- extern printf_init
-
extern mem_init
; fs.c
diff --git a/core/hello.c b/core/hello.c
index d30fc3b..bed7cb5 100644
--- a/core/hello.c
+++ b/core/hello.c
@@ -76,8 +76,3 @@ void mp5(void)
myprint(5);
}
-void printf_init(void)
-{
- openconsole(&dev_null_r, &dev_stdcon_w);
-}
-
diff --git a/core/init.c b/core/init.c
index 01319f4..26b4a19 100644
--- a/core/init.c
+++ b/core/init.c
@@ -62,7 +62,6 @@ static inline void bios_timer_init(void)
*hook = (uint32_t)&timer_irq;
}
-extern void printf_init(void);
void init(com32sys_t *regs __unused)
{
int i;
@@ -74,7 +73,6 @@ void init(com32sys_t *regs __unused)
KbdMap[i] = i;
adjust_screen();
- printf_init();
/* Init the memory subsystem */
mem_init();
More information about the Syslinux
mailing list