/* Load runtime image of EFIemu. Functions specific to 32/64-bit mode */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2009 Free Software Foundation, Inc.
*
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
/* ELF symbols and their values */
static int grub_efiemu_nelfsyms = 0;
/* Return the address of a section whose index is N. */
static grub_err_t
{
{
return GRUB_ERR_NONE;
}
}
{
grub_efiemu_elfsyms = 0;
return GRUB_ERR_NONE;
}
/* Check if EHDR is a valid ELF header. */
int
{
/* Check the header size. */
return 0;
/* Check the magic numbers. */
|| e->e_version != EV_CURRENT)
return 0;
return 1;
}
/* Load all segments from memory specified by E. */
static grub_err_t
{
Elf_Shdr *s;
{
{
void *addr;
switch (s->sh_type)
{
case SHT_PROGBITS:
break;
case SHT_NOBITS:
break;
}
}
}
return GRUB_ERR_NONE;
}
/* Get a string at offset OFFSET from strtab */
static char *
{
unsigned i;
Elf_Shdr *s;
i < e->e_shnum;
i++, s = (Elf_Shdr *)((char *) s + e->e_shentsize))
return 0;
}
/* Request memory for segments and fill segments info */
static grub_err_t
{
unsigned i;
Elf_Shdr *s;
i < e->e_shnum;
i++, s = (Elf_Shdr *)((char *) s + e->e_shentsize))
{
{
if (! seg)
return grub_errno;
if (s->sh_size)
{
(s->sh_addralign, s->sh_size,
return grub_errno;
}
/*
.text-physical doesn't need to be relocated when switching to
virtual mode
*/
".text-physical"))
seg->ptv_rel_needed = 0;
else
}
}
return GRUB_ERR_NONE;
}
static grub_err_t
{
unsigned i;
Elf_Shdr *s;
int num = 0;
/* Symbols */
i < e->e_shnum;
i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize))
if (s->sh_type == SHT_SYMTAB)
break;
if (i == e->e_shnum)
grub_efiemu_elfsyms = (struct grub_efiemu_elf_sym *)
/* Relocators */
i < e->e_shnum;
i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize))
return GRUB_ERR_NONE;
}
/* Fill grub_efiemu_elfsyms with symbol values */
static grub_err_t
{
unsigned i;
Elf_Shdr *s;
const char *str;
i < e->e_shnum;
i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize))
if (s->sh_type == SHT_SYMTAB)
break;
if (i == e->e_shnum)
entsize = s->sh_entsize;
for (i = 0;
{
int handle;
switch (type)
{
case STT_NOTYPE:
/* Resolve a global symbol. */
{
return err;
}
else
break;
case STT_OBJECT:
if ((err = grub_efiemu_get_section_addr
return err;
return err;
break;
case STT_FUNC:
if ((err = grub_efiemu_get_section_addr
return err;
return err;
break;
case STT_SECTION:
if ((err = grub_efiemu_get_section_addr
{
grub_efiemu_elfsyms[i].handle = 0;
grub_efiemu_elfsyms[i].off = 0;
break;
}
break;
case STT_FILE:
grub_efiemu_elfsyms[i].handle = 0;
grub_efiemu_elfsyms[i].off = 0;
break;
default:
return grub_error (GRUB_ERR_BAD_MODULE,
"unknown symbol type `%d'", (int) type);
}
}
return GRUB_ERR_NONE;
}
/* Load runtime to the memory and request memory for definitive location*/
{
/* Make sure that every section is within the core. */
return err;
return err;
return GRUB_ERR_NONE;
}
/* Load runtime definitively */
__attribute__ ((unused)),
{
if (err)
return err;
if (err)
return err;
core);
if (err)
return err;
return GRUB_ERR_NONE;
}