2009-07-01 Pavel Roskin <proski@gnu.org>

* include/grub/elf.h: Define Elf_Sword and Elf_Xword.
	* kern/i386/dl.c: Use ELF symbols without "32" or "64".
	* kern/powerpc/dl.c: Likewise.
	* kern/sparc64/dl.c: Likewise.
	* kern/x86_64/dl.c: Likewise.
This commit is contained in:
proski 2009-07-01 14:49:22 +00:00
parent 3f7f0cd003
commit 3262295617
6 changed files with 76 additions and 64 deletions

View file

@ -26,7 +26,7 @@
grub_err_t
grub_arch_dl_check_header (void *ehdr)
{
Elf32_Ehdr *e = ehdr;
Elf_Ehdr *e = ehdr;
/* Check the magic numbers. */
if (e->e_ident[EI_CLASS] != ELFCLASS32
@ -41,15 +41,15 @@ grub_arch_dl_check_header (void *ehdr)
grub_err_t
grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
{
Elf32_Ehdr *e = ehdr;
Elf32_Shdr *s;
Elf32_Word entsize;
Elf_Ehdr *e = ehdr;
Elf_Shdr *s;
Elf_Word entsize;
unsigned i;
/* Find a symbol table. */
for (i = 0, s = (Elf32_Shdr *) ((char *) e + e->e_shoff);
for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff);
i < e->e_shnum;
i++, s = (Elf32_Shdr *) ((char *) s + e->e_shentsize))
i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize))
if (s->sh_type == SHT_SYMTAB)
break;
@ -58,9 +58,9 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
entsize = s->sh_entsize;
for (i = 0, s = (Elf32_Shdr *) ((char *) e + e->e_shoff);
for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff);
i < e->e_shnum;
i++, s = (Elf32_Shdr *) ((char *) s + e->e_shentsize))
i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize))
if (s->sh_type == SHT_REL)
{
grub_dl_segment_t seg;
@ -72,32 +72,32 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
if (seg)
{
Elf32_Rel *rel, *max;
Elf_Rel *rel, *max;
for (rel = (Elf32_Rel *) ((char *) e + s->sh_offset),
for (rel = (Elf_Rel *) ((char *) e + s->sh_offset),
max = rel + s->sh_size / s->sh_entsize;
rel < max;
rel++)
{
Elf32_Word *addr;
Elf32_Sym *sym;
Elf_Word *addr;
Elf_Sym *sym;
if (seg->size < rel->r_offset)
return grub_error (GRUB_ERR_BAD_MODULE,
"reloc offset is out of the segment");
addr = (Elf32_Word *) ((char *) seg->addr + rel->r_offset);
sym = (Elf32_Sym *) ((char *) mod->symtab
+ entsize * ELF32_R_SYM (rel->r_info));
addr = (Elf_Word *) ((char *) seg->addr + rel->r_offset);
sym = (Elf_Sym *) ((char *) mod->symtab
+ entsize * ELF_R_SYM (rel->r_info));
switch (ELF32_R_TYPE (rel->r_info))
switch (ELF_R_TYPE (rel->r_info))
{
case R_386_32:
*addr += sym->st_value;
break;
case R_386_PC32:
*addr += (sym->st_value - (Elf32_Word) seg->addr
*addr += (sym->st_value - (Elf_Word) seg->addr
- rel->r_offset);
break;
}