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(a)gmail.com>
---
arch/ppc/build.xml | 6 +-----
arch/ppc/qemu/kernel.c | 23 ++++++++++++++++++-----
arch/ppc/qemu/ofmem.c | 2 +-
arch/ppc64/qemu/ldscript | 7 +++++++
4 files changed, 27 insertions(+), 11 deletions(-)
diff --git a/arch/ppc/build.xml b/arch/ppc/build.xml
index 4aec62f..8468799 100644
--- a/arch/ppc/build.xml
+++ b/arch/ppc/build.xml
@@ -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>
diff --git a/arch/ppc/qemu/kernel.c b/arch/ppc/qemu/kernel.c
index 4cae525..b26fba5 100644
--- a/arch/ppc/qemu/kernel.c
+++ b/arch/ppc/qemu/kernel.c
@@ -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) );
diff --git a/arch/ppc/qemu/ofmem.c b/arch/ppc/qemu/ofmem.c
index 4c6825e..f6cf8cd 100644
--- a/arch/ppc/qemu/ofmem.c
+++ b/arch/ppc/qemu/ofmem.c
@@ -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
diff --git a/arch/ppc64/qemu/ldscript b/arch/ppc64/qemu/ldscript
index 7a22903..fbbcc54 100644
--- a/arch/ppc64/qemu/ldscript
+++ b/arch/ppc64/qemu/ldscript
@@ -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.*)
--
1.6.2.4