1

I am writing code for the Microblaze on OVPsim and wonder is it possible to use semihosting with my own linker script and paging scheme (ie not using crt0?

I have built my platform with semihosting on, but when my assembly hits a global .exit - nothing happens - code example below:

handle_datatlb_miss:
    nop
.global exit
exit:
    ori r19, r0, clock_sweep_pte

(I understand that this should automatically be trapped by the semihosting and result in an end to the simulation).

I am using my own linker script with my own makefile:

SECTIONS
{
    . = 0x0000;
    .vectors.reset : { *(.vectors.reset) }
    . = 0x0008;
    .vectors.sw_exception : { *(.vectors.sw_exception) }
    . = 0x0010;
    .vectors.interrupt : { *(.vectors.interrupt) }
    .= 0x0018;
    .vectors.breakpoint : { *(.vectors.breakpoint) }
    . = 0x0020;
    .vectors.hw_exception : { *(.vectors.hw_exception) }
    .text : { *(.text) }
    .data : { *(.data) }
    .bss : { *(.bss) }
}

If I remove my linker script the code does not compile using the OVP supplied makefile (suitably adapted to build my code):

adrian@hairyirakli:~/Imperas/mb_boot$ make -f alt-makefile 
Linking Application startup.MICROBLAZE.elf
/home/adrian/Imperas/Imperas.20140731/lib/Linux32/CrossCompiler/microblaze-elf/bin/mb-ld: section .text [00000050 -> 0010a27b] overlaps section .vectors.hw_exception [00000020 -> 0000011f]
/home/adrian/Imperas/Imperas.20140731/lib/Linux32/CrossCompiler/microblaze-elf/bin/mb-ld: startup.MICROBLAZE.elf: section .text lma 0x50 overlaps previous sections
/home/adrian/Imperas/Imperas.20140731/lib/Linux32/CrossCompiler/microblaze-elf/bin/mb-ld: startup.MICROBLAZE.elf: section .vectors.breakpoint lma 0x10a27c overlaps previous sections
make: *** [startup.MICROBLAZE.elf] Error 1

When I do use it, with either my own makefile or the OVP-supplied makefile the code compiles but I cannot seem to access semihosting.

Can I access semihosting without using crt0 and the rest?

Update

This is what the start of my code looks like...

_start:
brai _actualstart
.end _start
.section .vectors.sw_exception, "ax"
.align 2
_vector_sw_exception:
brai _exception_handler
.section .vectors.interrupt, "ax"
.align 2
_vector_interrupt:
brai _interrupt_handler
.section .vectors.breakpoint, "ax"
.align 2
_vector_breakpoint:
brai _handle_breakpoint
.section .vectors.hw_exception, "ax"
.align 2
_vector_hw_exception:
brai _hw_exception_handler

(You can see all of it at https://github.com/mcmenaminadrian/mb_boot/blob/master/startup.S)

adrianmcmenamin
  • 1,081
  • 1
  • 15
  • 44
  • 1
    The error messages of the linker look worrisome: `... overlaps section .vectors.hw_exception [00000020 -> 0000011f]`. It looks like you put the whole h/w exception and interrupt handlers into `.vectors.hw_exception` and `.vectors.interrupt` sections. You suppose to put just `bra handler;` into those sections and keep the handlers in `.text`. `.vectors.*` sections should not exceed 8 bytes. – dkz Dec 09 '14 at 06:42
  • I have done that I think... if I could work out how to put code in a comment I'd put it here - but I can't so I'll edit the OP – adrianmcmenamin Dec 09 '14 at 10:00
  • Unfortunately I was not able to reproduce linker errors using Xilinx' and original GCC cross-compilers on Linux (I don't have OVP toolchain). Compiled as expected. Did not see any problems in .ld file either (makefile looks OK too). Can't tell if this affects semihosting, but the linker errors looks weird. – dkz Dec 09 '14 at 19:44
  • 1
    I fixed the linker errors - I had an .org line outside the .text section. Unfortunately that does not resolve my semihosting issue though. – adrianmcmenamin Dec 09 '14 at 22:17

0 Answers0