tar xzvf binutils-2.18 cd binutils-2.18 ./configure --target=sh-hitachi-elf --prefix=/usr/local/sh make make install cd .. tar xzvf gcc-4.3.2.tar.gz tar xzvf newlib-1.16.0.tar.gz mkdir objs2 cd objs2 ../gcc-4.3.2/configure --target=sh-hitachi-elf --prefix=/usr/local/sh --with-newlib --enable-languages=c,c++ --with-headers=../newlib-1.15.0/newlib/libc/include/ make install cd .. mkdir objNewLib cd objNewLib PATH=$PATH:/usr/local/sh/bin/ ../newlib-1.16.0/configure --target=sh-hitachi-elf --prefix=/usr/local/sh make install |
TARGET=main.mot TARGET_ELF=main.elf PREFIX=/usr/local/sh/bin/sh-hitachi-elf AS=gcc.exe # ld として gcc を使うと、余計な物ばかりリンクされてしまう #LD=gcc.exe LD=ld.exe CC=gcc.exe ASFLAGS= -c -Wa,--gstabs -m2 OBJCOPY=objcopy.exe # # -m2 : SH2 # # -mb : big endian # -ml : little endian # #CFLAGS= -c -x c -g -m2 -mb --save-temps CFLAGS= -c -x c -m2 -mb --save-temps #LDFLAGS= --Wl,-tmain.lds,-Mmain.Map LDFLAGS= -t main.lds -Map main.Map OBJCOPYFLAGS=-O srec --srec-forceS3 -S --strip-debug -R .bss -R .common -R .stack OBJS= boot.o \ main.o \ .SUFFIXES: .c .o .s .o .c.o: $(PREFIX)-$(CC) $(CFLAGS) $< -o $@ .s.o: $(PREFIX)-$(AS) $(ASFLAGS) $< -o $@ all : $(TARGET) $(TARGET) : $(TARGET_ELF) $(PREFIX)-$(OBJCOPY) $(OBJCOPYFLAGS) $(TARGET_ELF) $@ $(TARGET_ELF) : $(OBJS) main.lds Makefile $(PREFIX)-$(LD) $(LDFLAGS) $(OBJS) -o $@ main.o : main.c boot.o : boot.s gdbs : /usr/local/h8/bin/h8300-hitachi-elf-gdb.exe -w -x boot.cmd clean : rm -rf $(OBJS) $(TARGET) |
OUTPUT_FORMAT("elf32-sh") OUTPUT_ARCH(sh) ENTRY(_Start) SECTIONS { . = 0x0; .text : { *(.text); } .rodata : { *(.rodata); } . = 0xffff0000; .bss : { *(.bss); } .data : { *(.data); } .stack : { *(.stack); } } |
.text .global _Start _Start: mov.l .SP, r15 mov.l .L1, r0 jsr @r0 nop .align 2 .L1: .long _main .SP: .long 0x00001000 |
#include int main( void ) { // printf( "AAA" ); return 1; } |
S00B00006D61696E2E6D6F74D1 S31500001000DF02D001400B00090000101000001000A4 S315000010102FE66EF3E10160136FE36EF6000B000935 S70500001000EA |