Skip to content

Commit

Permalink
Switch to -fPIC.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
whitequark committed Jul 26, 2015
1 parent a8cd3b9 commit c8ffd0c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
8 changes: 6 additions & 2 deletions misoclib/soc/cpuif.py
Expand Up @@ -4,12 +4,16 @@

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):
Expand Down
18 changes: 17 additions & 1 deletion software/bios/linker.ld
Expand Up @@ -14,6 +14,17 @@ SECTIONS
_etext = .;
} > rom

.got :
{
_GLOBAL_OFFSET_TABLE_ = .;
*(.got)
} > rom

.got.plt :
{
*(.got.plt)
} > rom

.rodata :
{
. = ALIGN(4);
Expand All @@ -30,7 +41,6 @@ SECTIONS
_fdata = .;
*(.data .data.* .gnu.linkonce.d.*)
*(.data1)
_gp = ALIGN(16);
*(.sdata .sdata.* .gnu.linkonce.s.*)
_edata = .;
} > rom
Expand All @@ -49,6 +59,12 @@ SECTIONS
_ebss = .;
_end = .;
} > sram

/DISCARD/ :
{
*(.eh_frame)
*(.comment)
}
}

PROVIDE(_fstack = ORIGIN(sram) + LENGTH(sram) - 4);
3 changes: 1 addition & 2 deletions 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
Expand Down
4 changes: 0 additions & 4 deletions software/libbase/crt0-or1k.S
Expand Up @@ -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)
Expand Down

0 comments on commit c8ffd0c

Please sign in to comment.