IA64 support.
* Makefile.util.def (libgrubmods.a): Add grub-core/kern/ia64/dl_helper.c * configure.ac: Add ia64-efi target. Probe for __ia64_trampoline, __udivsi3, __umoddi3, __udivdi3, __divsi3, __modsi3, __umodsi3, __moddi3 and __divdi3 symbols. * gentpl.py: Add ia64_efi platform. Rename x86_efi to efi and Add ia64-efi. All users updated. * grub-core/Makefile.am: Set KERNEL_HEADER_FILES for ia64-efi. * grub-core/Makefile.core.def (kernel.img): Add compile flags for ia64. Remove kern/generic/rtc_get_time_ms.c on EFI. Add kern/ia64/efi/startup.S, kern/ia64/efi/init.c, kern/ia64/dl.c, kern/ia64/dl_helper.c on ia64-efi. Add kern/emu/cache.c on emu. (linux): Use on loader/ia64/efi/linux.c on ia64. * grub-core/gensymlist.sh (grub_register_exported_symbols): Check whether symbol is a function. * grub-core/kern/dl.c [GRUB_MACHINE_EMU]: Include sys/mman.h. (grub_symbol): New field 'isfunc'. (grub_dl_resolve_symbol): Return whole symbol rather than just address. (grub_dl_register_symbol): New argument 'isfunc'. All users updated. (grub_dl_load_segments): Place all sections into the same region. [__ia64__]: Create trampolines and got. [GRUB_MACHINE_EMU]: Call mprotect. (grub_dl_resolve_symbols): Resolve symbol type as well. [__ia64__]: Create function descriptors. * grub-core/kern/efi/efi.c (grub_get_rtc): Renamed to ... (grub_rtc_get_time_ms): ... this. Expressions simplified. (grub_get_rtc): New function. * grub-core/kern/emu/cache.c [__ia64__]: New file. * grub-core/kern/emu/cache.S: Renamed to ... * grub-core/kern/emu/cache_s.S: ... this. [__ia64__]: Add a nop. * grub-core/kern/emu/full.c (grub_arch_dl_get_tramp_got_size) [__ia64__]: New function. * grub-core/kern/emu/lite.c [__ia64__]: Include ../ia64/dl.c. * grub-core/kern/ia64/dl.c: New file. * grub-core/kern/ia64/dl_helper.c: Likewise. * grub-core/kern/ia64/efi/init.c: New file. * grub-core/kern/ia64/efi/startup.S: Likewise. * grub-core/lib/efi/halt.c [__ia64__]: Don't try acpi. * grub-core/lib/ia64/longjmp.S: New file (from glibc). * grub-core/lib/ia64/setjmp.S: Likewise (from glibc). * grub-core/lib/setjmp.S [__ia64__]: Include ./ia64/setjmp.S. * grub-core/loader/ia64/efi/linux.c: New file. * include/grub/dl.h (GRUB_MOD_NAME): Redefined using C rather than asm. (GRUB_MOD_DEP): Likewise. (grub_dl) [__ia64__]: New fields got and tramp. (grub_dl): New field 'base'. (grub_dl_register_symbol): New argument isfunc. All users updated. (GRUB_IA64_DL_TRAMP_ALIGN): New definition. (GRUB_IA64_DL_TRAMP_SIZE): Likewise. (GRUB_IA64_DL_GOT_ALIGN): Likewise. (grub_ia64_dl_get_tramp_got_size): New proto. (GRUB_ARCH_DL_TRAMP_ALIGN) [__ia64__]: Likewise (GRUB_ARCH_DL_GOT_ALIGN) [__ia64__]: Likewise (grub_arch_dl_get_tramp_got_size) [__ia64__]: Likewise * include/grub/efi/api.h: Skip call wrappers on ia64. * include/grub/efi/pe32.h (GRUB_PE32_MACHINE_IA64): New definition. * include/grub/efi/time.h (GRUB_TICKS_PER_SECOND): Change to 1000. * include/grub/elf.h (ELF_ST_INFO): New definition. * include/grub/ia64/efi/kernel.h: New file. * include/grub/ia64/efi/memory.h: Likewise. * include/grub/ia64/efi/time.h: Likewise. * include/grub/ia64/kernel.h: Likewise. * include/grub/ia64/setjmp.h: Likewise (from glibc). * include/grub/ia64/time.h: New file. * include/grub/ia64/types.h: Likewise. * include/grub/libgcc.h (__udivsi3, __umodsi3, __umoddi3, __udivdi3, __moddi3, __divdi3, __divsi3, __modsi3, __ia64_trampoline): New protos. * include/grub/offsets.h (GRUB_KERNEL_IA64_EFI_PREFIX): New definition. (GRUB_KERNEL_IA64_EFI_PREFIX_END): Likewise. * include/grub/types.h (PRIxGRUB_ADDR): Likewise. * util/grub-mkimage.c (image_target_desc): New field pe_target. All users updated. (EFI64_HEADER_SIZE): New definition. All users updated. (image_targets): Add ia64-efi. * util/grub-mkimagexx.c (relocate_symbols): New arguments jumpers and jumpers_addr. All users updated. Create function descriptors. (count_funcs): New function. (unaligned_uint32): New struct. (MASK20): New definition. (MASK19): Likewise. (MASKF21): Likewise. (add_value_to_slot_20b): New function. (add_value_to_slot_21_real): Likewise. (add_value_to_slot_21): Likewise. (ia64_kernel_trampoline): New struct. (nopm): New variable. (jump): Likewise. (make_trampoline): New function. (relocate_addresses): Handle ia64. (make_reloc_section): Likewise. (load_image): Likewise. Also-By: Robert Millan <rmh.grub@aybabtu.com> Also-By: Vladimir Serbinenko <phcoder@gmail.com>
This commit is contained in:
commit
32297d5ff7
39 changed files with 2526 additions and 124 deletions
|
@ -37,6 +37,10 @@
|
|||
#define GRUB_MODULES_MACHINE_READONLY
|
||||
#endif
|
||||
|
||||
#ifdef GRUB_MACHINE_EMU
|
||||
#include <sys/mman.h>
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
grub_dl_t grub_dl_head = 0;
|
||||
|
@ -86,6 +90,7 @@ struct grub_symbol
|
|||
struct grub_symbol *next;
|
||||
const char *name;
|
||||
void *addr;
|
||||
int isfunc;
|
||||
grub_dl_t mod; /* The module to which this symbol belongs. */
|
||||
};
|
||||
typedef struct grub_symbol *grub_symbol_t;
|
||||
|
@ -110,21 +115,22 @@ grub_symbol_hash (const char *s)
|
|||
|
||||
/* Resolve the symbol name NAME and return the address.
|
||||
Return NULL, if not found. */
|
||||
static void *
|
||||
static grub_symbol_t
|
||||
grub_dl_resolve_symbol (const char *name)
|
||||
{
|
||||
grub_symbol_t sym;
|
||||
|
||||
for (sym = grub_symtab[grub_symbol_hash (name)]; sym; sym = sym->next)
|
||||
if (grub_strcmp (sym->name, name) == 0)
|
||||
return sym->addr;
|
||||
return sym;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Register a symbol with the name NAME and the address ADDR. */
|
||||
grub_err_t
|
||||
grub_dl_register_symbol (const char *name, void *addr, grub_dl_t mod)
|
||||
grub_dl_register_symbol (const char *name, void *addr, int isfunc,
|
||||
grub_dl_t mod)
|
||||
{
|
||||
grub_symbol_t sym;
|
||||
unsigned k;
|
||||
|
@ -147,6 +153,7 @@ grub_dl_register_symbol (const char *name, void *addr, grub_dl_t mod)
|
|||
|
||||
sym->addr = addr;
|
||||
sym->mod = mod;
|
||||
sym->isfunc = isfunc;
|
||||
|
||||
k = grub_symbol_hash (name);
|
||||
sym->next = grub_symtab[k];
|
||||
|
@ -225,6 +232,48 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e)
|
|||
{
|
||||
unsigned i;
|
||||
Elf_Shdr *s;
|
||||
grub_size_t tsize = 0, talign = 1;
|
||||
#ifdef __ia64__
|
||||
grub_size_t tramp;
|
||||
grub_size_t got;
|
||||
#endif
|
||||
char *ptr;
|
||||
|
||||
for (i = 0, s = (Elf_Shdr *)((char *) e + e->e_shoff);
|
||||
i < e->e_shnum;
|
||||
i++, s = (Elf_Shdr *)((char *) s + e->e_shentsize))
|
||||
{
|
||||
tsize += ALIGN_UP (s->sh_size, s->sh_addralign);
|
||||
if (talign < s->sh_addralign)
|
||||
talign = s->sh_addralign;
|
||||
}
|
||||
|
||||
#ifdef __ia64__
|
||||
grub_arch_dl_get_tramp_got_size (e, &tramp, &got);
|
||||
tramp *= GRUB_IA64_DL_TRAMP_SIZE;
|
||||
got *= sizeof (grub_uint64_t);
|
||||
tsize += ALIGN_UP (tramp, GRUB_ARCH_DL_TRAMP_ALIGN);
|
||||
if (talign < GRUB_ARCH_DL_TRAMP_ALIGN)
|
||||
talign = GRUB_ARCH_DL_TRAMP_ALIGN;
|
||||
tsize += ALIGN_UP (got, GRUB_ARCH_DL_GOT_ALIGN);
|
||||
if (talign < GRUB_ARCH_DL_GOT_ALIGN)
|
||||
talign = GRUB_ARCH_DL_GOT_ALIGN;
|
||||
#endif
|
||||
|
||||
#ifdef GRUB_MACHINE_EMU
|
||||
if (talign < 8192 * 16)
|
||||
talign = 8192 * 16;
|
||||
tsize = ALIGN_UP (tsize, 8192 * 16);
|
||||
#endif
|
||||
|
||||
mod->base = grub_memalign (talign, tsize);
|
||||
if (!mod->base)
|
||||
return grub_errno;
|
||||
ptr = mod->base;
|
||||
|
||||
#ifdef GRUB_MACHINE_EMU
|
||||
mprotect (mod->base, tsize, PROT_READ | PROT_WRITE | PROT_EXEC);
|
||||
#endif
|
||||
|
||||
for (i = 0, s = (Elf_Shdr *)((char *) e + e->e_shoff);
|
||||
i < e->e_shnum;
|
||||
|
@ -242,12 +291,9 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e)
|
|||
{
|
||||
void *addr;
|
||||
|
||||
addr = grub_memalign (s->sh_addralign, s->sh_size);
|
||||
if (! addr)
|
||||
{
|
||||
grub_free (seg);
|
||||
return grub_errno;
|
||||
}
|
||||
ptr = (char *) ALIGN_UP ((grub_addr_t) ptr, s->sh_addralign);
|
||||
addr = ptr;
|
||||
ptr += s->sh_size;
|
||||
|
||||
switch (s->sh_type)
|
||||
{
|
||||
|
@ -270,6 +316,14 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e)
|
|||
mod->segment = seg;
|
||||
}
|
||||
}
|
||||
#ifdef __ia64__
|
||||
ptr = (char *) ALIGN_UP ((grub_addr_t) ptr, GRUB_ARCH_DL_TRAMP_ALIGN);
|
||||
mod->tramp = ptr;
|
||||
ptr += tramp;
|
||||
ptr = (char *) ALIGN_UP ((grub_addr_t) ptr, GRUB_ARCH_DL_GOT_ALIGN);
|
||||
mod->got = ptr;
|
||||
ptr += got;
|
||||
#endif
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
@ -320,17 +374,20 @@ grub_dl_resolve_symbols (grub_dl_t mod, Elf_Ehdr *e)
|
|||
/* Resolve a global symbol. */
|
||||
if (sym->st_name != 0 && sym->st_shndx == 0)
|
||||
{
|
||||
sym->st_value = (Elf_Addr) grub_dl_resolve_symbol (name);
|
||||
if (! sym->st_value)
|
||||
grub_symbol_t nsym = grub_dl_resolve_symbol (name);
|
||||
if (! nsym)
|
||||
return grub_error (GRUB_ERR_BAD_MODULE,
|
||||
"symbol not found: `%s'", name);
|
||||
sym->st_value = (Elf_Addr) nsym->addr;
|
||||
if (nsym->isfunc)
|
||||
sym->st_info = ELF_ST_INFO (bind, STT_FUNC);
|
||||
}
|
||||
else
|
||||
{
|
||||
sym->st_value += (Elf_Addr) grub_dl_get_section_addr (mod,
|
||||
sym->st_shndx);
|
||||
if (bind != STB_LOCAL)
|
||||
if (grub_dl_register_symbol (name, (void *) sym->st_value, mod))
|
||||
if (grub_dl_register_symbol (name, (void *) sym->st_value, 0, mod))
|
||||
return grub_errno;
|
||||
}
|
||||
break;
|
||||
|
@ -338,10 +395,21 @@ grub_dl_resolve_symbols (grub_dl_t mod, Elf_Ehdr *e)
|
|||
case STT_FUNC:
|
||||
sym->st_value += (Elf_Addr) grub_dl_get_section_addr (mod,
|
||||
sym->st_shndx);
|
||||
#ifdef __ia64__
|
||||
{
|
||||
/* FIXME: free descriptor once it's not used anymore. */
|
||||
char **desc;
|
||||
desc = grub_malloc (2 * sizeof (char *));
|
||||
if (!desc)
|
||||
return grub_errno;
|
||||
desc[0] = (void *) sym->st_value;
|
||||
desc[1] = mod->base;
|
||||
sym->st_value = (grub_addr_t) desc;
|
||||
}
|
||||
#endif
|
||||
if (bind != STB_LOCAL)
|
||||
if (grub_dl_register_symbol (name, (void *) sym->st_value, mod))
|
||||
if (grub_dl_register_symbol (name, (void *) sym->st_value, 1, mod))
|
||||
return grub_errno;
|
||||
|
||||
if (grub_strcmp (name, "grub_mod_init") == 0)
|
||||
mod->init = (void (*) (grub_dl_t)) sym->st_value;
|
||||
else if (grub_strcmp (name, "grub_mod_fini") == 0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue