Support ELF64 in the kernel.

This has been done by adding typedefs in elf_common.h to the correct ELF
structures for the architecture, and changing all Elf32_* uses to those
types. I don't know whether image loading works as I cannot test it yet,
there may be some 64-bit safety issues around. However, symbol lookup for
the kernel is working correctly.
This commit is contained in:
Alex Smith
2012-07-09 11:11:38 +01:00
parent bc3093488f
commit 3b802628b8
12 changed files with 287 additions and 277 deletions
+6
View File
@@ -89,6 +89,7 @@ struct Elf32_Sym {
#ifdef __cplusplus
uint8 Bind() const;
uint8 Type() const;
void SetInfo(uint8 bind, uint8 type);
#endif
};
@@ -218,6 +219,11 @@ Elf32_Sym::Type() const
return ELF32_ST_TYPE(st_info);
}
inline void
Elf32_Sym::SetInfo(uint8 bind, uint8 type)
{
st_info = ELF32_ST_INFO(bind, type);
}
inline uint8
Elf32_Rel::SymbolIndex() const
+8
View File
@@ -91,6 +91,7 @@ struct Elf64_Sym {
#ifdef __cplusplus
uint8 Bind() const;
uint8 Type() const;
void SetInfo(uint8 bind, uint8 type);
#endif
};
@@ -221,6 +222,13 @@ Elf64_Sym::Type() const
}
inline void
Elf64_Sym::SetInfo(uint8 bind, uint8 type)
{
st_info = ELF64_ST_INFO(bind, type);
}
inline uint8
Elf64_Rel::SymbolIndex() const
{
+35
View File
@@ -263,4 +263,39 @@
#define VER_FLG_WEAK 0x2 /* weak version identifier */
// Determine the correct ELF types to use for the architecture
#if B_HAIKU_64_BIT
# define _ELF_TYPE(type) Elf64_##type
#else
# define _ELF_TYPE(type) Elf32_##type
#endif
#define DEFINE_ELF_TYPE(type, name) \
struct _ELF_TYPE(type); \
typedef _ELF_TYPE(type) name
DEFINE_ELF_TYPE(Ehdr, elf_ehdr);
DEFINE_ELF_TYPE(Phdr, elf_phdr);
DEFINE_ELF_TYPE(Shdr, elf_shdr);
DEFINE_ELF_TYPE(Sym, elf_sym);
DEFINE_ELF_TYPE(Dyn, elf_dyn);
DEFINE_ELF_TYPE(Rel, elf_rel);
DEFINE_ELF_TYPE(Rela, elf_rela);
DEFINE_ELF_TYPE(Verdef, elf_verdef);
DEFINE_ELF_TYPE(Verdaux, elf_verdaux);
DEFINE_ELF_TYPE(Verneed, elf_verneed);
DEFINE_ELF_TYPE(Vernaux, elf_vernaux);
#undef DEFINE_ELF_TYPE
#undef _ELF_TYPE
typedef uint16 elf_versym;
#if B_HAIKU_64_BIT
# define ELF_CLASS ELFCLASS64
#else
# define ELF_CLASS ELFCLASS32
#endif
#endif /* _ELF_COMMON_H_ */