vxBoot - 1.2.4 : Fix relocation for non 4-aligned symbols' offset
@fix <> CMakelist.txt : | dump project version <> loader/elf/rela : | fix exception when the relocalised symbols are not in a 4-aligned address
This commit is contained in:
parent
b2d432fcee
commit
41d8b2a505
|
@ -1,5 +1,5 @@
|
|||
cmake_minimum_required(VERSION 3.15)
|
||||
project(vxBoot VERSION 1.2.3 LANGUAGES C)
|
||||
project(vxBoot VERSION 1.2.4 LANGUAGES C)
|
||||
|
||||
include(GenerateG1A)
|
||||
include(GenerateG3A)
|
||||
|
|
|
@ -65,7 +65,7 @@ static int loader_reloc_section(
|
|||
/* logs */
|
||||
terminal_log(
|
||||
LOG_INFO,
|
||||
" section '%s' with %d entries\n",
|
||||
" > '%s' (%d)...",
|
||||
name, nb_rela
|
||||
);
|
||||
|
||||
|
@ -85,7 +85,10 @@ static int loader_reloc_section(
|
|||
break;
|
||||
}
|
||||
if (type < 0) {
|
||||
terminal_write("unable to relocalize symbols %d\n", i);
|
||||
terminal_log(
|
||||
LOG_ALERT,
|
||||
"\nunable to relocalize symbols %d\n", i
|
||||
);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
|
@ -104,7 +107,10 @@ static int loader_reloc_section(
|
|||
virtual address is set. So, for now, we just need to add the
|
||||
relocation offset to the content of the location. */
|
||||
//val = kernel->elf.sym.tab[ELF32_R_SYM(rela[i].r_info)].st_value;
|
||||
val = *(uintptr_t*)loc;
|
||||
val = (((uint8_t*)loc)[0] << 24);
|
||||
val |= (((uint8_t*)loc)[1] << 16);
|
||||
val |= (((uint8_t*)loc)[2] << 8);
|
||||
val |= (((uint8_t*)loc)[3] << 0);
|
||||
|
||||
switch (table[type].id) {
|
||||
case R_SH_GOT32:
|
||||
|
@ -113,14 +119,19 @@ static int loader_reloc_section(
|
|||
case R_SH_GOTOFF:
|
||||
break;
|
||||
case R_SH_DIR32:
|
||||
//terminal_log(
|
||||
// LOG_DEBUG,
|
||||
// " %08x %-8s %08x\n",
|
||||
// rela[i].r_offset,
|
||||
// table[type].name,
|
||||
// val
|
||||
//);
|
||||
*(uintptr_t *)loc = voff + val;
|
||||
terminal_log(
|
||||
LOG_DEBUG,
|
||||
" %08x %-8s %08x %d %d",
|
||||
rela[i].r_offset,
|
||||
table[type].name,
|
||||
val,
|
||||
rela[i].r_addend, type
|
||||
);
|
||||
val += voff;
|
||||
((uint8_t *)loc)[0] = (val & 0xff000000) >> 24;
|
||||
((uint8_t *)loc)[1] = (val & 0x00ff0000) >> 16;
|
||||
((uint8_t *)loc)[2] = (val & 0x0000ff00) >> 8;
|
||||
((uint8_t *)loc)[3] = (val & 0x000000ff) >> 0;
|
||||
break;
|
||||
default:
|
||||
terminal_log(
|
||||
|
@ -131,6 +142,8 @@ static int loader_reloc_section(
|
|||
return (-1);
|
||||
}
|
||||
}
|
||||
|
||||
terminal_log(LOG_INFO, "OK\n");
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue