Switch to -fPIC.
authorwhitequark <whitequark@whitequark.org>
Sun, 26 Jul 2015 13:06:48 +0000 (16:06 +0300)
committerwhitequark <whitequark@whitequark.org>
Sun, 26 Jul 2015 13:06:48 +0000 (16:06 +0300)
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
software/bios/linker.ld
software/common.mak
software/libbase/crt0-or1k.S

index 256612f02f26f2cc0739613220d4baed188bf4a4..e3ce49ed7f658bed201cdd920e76be4b3fb43cce 100644 (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):
index 59960b7c381846189de1dc7748785264a1692b2c..90a7d2b7c729e9f979e91b154a3810061ecb67f9 100644 (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);
index b345bee3f04789860dd3d18f0fd667f79ae55f4b..0b637c100f7f0f897eece1fe32933308908d30e6 100644 (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
index 248b277f58c540c848f2a468b7a2a4c2e8efd9c2..0c405925089d7c866923455d94faef7d27e09ff9 100644 (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)