ppc: avoid runtime relocations

Because the sizes of cells and pointers do not match on PPC64,
relocations of an ucell array using the address of the array itself
can't be computed by the linker.

Use a fixed address on PPC64 for the array, so we can use a fixed
ucell sized constant for the relocation offset.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>

git-svn-id: svn://coreboot.org/openbios/trunk/openbios-devel@1018 f158a5a8-5612-0410-a976-696ce0be7e32
This commit is contained in:
Blue Swirl 2011-01-30 13:07:40 +00:00
parent eab38f07b6
commit 132b7dcb95
4 changed files with 27 additions and 11 deletions

View File

@ -60,11 +60,7 @@
<executable name="target/include/qemu-dict.h" target="target" condition="QEMU">
<rule><![CDATA[
$(call quiet-command,true, " GEN $(TARGET_DIR)$@")
@echo "static const char forth_dictionary[] = {" > $@
@cat $< | hexdump -ve '1/0 "\t" 8/1 "0x%02x, " 1/0 "\n"' \
| sed 's/0x ,//g' >> $@
@echo "};" >> $@]]></rule>
$(call quiet-command,$(ODIR)/forthstrap -x -D $@ -d $< </dev/null, " GEN $(TARGET_DIR)$@")]]></rule>
<external-object source="openbios-qemu.dict"/>
</executable>

View File

@ -17,7 +17,6 @@
*
*/
#include "qemu-dict.h"
#include "config.h"
#include "dict.h"
#include "libopenbios/bindings.h"
@ -27,7 +26,19 @@
#include "kernel.h"
#define MEMORY_SIZE (256*1024) /* 256K ram for hosted system */
#define DICTIONARY_SIZE (512*1024) /* 512K for the dictionary */
/* 512K for the dictionary */
#define DICTIONARY_SIZE (512 * 1024 / sizeof(ucell))
#ifdef __powerpc64__
#define DICTIONARY_BASE 0xfff08000 /* this must match the value in ldscript! */
#define DICTIONARY_SECTION __attribute__((section(".data.dict")))
#else
#define DICTIONARY_BASE ((ucell)((char *)&forth_dictionary))
#define DICTIONARY_SECTION
#endif
static ucell forth_dictionary[DICTIONARY_SIZE] DICTIONARY_SECTION = {
#include "qemu-dict.h"
};
static ucell *memory;
@ -82,10 +93,12 @@ init_memory( void )
int
initialize_forth( void )
{
dict = malloc(DICTIONARY_SIZE);
dictlimit = DICTIONARY_SIZE;
dict = (unsigned char *)forth_dictionary;
dicthead = (ucell)FORTH_DICTIONARY_END;
last = (ucell *)((unsigned char *)forth_dictionary +
FORTH_DICTIONARY_LAST);
dictlimit = sizeof(forth_dictionary);
load_dictionary( forth_dictionary, sizeof(forth_dictionary) );
forth_init();
PUSH_xt( bind_noname_func(arch_of_init) );

View File

@ -55,7 +55,7 @@ extern void setup_mmu(unsigned long code_base);
#define HASH_BITS 15
#endif
#define HASH_SIZE (2 << HASH_BITS)
#define OFMEM_SIZE (2 * 1024 * 1024)
#define OFMEM_SIZE (1 * 1024 * 1024 + 512 * 1024)
#define SEGR_USER BIT(2)
#define SEGR_BASE 0x0400

View File

@ -6,6 +6,7 @@ OUTPUT_ARCH(powerpc:common64)
BASE_ADDR = 0xfff00000;
/* As NVRAM is at 0xfff04000, the .text needs to be after that
* The value in arch/ppc/qemu/kernel.c must match this value!
*/
TEXT_ADDR = 0xfff08000;
@ -26,6 +27,12 @@ SECTIONS
. = TEXT_ADDR;
/* Normal sections */
.data.dict ALIGN(4096): {
_dict_start = .;
*(.data.dict)
_dict_end = .;
}
.text ALIGN(4096): {
*(.text)
*(.text.*)