mirror of
https://github.com/aolofsson/oh.git
synced 2025-01-30 02:32:53 +08:00
Customizing linker file per architecture
This commit is contained in:
parent
6b01f16935
commit
099b9527e3
@ -25,38 +25,59 @@ ELF = sys.argv[3]
|
|||||||
|
|
||||||
LINKERSCRIPT="tmp.ld"
|
LINKERSCRIPT="tmp.ld"
|
||||||
|
|
||||||
if(ARCH=="riscv64"):
|
if(ARCH=="rv32i"):
|
||||||
GCCROOT=ARCH + "-unknown-elf-"
|
GCC="riscv64-unknown-elf-gcc -march=rv32i -mabi=ilp32"
|
||||||
|
GCCOPT=" -static -mcmodel=medany -fvisibility=hidden -nostdlib -nostartfiles"
|
||||||
OUTPUT="riscv"
|
OUTPUT="riscv"
|
||||||
else:
|
else:
|
||||||
GCCROOT="e-"
|
GCC="e-gcc"
|
||||||
|
GCCOPT=" -static -fvisibility=hidden -nostdlib -nostartfiles"
|
||||||
OUTPUT="epiphany"
|
OUTPUT="epiphany"
|
||||||
|
|
||||||
#############################################
|
#############################################
|
||||||
#PRINT LINKER FILE
|
#PRINT LINKER FILE
|
||||||
f=open("tmp.ld",'w')
|
f=open("tmp.ld",'w')
|
||||||
f.write("""OUTPUT_ARCH( "riscv" )
|
f.write("OUTPUT_ARCH( \"" + OUTPUT + "\" )\n")
|
||||||
ENTRY(_start)
|
if(ARCH=="rv32i"):
|
||||||
|
f.write("""ENTRY(_start)
|
||||||
SECTIONS
|
SECTIONS
|
||||||
{
|
{
|
||||||
. = 0x00000000;
|
. = 0x80000000;
|
||||||
.text.init : { *(.text.init) }
|
.text.trap : { *(.text.trap) }
|
||||||
. = ALIGN(0x1000);
|
|
||||||
.tohost : { *(.tohost) }
|
. = 0x00000000;
|
||||||
. = ALIGN(0x1000);
|
.text.init : { *(.text.init) }
|
||||||
.text : { *(.text) }
|
|
||||||
. = ALIGN(0x1000);
|
. = ALIGN(0x1000);
|
||||||
.data : { *(.data) }
|
.tohost : { *(.tohost) }
|
||||||
.bss : { *(.bss) }
|
. = ALIGN(0x1000);
|
||||||
_end = .;
|
.text : { *(.text) }
|
||||||
}""")
|
. = ALIGN(0x1000);
|
||||||
|
.data : { *(.data) }
|
||||||
|
.data.string : { *(.data.string)}
|
||||||
|
.bss : { *(.bss) }
|
||||||
|
_end = .;
|
||||||
|
}""")
|
||||||
|
else:
|
||||||
|
f.write("""ENTRY(_start)
|
||||||
|
SECTIONS
|
||||||
|
{
|
||||||
|
. = 0x00000000;
|
||||||
|
.text.init : { *(.text.init) }
|
||||||
|
. = ALIGN(0x1000);
|
||||||
|
.tohost : { *(.tohost) }
|
||||||
|
. = ALIGN(0x1000);
|
||||||
|
.text : { *(.text) }
|
||||||
|
. = ALIGN(0x1000);
|
||||||
|
.data : { *(.data) }
|
||||||
|
.bss : { *(.bss) }
|
||||||
|
_end = .;
|
||||||
|
}""")
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
#############################################
|
#############################################
|
||||||
#RUN GCC
|
#RUN GCC
|
||||||
CMD=GCCROOT + "gcc -static -mcmodel=medany -fvisibility=hidden -nostdlib -nostartfiles" + " -T" + LINKERSCRIPT + " -o " + ELF + " " + ASM
|
CMD = GCC + GCCOPT + " -T" + LINKERSCRIPT + " -o " + ELF + " " + ASM
|
||||||
print(CMD)
|
print(CMD)
|
||||||
os.system(CMD)
|
os.system(CMD)
|
||||||
|
|
||||||
@ -64,5 +85,3 @@ os.system(CMD)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user