[Kos-cvs] kos/modules/kbs/elf _elf.c,1.2,1.3
thomas at kos.enix.org
thomas at kos.enix.org
Tue Dec 28 19:44:36 CET 2004
Update of /var/cvs/kos/kos/modules/kbs/elf
In directory the-doors:/tmp/cvs-serv10813/modules/kbs/elf
Modified Files:
_elf.c
Log Message:
2004-12-28 Thomas Petazzoni <thomas at crazy.kos.nx>
* modules/x86/task/task.c: Try to restrict access to exported
symbol.
* modules/x86/task/_thread_cpu_context.c: Move to the new PMM
system.
* modules/x86/task/Makefile (all): arch_task.ro instead of
arch-task.ro.
* modules/x86/mm/_team_mm_context.c: More informations.
* modules/x86/mm/_mm.h, modules/x86/mm/mm.c, modules/x86/mm/_rmap.c,
modules/x86/mm/_vmap.c: The new VMAP/RMAP system. We also make
sure access to all exported function is restricted to the VMM
module.
* modules/x86/mm/Makefile (all): arch_mm.ro instead of
arch-mm.ro.
* modules/x86/lib/Makefile (all): Rename to arch_lib.ro instead of
arch-lib.ro.
* modules/x86/internals.h: More definitions on the address space
configuration.
* modules/vmm/vmm.h (struct address_space): Add a mutex and a
spinlock to protect address space.
* modules/vmm/vmm.c: Restrict access to some exported
functions. More work has to be done in this area.
* modules/vmm/_vmm_map.c: Part of the new vmap system.
* modules/vmm/_vmm_as.c: Make the appropriate lock/unlock on the
address space mutex. It's just a first try. More reflexion has to
be made.
* modules/task/task.h: Make sure DOXYGEN doesn't try to analyze
the #if stuff, because it doesn't like it.
* modules/task/_task_utils.c (show_all_thread_info): If team is
NULL, it means that we want to display the threads of all teams.
* modules/scheduler/synchq.h: Avoid inclusion of task.h.
* modules/pmm/pmm.c: New PMM system.
* modules/pmm/_pmm_put_page.c: New PMM system.
* modules/pmm/_pmm_init.c: New PMM system.
* modules/pmm/_pmm_get_page.c: New PMM system.
* modules/pmm/_pmm_get_at_addr.c: New PMM system.
* modules/pmm/_pmm.h: struct gpfme is now private.
* modules/pmm/pmm.h: struct gpfme is now private (migrated to
_pmm.h).
* modules/pmm/Makefile (OBJS): New PMM system, with fewer
functionnalities.
* modules/kos/spinlock.h: New type spinlock_flags_t, that should
be used instead of k_ui32_t for spinlock flags.
* modules/kmem/_kvmem_utils.c: Migration to the new PMM
system and various cleanups.
* modules/kmem/_kvmem_init.c: Migration to the new PMM
system and various cleanups.
* modules/kmem/_kslab_cache_grow.c: Migration to the new PMM
system and various cleanups.
* modules/kmem/_kslab_cache_free.c: Migration to the new PMM
system, and various cleanups.
* modules/kitc/_kmutex.c: DEBUG_PRINT3 calls to show mutex
lock/unlock/trylock.
* modules/init/_init_modules.c (init_modules): A message is
displayed when initializating modules.
* modules/ide/_ide.c: Various cleanups.
* modules/fs/fat/_fat.c: Various cleanups.
* modules/fs/devfs/devfs.c: Various cleanups, including whitespace
cleanification.
* modules/debug/debug.h: Add the DEBUG_PRINT1, DEBUG_PRINT2,
DEBUG_PRINT3 macros. Maybe there's a cleaner way to do it. David ?
* modules/debug/debug.c (init_module_level0): Init the
backtracking stuff a little later so that we have debugging
messages during this initialization.
* modules/debug/bt.c (_init_backtracing_stuff): bt_next is not
anymore a valid candidate to determine if fomit-frame-pointer was
selected or not, because of gcc optimizations. We use bt_init
instead.
* modules/Makefile (doc): Add a target that generates the doxygen
documentation.
* loader/mod.h (EXPORT_FUNCTION_RESTRICTED): Change the symbol
names generated by the macros, so that they include the name of
the target module (the one allowed to import the exported
symbol). This is needed in order to export the same symbol to
multiple modules. Previously, the RESTRICTED system generated
symbols that were identical for a given symbol exported to
multiple modules.
* doc/testingfr.tex: A big update to this documentation. Not
finished. The english version should also be updated.
* TODO: Some new things to do.
* MkVars (CFLAGS): Pass the DEBUG_LEVEL Makefile variable to the C
files. In each modules/.../Makefile, we can set a
DEBUG_LEVEL=value that will set the level of verbosity of the
module. Macros named DEBUG_PRINT1, DEBUG_PRINT2, DEBUG_PRINT3 have
been added.
(MODULES): Change all '-' to '_', because of the new
EXPORT_FUNCTION_RESTRICTED system. This system creates symbol that
contains the name of a module (the one allowed to import the
exported symbol). But the '-' character is not allowed inside C
identifiers. So, we use '_' instead.
* CREDITS: Add Fabrice Bellard to the CREDITS, for his Qemu
emulator.
Index: _elf.c
===================================================================
RCS file: /var/cvs/kos/kos/modules/kbs/elf/_elf.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- _elf.c 29 Dec 2003 13:42:51 -0000 1.2
+++ _elf.c 28 Dec 2004 18:44:34 -0000 1.3
@@ -1,6 +1,6 @@
/** elf.c - Copyright (c) 2003, Julien Munier <julien.munier at enix.org>
the Kid Operating System, http://kos.enix.org/
-
+
elf format support and loading facility.
Warning: only for x86 Intel architecture!
*/
@@ -24,7 +24,7 @@
static int elf32_loadbin(struct binld *ur);
static struct binfmt elf32_binfmt =
- {
+ {
"elf32",
elf32_loadbin,
elf32_loadshl,
@@ -72,7 +72,7 @@
DEBUG("[elf.c] Invalid Elf header version number\n");
return -EINVAL;
}
-
+
/** We do only support 32-bits Intel x86 objects */
if (elf32header->e_ident[EI_CLASS] != ELFCLASS32)
{
@@ -131,15 +131,15 @@
{
result_t retval;
vaddr_t addr;
-
+
CONCEPTION_ASSERT(mur != NULL);
ASSERT_RETURN_VAL(tph != NULL, -EINVAL);
DEBUG("[elf.c] mapping file from @0x%x in file, at @0x%x in mem., 0x%x bytes, %d\n",
tph->p_offset, tph->p_vaddr, tph->p_filesz, ar);
-
- retval = as_map_ures(& get_current_team()->address_space, mur,
+
+ retval = as_map_ures(& get_current_team()->address_space, mur,
tph->p_offset,
tph->p_vaddr, tph->p_filesz,
MAP_PRIVATE,
@@ -156,7 +156,7 @@
{
result_t retval=ESUCCESS;
vaddr_t addr;
-
+
CONCEPTION_ASSERT(base < end);
DEBUG("[elf.c] padding at @0x%x in mem., 0x%x bytes, %d\n",
@@ -175,7 +175,7 @@
base, end - base,
MAP_PRIVATE,
ar,
- MAP_FIXED | MAP_ANONYMOUS,
+ MAP_FIXED | MAP_ANONYMOUS,
&addr);
}
@@ -203,7 +203,7 @@
vaddr_t data_end=0;
vaddr_t code_start=0;
vaddr_t code_end=0;
-
+
ASSERT_RETURN_VAL(bld != NULL, -EINVAL);
ASSERT_RETURN_VAL(bld->ur->view->iid == INTERFACE_FILE_ID, -EBADIFACE);
@@ -234,7 +234,7 @@
kfree(elf32phdrs);
return retval;
}
-
+
/** ret the bytes */
retval = FILE_OPS(ur->view->ops)->read(ur, (char*)elf32phdrs, & elf32phdrs_sz);
if (retval < 0)
@@ -247,7 +247,7 @@
/** set theorical code_start */
base_addr = code_start = elf32ehdr->e_entry;
-
+
DEBUG("[elf.c] Lookup for an interpreter\n");
/** lookup for an interpreter */
for (i=0, tph = elf32phdrs ; i < elf32ehdr->e_phnum ; i++)
@@ -274,7 +274,7 @@
}
tph++;
}
-
+
/** co interpreter information */
if (interpreter)
{
@@ -304,7 +304,7 @@
{
vaddr_t k, start_addr;
access_right_t ar = 0;
-
+
if (tph->p_type != PT_LOAD)
{
DEBUG("[elf.c] Not a loadable segment\n");
@@ -312,26 +312,26 @@
}
if (tph->p_memsz == 0)
- continue;
-
+ continue;
+
if(tph->p_flags & PF_X) ar |= VM_ACCESS_EXEC;
if(tph->p_flags & PF_W) ar |= VM_ACCESS_WRITE;
if(tph->p_flags & PF_R) ar |= VM_ACCESS_READ;
-
+
/** mapping structure
| Pad |
- |----------| PAGE_ALIGN_SUP(prev.hdr(p_vaddr + p_memsz))
+ |----------| PAGE_ALIGN_SUP(prev.hdr(p_vaddr + p_memsz))
| prev.Pad | == PAGE_ALIGN_INF(current.p_vaddr)
|----------| current.hdr(p_vaddr)
- | |
+ | |
| bulk | <- map current.hdr(p_filesz) bytes
- | |
- |----------| current.hdr(p_vaddr + p_filesz)
+ | |
+ |----------| current.hdr(p_vaddr + p_filesz)
| 0x0 | <- fill the gap with 0x0
|----------| current.hdr(p_vaddr + p_memsz)
| Pad |
|----------| PAGE_ALIGN_SUP(current.hdr(p_vaddr + p_memsz)
-
+
Step for mapping :
- pad to reach the vaddr from where to map to
- map the file bulk for p_filesz
@@ -346,14 +346,14 @@
retval = map_elf_segment(mur, tph, ar);
if (retval < 0)
{
- DEBUG("Couldn't map segmen\n");
+ DEBUG("Couldn't map segment\n");
return retval;
}
}
if (tph->p_memsz > tph->p_filesz)
{
- retval = elf_padding(k + tph->p_filesz,
+ retval = elf_padding(k + tph->p_filesz,
k + tph->p_memsz,
ar);
if (retval < 0)
@@ -362,16 +362,16 @@
return retval;
}
}
-
+
if (k < code_start) code_start = k;
if (k > data_start) data_start = k;
-
+
k += tph->p_filesz;
if ((ar & PF_X) && code_end < k) code_end = k;
k = tph->p_vaddr + tph->p_memsz;
if (data_end < k) data_end = k;
}
-
+
if (interpreter)
{
//elf_entry = elf32_load_interpreter(...);
More information about the Kos-cvs
mailing list