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.
This commit is contained in:
whitequark 2015-07-26 16:06:48 +03:00
parent a8cd3b9adc
commit c8ffd0c9ee
4 changed files with 24 additions and 9 deletions

View file

@ -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):

View file

@ -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);

View file

@ -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

View file

@ -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)