Discussion:
[RFA/libgloss/arm] Handle zero heap base from semihosting
Matthew Gretton-Dann
2011-09-26 15:27:25 UTC
Permalink
Hi,

The attached patch fixes an issue in libgloss' heap setup when using
semihosting.

In particular the semihosting SYS_HEAPINFO call can return 0 for the
heap_base, and this means that the C library is to start the heap at the
end of the image.

This behaviour is documented here:

http://infocenter.arm.com/help/topic/com.arm.doc.dui0471-/Bacbefaa.html

The attached patch handles this case.

Please can someone review.

Thanks,

Matt

libgloss/ChangeLog:

2011-09-02 Matthew Gretton-Dann <matthew.gretton-***@arm.com>

* arm/crt0.s: support 0 heap base response from semihosting.

Thanks,

Matt
--
Matthew Gretton-Dann
Principal Engineer, PD Software - Tools, ARM Ltd
Can Finner
2011-09-27 01:44:40 UTC
Permalink
On Mon, Sep 26, 2011 at 11:27 PM, Matthew Gretton-Dann
       * arm/crt0.s: support 0 heap base response from semihosting.
Hi,

For the symbol "__end__".
.word CommandLine
.word 255
+.LC31:
+ .word __end__

Is there any story why not using "__bss_end__"? In case the program
can not assuming
the bss end lies at last of data segment?

Thanks
--
Regards.
Matthew Gretton-Dann
2011-09-27 08:50:00 UTC
Permalink
Post by Can Finner
On Mon, Sep 26, 2011 at 11:27 PM, Matthew Gretton-Dann
Post by Matthew Gretton-Dann
* arm/crt0.s: support 0 heap base response from semihosting.
Hi,
For the symbol "__end__".
.word CommandLine
.word 255
+ .word __end__
Is there any story why not using "__bss_end__"? In case the program
can not assuming
the bss end lies at last of data segment?
Thanks
The default linker script for arm-none-eabi (installed as
Post by Can Finner
_bss_end__ = . ; __bss_end__ = . ;
. = ALIGN(32 / 8);
. = ALIGN(32 / 8);
__end__ = . ;
_end = .; PROVIDE (end = .);
So I'm using __end__ as it is aligned to a 4-byte boundary which the
heap requires - whereas __bss_end__ may not be.

Thanks,

Matt
--
Matthew Gretton-Dann
Principal Engineer, PD Software - Tools, ARM Ltd
Can Finner
2011-09-27 08:59:46 UTC
Permalink
Post by Matthew Gretton-Dann
The default linker script for arm-none-eabi (installed as
 _bss_end__ = . ; __bss_end__ = . ;
 . = ALIGN(32 / 8);
 . = ALIGN(32 / 8);
 __end__ = . ;
 _end = .; PROVIDE (end = .);
So I'm using __end__ as it is aligned to a 4-byte boundary which the heap
requires - whereas __bss_end__ may not be.
Thanks,
Thanks for clarification. I think __end__ here is better, though we
can align __bss_end__
in crt0.S by simple operation. The only concern is that crt0.S depends one more
linker script smbol now. :)

Thanks
--
Regards.
Nick Clifton
2011-09-29 11:27:43 UTC
Permalink
Hi Matthew,

Thanks for posting this patch. Sorry for the delay in reviewing - I
have been off on vacation.

Anyway the patch is fine and I have checked it in.

Cheers
Nick

libgloss/ChangeLog
2011-09-29 Matthew Gretton-Dann <matthew.gretton-***@arm.com>

* arm/crt0.s: Support 0 heap base response from HeapInfo syscall.
Loading...