From c8ffd0c9eecadfd7e3e8ede16b58f2b6b2cda7b2 Mon Sep 17 00:00:00 2001 From: whitequark Date: Sun, 26 Jul 2015 16:06:48 +0300 Subject: [PATCH] Switch to -fPIC. Using -fPIC for everything allows to link the MiSoC static libraries both into static images such as the BIOS as well as into shared libraries. --- misoclib/soc/cpuif.py | 8 ++++++-- software/bios/linker.ld | 18 +++++++++++++++++- software/common.mak | 3 +-- software/libbase/crt0-or1k.S | 4 ---- 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/misoclib/soc/cpuif.py b/misoclib/soc/cpuif.py index 256612f0..e3ce49ed 100644 --- a/misoclib/soc/cpuif.py +++ b/misoclib/soc/cpuif.py @@ -4,12 +4,16 @@ from migen.bank.description import CSRStatus def get_cpu_mak(cpu_type): if cpu_type == "lm32": + triple = "lm32-elf" cpuflags = "-mbarrel-shift-enabled -mmultiply-enabled -mdivide-enabled -msign-extend-enabled" + clang = "" elif cpu_type == "or1k": - cpuflags = "-mhard-mul -mhard-div" + triple = "or1k-linux" + cpuflags = "-fPIC -mhard-mul -mhard-div" + clang = "1" else: raise ValueError("Unsupported CPU type: "+cpu_type) - return "CPU={}\nCPUFLAGS={}\n".format(cpu_type, cpuflags) + return "TRIPLE={}\nCPU={}\nCPUFLAGS={}\nCLANG={}".format(triple, cpu_type, cpuflags, clang) def get_linker_output_format(cpu_type): diff --git a/software/bios/linker.ld b/software/bios/linker.ld index 59960b7c..90a7d2b7 100644 --- a/software/bios/linker.ld +++ b/software/bios/linker.ld @@ -14,6 +14,17 @@ SECTIONS _etext = .; } > rom + .got : + { + _GLOBAL_OFFSET_TABLE_ = .; + *(.got) + } > rom + + .got.plt : + { + *(.got.plt) + } > rom + .rodata : { . = ALIGN(4); @@ -30,7 +41,6 @@ SECTIONS _fdata = .; *(.data .data.* .gnu.linkonce.d.*) *(.data1) - _gp = ALIGN(16); *(.sdata .sdata.* .gnu.linkonce.s.*) _edata = .; } > rom @@ -49,6 +59,12 @@ SECTIONS _ebss = .; _end = .; } > sram + + /DISCARD/ : + { + *(.eh_frame) + *(.comment) + } } PROVIDE(_fstack = ORIGIN(sram) + LENGTH(sram) - 4); diff --git a/software/common.mak b/software/common.mak index b345bee3..0b637c10 100644 --- a/software/common.mak +++ b/software/common.mak @@ -1,10 +1,9 @@ include $(MSCDIR)/software/include/generated/cpu.mak -TRIPLE=$(CPU)-elf TARGET_PREFIX=$(TRIPLE)- RM ?= rm -f -ifeq ($(CPU),or1k) +ifeq ($(CLANG),1) CC_normal := clang -target $(TRIPLE) CX_normal := clang++ -target $(TRIPLE) else diff --git a/software/libbase/crt0-or1k.S b/software/libbase/crt0-or1k.S index 248b277f..0c405925 100644 --- a/software/libbase/crt0-or1k.S +++ b/software/libbase/crt0-or1k.S @@ -141,10 +141,6 @@ _crt0: /* Setup stack and global pointer */ l.movhi r1, hi(_fstack) l.ori r1, r1, lo(_fstack) -/* - l.movhi r16, hi(_gp) - l.ori r16, gp, lo(_gp) -*/ /* Clear BSS */ l.movhi r21, hi(_fbss) -- 2.30.2