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.
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):
_etext = .;
} > rom
+ .got :
+ {
+ _GLOBAL_OFFSET_TABLE_ = .;
+ *(.got)
+ } > rom
+
+ .got.plt :
+ {
+ *(.got.plt)
+ } > rom
+
.rodata :
{
. = ALIGN(4);
_fdata = .;
*(.data .data.* .gnu.linkonce.d.*)
*(.data1)
- _gp = ALIGN(16);
*(.sdata .sdata.* .gnu.linkonce.s.*)
_edata = .;
} > rom
_ebss = .;
_end = .;
} > sram
+
+ /DISCARD/ :
+ {
+ *(.eh_frame)
+ *(.comment)
+ }
}
PROVIDE(_fstack = ORIGIN(sram) + LENGTH(sram) - 4);
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
/* 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)