arm/arm64: Fix improper use of start address.

It was used instead of loading address of current section or of entire buffer.
This commit is contained in:
Vladimir Serbinenko 2017-02-01 20:12:07 +01:00
parent ea20dd2b22
commit 43b444e593

View file

@ -50,8 +50,6 @@
#pragma GCC diagnostic ignored "-Wcast-align" #pragma GCC diagnostic ignored "-Wcast-align"
static Elf_Addr SUFFIX (entry_point);
/* These structures are defined according to the CHRP binding to IEEE1275, /* These structures are defined according to the CHRP binding to IEEE1275,
"Client Program Format" section. */ "Client Program Format" section. */
@ -979,7 +977,7 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections,
case R_AARCH64_CALL26: case R_AARCH64_CALL26:
{ {
sym_addr -= offset; sym_addr -= offset;
sym_addr -= SUFFIX (entry_point); sym_addr -= target_section_addr + image_target->vaddr_offset;
if (!grub_arm_64_check_xxxx26_offset (sym_addr)) if (!grub_arm_64_check_xxxx26_offset (sym_addr))
grub_util_error ("%s", "CALL26 Relocation out of range"); grub_util_error ("%s", "CALL26 Relocation out of range");
@ -990,7 +988,7 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections,
case R_AARCH64_ADR_PREL_PG_HI21: case R_AARCH64_ADR_PREL_PG_HI21:
{ {
sym_addr &= ~0xfffULL; sym_addr &= ~0xfffULL;
sym_addr -= (offset + SUFFIX (entry_point)) & ~0xfffULL; sym_addr -= (offset + target_section_addr + image_target->vaddr_offset) & ~0xfffULL;
if (!grub_arm64_check_hi21_signed (sym_addr)) if (!grub_arm64_check_hi21_signed (sym_addr))
grub_util_error ("%s", "CALL26 Relocation out of range"); grub_util_error ("%s", "CALL26 Relocation out of range");
@ -1010,7 +1008,7 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections,
case EM_ARM: case EM_ARM:
{ {
sym_addr += addend; sym_addr += addend;
sym_addr -= SUFFIX (entry_point); sym_addr -= image_target->vaddr_offset;
switch (ELF_R_TYPE (info)) switch (ELF_R_TYPE (info))
{ {
case R_ARM_ABS32: case R_ARM_ABS32:
@ -1974,8 +1972,6 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path,
if (layout->start_address == (Elf_Addr) -1) if (layout->start_address == (Elf_Addr) -1)
grub_util_error ("start symbol is not defined"); grub_util_error ("start symbol is not defined");
SUFFIX (entry_point) = (Elf_Addr) layout->start_address;
/* Resolve addresses in the virtual address space. */ /* Resolve addresses in the virtual address space. */
SUFFIX (relocate_addresses) (e, sections, section_addresses, SUFFIX (relocate_addresses) (e, sections, section_addresses,
section_entsize, section_entsize,