aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFeng Tang <feng.tang@intel.com>2010-06-17 17:09:30 +0800
committerFeng Tang <feng.tang@intel.com>2010-07-20 11:10:03 +0800
commit71d5d1ba646e676cf1faf394e0d54950e416fe1c (patch)
tree59d43ce256f1fb0b7f08637b25be9add5ce66b68
parent2c3f9a53205e8a44a4b58f68e3cce2732225d05f (diff)
downloadsyslinux-71d5d1ba646e676cf1faf394e0d54950e416fe1c.tar.gz
syslinux-71d5d1ba646e676cf1faf394e0d54950e416fe1c.tar.xz
syslinux-71d5d1ba646e676cf1faf394e0d54950e416fe1c.zip
elflink: change the exit.c, remove the exit.S to make process exit working
following elflink branch
-rw-r--r--com32/lib/MCONFIG2
-rwxr-xr-xcom32/lib/Makefile2
-rw-r--r--com32/lib/exit.c24
-rw-r--r--com32/lib/sys/exit.S41
-rwxr-xr-xcom32/lib/sys/module/elf_module.c5
-rw-r--r--com32/lib/sys/module/exec.c1
6 files changed, 26 insertions, 49 deletions
diff --git a/com32/lib/MCONFIG b/com32/lib/MCONFIG
index 44278bd1..c441c9c1 100644
--- a/com32/lib/MCONFIG
+++ b/com32/lib/MCONFIG
@@ -38,7 +38,7 @@ OPTFLAGS = -Os -march=i386 -falign-functions=0 -falign-jumps=0 \
WARNFLAGS = $(GCCWARN) -Wpointer-arith -Wwrite-strings -Wstrict-prototypes -Winline
CFLAGS = $(OPTFLAGS) $(REQFLAGS) $(WARNFLAGS) $(LIBFLAGS)
-LDFLAGS = -m elf32_i386
+LDFLAGS = -m elf32_i386 --hash-style=gnu
.SUFFIXES: .c .o .a .so .lo .i .S .s .ls .ss .lss
diff --git a/com32/lib/Makefile b/com32/lib/Makefile
index f53c2c2f..2c15b9d2 100755
--- a/com32/lib/Makefile
+++ b/com32/lib/Makefile
@@ -68,7 +68,7 @@ DYNENTRY_OBJS = \
## CORE OBJECTS, INCLUDED IN THE ROOT COM32 MODULE
LIBENTRY_OBJS = \
sys/intcall.o sys/farcall.o sys/cfarcall.o sys/zeroregs.o \
- sys/argv.o sys/exit.o \
+ sys/argv.o \
sys/fileinfo.o sys/opendev.o sys/read.o sys/write.o sys/ftell.o \
sys/close.o sys/open.o sys/fileread.o sys/fileclose.o \
sys/openmem.o \
diff --git a/com32/lib/exit.c b/com32/lib/exit.c
index ccd6f1ee..cba6cee0 100644
--- a/com32/lib/exit.c
+++ b/com32/lib/exit.c
@@ -31,11 +31,29 @@
* The regular exit
*/
+#include <sys/module.h>
#include <stdlib.h>
-
-extern __noreturn(*__exit_handler) (int);
+#include <unistd.h>
+#include "atexit.h"
__noreturn exit(int rv)
{
- __exit_handler(rv);
+ struct atexit *ap;
+
+ for (ap = __syslinux_current->u.x.atexit_list; ap; ap = ap->next) {
+ ap->fctn(rv, ap->arg); /* This assumes extra args are harmless */
+ }
+
+ _exit(rv);
+}
+
+__noreturn _Exit(int rv)
+{
+ _exit(rv);
}
+
+__noreturn _exit(int rv)
+{
+ longjmp(__syslinux_current->u.x.process_exit, rv+1);
+}
+
diff --git a/com32/lib/sys/exit.S b/com32/lib/sys/exit.S
deleted file mode 100644
index 2ab80122..00000000
--- a/com32/lib/sys/exit.S
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Implementation of _exit() for com32 based on c32entry.S
- */
- .text
-
- .globl _Exit
- .type _Exit, @function
-_Exit:
- /* Just fall through to _exit */
- .size _Exit, .-_Exit
-
- .globl _exit
- .type _exit, @function
-_exit:
-#ifdef REGPARM
- pushl %eax
-#endif
-
- /* Run any destructors */
- movl $__dtors_start, %esi
-2:
- cmpl $__dtors_end, %esi
- jae 1f
- call *(%esi)
- addl $4,%esi
- jmp 2b
-
-1:
-#ifdef REGPARM
- popl %eax
-#else
- movl 4(%esp),%eax # Exit code in %eax = return value
-#endif
- movl (__entry_esp),%esp # Return stack pointer to entry value
- ret # Return to termination address
- .size _exit, .-_exit
-
- .data
-__exit_handler:
- .globl __exit_handler
- .long _exit
diff --git a/com32/lib/sys/module/elf_module.c b/com32/lib/sys/module/elf_module.c
index 187dfee7..26705df7 100755
--- a/com32/lib/sys/module/elf_module.c
+++ b/com32/lib/sys/module/elf_module.c
@@ -462,7 +462,7 @@ int module_load(struct elf_module *module) {
CHECKED(res, prepare_dynlinking(module), error);
//printf("check... 4\n");
//
- dump_elf_module(module);
+ //dump_elf_module(module);
// Check the symbols for duplicates / missing definitions
CHECKED(res, check_symbols(module), error);
@@ -486,13 +486,12 @@ int module_load(struct elf_module *module) {
image_unload(module);
/*
- */
DBG_PRINT("MODULE %s LOADED SUCCESSFULLY (main@%p, init@%p, exit@%p)\n",
module->name,
(module->main_func == NULL) ? NULL : *(module->main_func),
(module->init_func == NULL) ? NULL : *(module->init_func),
(module->exit_func == NULL) ? NULL : *(module->exit_func));
-
+ */
return 0;
error:
diff --git a/com32/lib/sys/module/exec.c b/com32/lib/sys/module/exec.c
index d6942a9a..8204ee42 100644
--- a/com32/lib/sys/module/exec.c
+++ b/com32/lib/sys/module/exec.c
@@ -306,6 +306,7 @@ int spawn_load(const char *name,const char **argv)
else
exit((*module->main_func)(argc, args)); /* Actually run! */
+
// Clean up the allocation context
//__free_tagged(module);
// Restore the allocation context