Changed the boot ELF code to use templates and added ELF64 support.
The actual implementation of the ELF loading methods have been put into an ELFLoader template class that takes a single template parameter, which is a structure containing all the necessary ELF typedefs. It's a bit verbose, but I thought it was a neater solution than using a bunch of standalone functions with a huge number of template parameters. There is no change to code outside of elf.cpp, the ELF32/ELF64 differences are handled internally.
This commit is contained in:
@@ -5,24 +5,21 @@
|
||||
#ifndef KERNEL_BOOT_ARCH_H
|
||||
#define KERNEL_BOOT_ARCH_H
|
||||
|
||||
|
||||
#include <SupportDefs.h>
|
||||
#include <boot/elf.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* ELF support */
|
||||
|
||||
extern status_t boot_arch_elf_relocate_rel(preloaded_elf32_image *image,
|
||||
struct Elf32_Rel *rel, int rel_len);
|
||||
extern status_t boot_arch_elf_relocate_rela(preloaded_elf32_image *image,
|
||||
struct Elf32_Rela *rel, int rel_len);
|
||||
extern status_t boot_arch_elf_relocate_rel(preloaded_elf32_image* image,
|
||||
struct Elf32_Rel* rel, int rel_len);
|
||||
extern status_t boot_arch_elf_relocate_rel(preloaded_elf64_image* image,
|
||||
struct Elf64_Rel* rel, int rel_len);
|
||||
extern status_t boot_arch_elf_relocate_rela(preloaded_elf32_image* image,
|
||||
struct Elf32_Rela* rel, int rel_len);
|
||||
extern status_t boot_arch_elf_relocate_rela(preloaded_elf64_image* image,
|
||||
struct Elf64_Rela* rel, int rel_len);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* KERNEL_BOOT_ARCH_H */
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
/*
|
||||
** Copyright 2003-2004, Axel Dörfler, [email protected]. All rights reserved.
|
||||
** Distributed under the terms of the OpenBeOS License.
|
||||
*/
|
||||
* Copyright 2003-2004, Axel Dörfler, [email protected]. All rights reserved.
|
||||
* Copyright 2012, Alex Smith, [email protected].
|
||||
* Distributed under the terms of the OpenBeOS License.
|
||||
*/
|
||||
#ifndef KERNEL_BOOT_ELF_H
|
||||
#define KERNEL_BOOT_ELF_H
|
||||
|
||||
@@ -76,15 +77,11 @@ struct preloaded_elf64_image : public preloaded_image {
|
||||
FixedWidthPointer<Elf64_Sym> debug_symbols;
|
||||
} _PACKED;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern status_t boot_elf_resolve_symbol(struct preloaded_elf32_image *image,
|
||||
struct Elf32_Sym *symbol, addr_t *symbolAddress);
|
||||
extern status_t boot_elf_resolve_symbol(preloaded_elf32_image* image,
|
||||
struct Elf32_Sym* symbol, Elf32_Addr* symbolAddress);
|
||||
extern status_t boot_elf_resolve_symbol(preloaded_elf64_image* image,
|
||||
struct Elf64_Sym* symbol, Elf64_Addr* symbolAddress);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* KERNEL_BOOT_ELF_H */
|
||||
|
||||
Reference in New Issue
Block a user