deal with odd-address errors:

handle non-aligned relocations
make sure .init/.fini sections are aligned
This commit is contained in:
Wolfgang Thaller 2012-04-03 10:57:27 +02:00
parent 69ecf7f5e0
commit 012f491d4e
2 changed files with 14 additions and 2 deletions

View File

@ -24,6 +24,7 @@ SECTIONS {
*(.glue_7t)
*(.glue_7)
*(.jcr)
. = ALIGN (4) ;
@SYMBOL_PREFIX@__init_section = . ;
KEEP (*(.init))
@SYMBOL_PREFIX@__init_section_end = . ;

View File

@ -1,3 +1,5 @@
#include <stdint.h>
#include <Processes.h>
#include <Sound.h>
#include <Memory.h>
@ -60,8 +62,17 @@ void _start()
for(i = 0; i < n; i++)
{
long *addr = (long*)(relocs[i] + displacement);
*addr += (*addr >= data_end ? bss_displacement : displacement);
uint8_t *addrPtr = (uint8_t*)(relocs[i] + displacement);
long addr;
addr = (addrPtr[0] << 24) | (addrPtr[1] << 16) | (addrPtr[2] << 8) | addrPtr[3];
addr += addr >= data_end ? bss_displacement : displacement;
addrPtr[0] = addr >> 24;
addrPtr[1] = addr >> 16;
addrPtr[2] = addr >> 8;
addrPtr[3] = addr;
}
/* {