added libgcc_helper.S to retarget libgcc calls for 64 bit multiplication/division
This commit is contained in:
@@ -201,3 +201,4 @@ Makefile
|
|||||||
x86emu/x86biosemu.c
|
x86emu/x86biosemu.c
|
||||||
x86emu/x86emu.c
|
x86emu/x86emu.c
|
||||||
x86emu/x86pcibios.c
|
x86emu/x86pcibios.c
|
||||||
|
util/libgcc_helper.S
|
||||||
|
|||||||
8
Makefile
8
Makefile
@@ -29,6 +29,7 @@ AR=$(TCPREFIX)ar
|
|||||||
RANLIB=$(TCPREFIX)ranlib
|
RANLIB=$(TCPREFIX)ranlib
|
||||||
NATIVECC=gcc
|
NATIVECC=gcc
|
||||||
|
|
||||||
|
LDLIBS=-L/usr/lib/gcc/m68k-elf/4.9.2/m5475 -lgcc
|
||||||
INCLUDE=-Iinclude
|
INCLUDE=-Iinclude
|
||||||
CFLAGS=-mcpu=5474 \
|
CFLAGS=-mcpu=5474 \
|
||||||
-g \
|
-g \
|
||||||
@@ -140,6 +141,7 @@ CSRCS= \
|
|||||||
ASRCS= \
|
ASRCS= \
|
||||||
startcf.S \
|
startcf.S \
|
||||||
printf_helper.S \
|
printf_helper.S \
|
||||||
|
libgcc_helper.S \
|
||||||
exceptions.S \
|
exceptions.S \
|
||||||
xhdi_vec.S \
|
xhdi_vec.S \
|
||||||
pci_wrappers.S
|
pci_wrappers.S
|
||||||
@@ -255,7 +257,7 @@ define EX_TEMPLATE
|
|||||||
$(1)_MAPFILE=$(1)/$$(basename $$(FLASH_EXEC)).map
|
$(1)_MAPFILE=$(1)/$$(basename $$(FLASH_EXEC)).map
|
||||||
$(1)/$$(FLASH_EXEC): $(1)/$(LIBBAS) $(LDCSRC)
|
$(1)/$$(FLASH_EXEC): $(1)/$(LIBBAS) $(LDCSRC)
|
||||||
$(CPP) $(INCLUDE) -DOBJDIR=$(1)/objs -P -DFORMAT_ELF=$(FORMAT_ELF) -D$$(MACHINE) $(LDCSRC) -o $(1)/$$(LDCFILE)
|
$(CPP) $(INCLUDE) -DOBJDIR=$(1)/objs -P -DFORMAT_ELF=$(FORMAT_ELF) -D$$(MACHINE) $(LDCSRC) -o $(1)/$$(LDCFILE)
|
||||||
$(LD) --oformat $$(FORMAT) -Map $$($(1)_MAPFILE) --cref -T $(1)/$$(LDCFILE) -o $$@
|
$(LD) --oformat $$(FORMAT) -Map $$($(1)_MAPFILE) --cref -T $(1)/$$(LDCFILE) $(LDLIBS) -o $$@
|
||||||
ifeq ($(COMPILE_ELF),Y)
|
ifeq ($(COMPILE_ELF),Y)
|
||||||
$(OBJCOPY) -O srec $$@ $$(basename $$@).s19
|
$(OBJCOPY) -O srec $$@ $$(basename $$@).s19
|
||||||
else
|
else
|
||||||
@@ -266,7 +268,7 @@ endif
|
|||||||
$(1)_MAPFILE_RAM=$(1)/$$(basename $$(RAM_EXEC)).map
|
$(1)_MAPFILE_RAM=$(1)/$$(basename $$(RAM_EXEC)).map
|
||||||
$(1)/$$(RAM_EXEC): $(1)/$(LIBBAS) $(LDCSRC)
|
$(1)/$$(RAM_EXEC): $(1)/$(LIBBAS) $(LDCSRC)
|
||||||
$(CPP) $(INCLUDE) -DCOMPILE_RAM -DOBJDIR=$(1)/objs -P -DFORMAT_ELF=$(FORMAT_ELF) -D$$(MACHINE) $(LDCSRC) -o $(1)/$$(LDRFILE)
|
$(CPP) $(INCLUDE) -DCOMPILE_RAM -DOBJDIR=$(1)/objs -P -DFORMAT_ELF=$(FORMAT_ELF) -D$$(MACHINE) $(LDCSRC) -o $(1)/$$(LDRFILE)
|
||||||
$(LD) $(LDFLAGS) --oformat $$(FORMAT) -Map $$($(1)_MAPFILE_RAM) --cref -T $(1)/$$(LDRFILE) -o $$@
|
$(LD) $(LDFLAGS) --oformat $$(FORMAT) -Map $$($(1)_MAPFILE_RAM) --cref -T $(1)/$$(LDRFILE) $(LDLIBS) -o $$@
|
||||||
ifeq ($(COMPILE_ELF),Y)
|
ifeq ($(COMPILE_ELF),Y)
|
||||||
$(OBJCOPY) -O srec $$@ $$(basename $$@).s19
|
$(OBJCOPY) -O srec $$@ $$(basename $$@).s19
|
||||||
else
|
else
|
||||||
@@ -277,7 +279,7 @@ endif
|
|||||||
$(1)_MAPFILE_BFL=$(1)/$$(basename $$(BASFLASH_EXEC)).map
|
$(1)_MAPFILE_BFL=$(1)/$$(basename $$(BASFLASH_EXEC)).map
|
||||||
$(1)/$$(BASFLASH_EXEC): $(1)/objs/basflash.o $(1)/objs/basflash_start.o $(1)/$(LIBBAS) $(LDCBFL)
|
$(1)/$$(BASFLASH_EXEC): $(1)/objs/basflash.o $(1)/objs/basflash_start.o $(1)/$(LIBBAS) $(LDCBFL)
|
||||||
$(CPP) $(INCLUDE) -P -DOBJDIR=$(1)/objs -DFORMAT_ELF=$(FORMAT_ELF) -D$$(MACHINE) $(LDCBSRC) -o $(1)/$$(LDCBFS)
|
$(CPP) $(INCLUDE) -P -DOBJDIR=$(1)/objs -DFORMAT_ELF=$(FORMAT_ELF) -D$$(MACHINE) $(LDCBSRC) -o $(1)/$$(LDCBFS)
|
||||||
$(LD) --oformat $$(FORMAT) -Map $$($(1)_MAPFILE_BFL) --cref -T $(1)/$$(LDCFILE) -L$(1) -lbas -o $$@
|
$(LD) --oformat $$(FORMAT) -Map $$($(1)_MAPFILE_BFL) --cref -T $(1)/$$(LDCFILE) -L$(1) -lbas $(LDLIBS) -o $$@
|
||||||
ifeq ($(COMPILE_ELF),Y)
|
ifeq ($(COMPILE_ELF),Y)
|
||||||
$(OBJCOPY) -O srec $$@ $$(basename $$@).s19
|
$(OBJCOPY) -O srec $$@ $$(basename $$@).s19
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ SECTIONS
|
|||||||
OBJDIR/s19reader.o(.text)
|
OBJDIR/s19reader.o(.text)
|
||||||
OBJDIR/bas_printf.o(.text)
|
OBJDIR/bas_printf.o(.text)
|
||||||
OBJDIR/bas_string.o(.text)
|
OBJDIR/bas_string.o(.text)
|
||||||
|
OBJDIR/libgcc_helper.o(.text)
|
||||||
OBJDIR/printf_helper.o(.text)
|
OBJDIR/printf_helper.o(.text)
|
||||||
OBJDIR/cache.o(.text)
|
OBJDIR/cache.o(.text)
|
||||||
OBJDIR/dma.o(.text)
|
OBJDIR/dma.o(.text)
|
||||||
@@ -118,6 +119,7 @@ SECTIONS
|
|||||||
#endif /* COMPILE_RAM */
|
#endif /* COMPILE_RAM */
|
||||||
|
|
||||||
#if (FORMAT_ELF == 1)
|
#if (FORMAT_ELF == 1)
|
||||||
|
*(.eh_frame)
|
||||||
*(.rodata)
|
*(.rodata)
|
||||||
*(.rodata.*)
|
*(.rodata.*)
|
||||||
#endif
|
#endif
|
||||||
@@ -154,8 +156,6 @@ SECTIONS
|
|||||||
* Global memory map
|
* Global memory map
|
||||||
*/
|
*/
|
||||||
|
|
||||||
___muldi3 = __muldi3;
|
|
||||||
|
|
||||||
/* SDRAM Initialization */
|
/* SDRAM Initialization */
|
||||||
___SDRAM = SDRAM_START;
|
___SDRAM = SDRAM_START;
|
||||||
___SDRAM_SIZE = SDRAM_SIZE;
|
___SDRAM_SIZE = SDRAM_SIZE;
|
||||||
|
|||||||
26
util/libgcc_helper.S
Normal file
26
util/libgcc_helper.S
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* needed for ELF compilation of x86emu which uses 64 bit multiplication and division. This
|
||||||
|
* is implemented in libgcc.a. However, the ELF compiler emits leading underscores and libgcc
|
||||||
|
* is not compiled like that - we must reimplement the symbols.
|
||||||
|
*
|
||||||
|
* FIXME: This is a quirk and should be replaced by BaS' own implementation later
|
||||||
|
*/
|
||||||
|
.global ___divdi3
|
||||||
|
.extern __divdi3
|
||||||
|
___divdi3: jmp __divdi3
|
||||||
|
|
||||||
|
.global ___muldi3
|
||||||
|
.extern __muldi3
|
||||||
|
___muldi3: jmp __muldi3
|
||||||
|
|
||||||
|
.global ___moddi3
|
||||||
|
.extern __moddi3
|
||||||
|
___moddi3: jmp __moddi3
|
||||||
|
|
||||||
|
.global ___udivdi3
|
||||||
|
.extern __udivdi3
|
||||||
|
___udivdi3: jmp __udivdi3
|
||||||
|
|
||||||
|
.global ___umoddi3
|
||||||
|
.extern __umoddi3
|
||||||
|
___umoddi3: jmp __umoddi3
|
||||||
@@ -169,6 +169,7 @@ static void push_long (struct X86EMU *, uint32_t w);
|
|||||||
static uint16_t pop_word (struct X86EMU *);
|
static uint16_t pop_word (struct X86EMU *);
|
||||||
static uint32_t pop_long (struct X86EMU *);
|
static uint32_t pop_long (struct X86EMU *);
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
REMARKS:
|
REMARKS:
|
||||||
Handles any pending asychronous interrupts.
|
Handles any pending asychronous interrupts.
|
||||||
@@ -7819,6 +7820,8 @@ idiv_word(struct X86EMU *emu, uint16_t s)
|
|||||||
emu->x86.R_AX = (uint16_t) div;
|
emu->x86.R_AX = (uint16_t) div;
|
||||||
emu->x86.R_DX = (uint16_t) mod;
|
emu->x86.R_DX = (uint16_t) mod;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
REMARKS:
|
REMARKS:
|
||||||
Implements the IDIV instruction and side effects.
|
Implements the IDIV instruction and side effects.
|
||||||
|
|||||||
Reference in New Issue
Block a user