<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">2017-08-17 16:57 GMT+02:00 Gedare Bloom <span dir="ltr"><<a href="mailto:gedare@rtems.org" target="_blank">gedare@rtems.org</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Wed, Aug 16, 2017 at 11:12 AM, Denis Obrezkov<br>
<<a href="mailto:denisobrezkov@gmail.com">denisobrezkov@gmail.com</a>> wrote:<br>
> ---<br>
> c/src/lib/libbsp/riscv32/<wbr>hifive1/startup/linkcmds | 379 ++++++++++++++++++++++<br>
> 1 file changed, 379 insertions(+)<br>
> create mode 100644 c/src/lib/libbsp/riscv32/<wbr>hifive1/startup/linkcmds<br>
><br>
> diff --git a/c/src/lib/libbsp/riscv32/<wbr>hifive1/startup/linkcmds b/c/src/lib/libbsp/riscv32/<wbr>hifive1/startup/linkcmds<br>
> new file mode 100644<br>
> index 0000000..8bf56a0<br>
> --- /dev/null<br>
> +++ b/c/src/lib/libbsp/riscv32/<wbr>hifive1/startup/linkcmds<br>
> @@ -0,0 +1,379 @@<br>
> +/**<br>
> + * @file<br>
> + *<br>
> + * @ingroup bsp_linker<br>
> + *<br>
> + * @brief Memory map<br>
> + */<br>
> +<br>
> +/*<br>
> + *<br>
> + * Copyright (c) 2015 University of York.<br>
> + * Hesham ALMatary <<a href="mailto:hmka501@york.ac.uk">hmka501@york.ac.uk</a>><br>
> + *<br>
> + * Redistribution and use in source and binary forms, with or without<br>
> + * modification, are permitted provided that the following conditions<br>
> + * are met:<br>
> + * 1. Redistributions of source code must retain the above copyright<br>
> + * notice, this list of conditions and the following disclaimer.<br>
> + * 2. Redistributions in binary form must reproduce the above copyright<br>
> + * notice, this list of conditions and the following disclaimer in the<br>
> + * documentation and/or other materials provided with the distribution.<br>
> + *<br>
> + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND<br>
> + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE<br>
> + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE<br>
> + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE<br>
> + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL<br>
> + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS<br>
> + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)<br>
> + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT<br>
> + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY<br>
> + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF<br>
> + * SUCH DAMAGE.<br>
> + */<br>
> +<br>
> +OUTPUT_FORMAT("elf32-<wbr>littleriscv", "elf32-littleriscv", "elf32-littleriscv")<br>
> +OUTPUT_ARCH (riscv)<br>
> +<br>
> +ENTRY (_start)<br>
> +<br>
> +MEMORY<br>
> +{<br>
> + ROM : ORIGIN = 0x20400000, LENGTH = 16M<br>
> + RAM : ORIGIN = 0x80000000, LENGTH = 16K /* 64KiB external RAM, but gdb knows only about 16 KiB */<br>
</div></div>Is there actually 64K ram?<br>
<br>
I don't have the knowledge to review the rest of this for correctness.<br>
It would be good to have a shared linkcmds approach though, like ARM.<br>
<div><div class="h5"><br>
> + ITIM : ORIGIN = 0x08000000, LENGTH = 8K<br>
> +}<br>
> +<br>
> +REGION_ALIAS ("REGION_VECTOR", ROM);<br>
> +REGION_ALIAS ("REGION_START", ROM);<br>
> +REGION_ALIAS ("REGION_TEXT", ROM);<br>
> +REGION_ALIAS ("REGION_TEXT_LOAD", ROM);<br>
> +REGION_ALIAS ("REGION_RODATA", ROM);<br>
> +REGION_ALIAS ("REGION_RODATA_LOAD", ROM);<br>
> +REGION_ALIAS ("REGION_DATA", RAM);<br>
> +REGION_ALIAS ("REGION_DATA_LOAD", ROM);<br>
> +REGION_ALIAS ("REGION_FAST_DATA", RAM);<br>
> +REGION_ALIAS ("REGION_FAST_DATA_LOAD", ROM);<br>
> +REGION_ALIAS ("REGION_BSS", RAM);<br>
> +REGION_ALIAS ("REGION_WORK", RAM);<br>
> +REGION_ALIAS ("REGION_STACK", RAM);<br>
> +<br>
> +/* The following address is used for text output */<br>
> +/* bsp_section_outbut_buffer = 0x8F800000; */<br>
> + bsp_section_vector_begin = 0x20400000;<br>
> +<br>
> +<br>
> +STACK_LENGTH = 0;<br>
> +/*<br>
> + * Global symbols that may be defined externally<br>
> + */<br>
> +bsp_vector_table_size = DEFINED (bsp_vector_table_size) ? bsp_vector_table_size : 64;<br>
> +<br>
> +bsp_section_xbarrier_align = DEFINED (bsp_section_xbarrier_align) ? bsp_section_xbarrier_align : 1;<br>
> +bsp_section_robarrier_align = DEFINED (bsp_section_robarrier_align) ? bsp_section_robarrier_align : 1;<br>
> +bsp_section_rwbarrier_align = DEFINED (bsp_section_rwbarrier_align) ? bsp_section_rwbarrier_align : 1;<br>
> +<br>
> +bsp_stack_align = DEFINED (bsp_stack_align) ? bsp_stack_align : 8;<br>
> +<br>
> +bsp_stack_main_size = DEFINED (bsp_stack_main_size) ? bsp_stack_main_size : 1024;<br>
> +bsp_stack_main_size = ALIGN (bsp_stack_main_size, bsp_stack_align);<br>
> +<br>
> +_bsp_processor_count = DEFINED (_bsp_processor_count) ? _bsp_processor_count : 1;<br>
> +<br>
> +SECTIONS {<br>
> +<br>
> + .vector :<br>
> + {<br>
> + . = 0x100;<br>
> + *(.vector)<br>
> + . = ALIGN(bsp_vector_table_size);<br>
> + bsp_section_vector_end = .;<br>
> + } > REGION_VECTOR AT > REGION_VECTOR<br>
> + bsp_section_vector_size = bsp_section_vector_end - bsp_section_vector_begin;<br>
> + bsp_vector_table_begin = bsp_section_vector_begin;<br>
> + bsp_vector_table_end = bsp_vector_table_begin + bsp_vector_table_size;<br>
> +<br>
> + .start :<br>
> + {<br>
> + . = ALIGN(8);<br>
> + bsp_section_start_begin = .;<br>
> + KEEP (*(.bsp_start_text))<br>
> + KEEP (*(.bsp_start_data))<br>
> + bsp_section_start_end = .;<br>
> + } > REGION_START AT > REGION_START<br>
> + bsp_section_start_size = bsp_section_start_end - bsp_section_start_begin;<br>
> +<br>
> +.xbarrier : {<br>
> + . = ALIGN (bsp_section_xbarrier_align);<br>
> + } > REGION_VECTOR AT > REGION_VECTOR<br>
> +<br>
> +.text : {<br>
> + . = ALIGN(8);<br>
> + bsp_section_text_begin = .;<br>
> + *(.text.unlikely .text.*_unlikely)<br>
> + *(.text .stub .text.* .gnu.linkonce.t.*)<br>
> + /* .gnu.warning sections are handled specially by elf32.em. */<br>
> + *(.gnu.warning)<br>
> + *(.glue_7t) *(.glue_7) *(.vfp11_veneer) *(.v4_bx)<br>
> + } > REGION_TEXT AT > REGION_TEXT_LOAD<br>
> + .init : {<br>
> + KEEP (*(.init))<br>
> + } > REGION_TEXT AT > REGION_TEXT_LOAD<br>
> + .fini : {<br>
> + KEEP (*(.fini))<br>
> + . = ALIGN(8);<br>
> + bsp_section_text_end = .;<br>
> + PROVIDE (__etext = .);<br>
> + PROVIDE (_etext = .);<br>
> + PROVIDE (etext = .);<br>
> +<br>
> + } > REGION_TEXT AT > REGION_TEXT_LOAD<br>
> + bsp_section_text_size = bsp_section_text_end - bsp_section_text_begin;<br>
> + bsp_section_text_load_begin = LOADADDR (.text);<br>
> + bsp_section_text_load_end = bsp_section_text_load_begin + bsp_section_text_size;<br>
> +<br>
> +.robarrier : {<br>
> + . = ALIGN (bsp_section_robarrier_align);<br>
> + } > REGION_RODATA AT > REGION_RODATA<br>
> +<br>
> +.rodata : {<br>
> + . = ALIGN(8);<br>
> + bsp_section_rodata_begin = .;<br>
> + *(.rodata .rodata.* .gnu.linkonce.r.*)<br>
> + } > REGION_RODATA AT > REGION_RODATA_LOAD<br>
> +.eh_frame : {<br>
> + KEEP (*(.eh_frame))<br>
> + } > REGION_RODATA AT > REGION_RODATA_LOAD<br>
> + .gcc_except_table : {<br>
> + *(.gcc_except_table .gcc_except_table.*)<br>
> + } > REGION_RODATA AT > REGION_RODATA_LOAD<br>
> + .tdata : {<br>
> + _TLS_Data_begin = .;<br>
> + *(.tdata .tdata.* .gnu.linkonce.td.*)<br>
> + _TLS_Data_end = .;<br>
> + } > REGION_RODATA AT > REGION_RODATA_LOAD<br>
> + .tbss : {<br>
> + _TLS_BSS_begin = .;<br>
> + *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon)<br>
> + _TLS_BSS_end = .;<br>
> + } > REGION_RODATA AT > REGION_RODATA_LOAD<br>
> + _TLS_Data_size = _TLS_Data_end - _TLS_Data_begin;<br>
> + _TLS_Data_begin = _TLS_Data_size != 0 ? _TLS_Data_begin : _TLS_BSS_begin;<br>
> + _TLS_Data_end = _TLS_Data_size != 0 ? _TLS_Data_end : _TLS_BSS_begin;<br>
> + _TLS_BSS_size = _TLS_BSS_end - _TLS_BSS_begin;<br>
> + _TLS_Size = _TLS_BSS_end - _TLS_Data_begin;<br>
> + _TLS_Alignment = MAX (ALIGNOF (.tdata), ALIGNOF (.tbss));<br>
> + .preinit_array : {<br>
> + PROVIDE_HIDDEN (__preinit_array_start = .);<br>
> + KEEP (*(.preinit_array))<br>
> + PROVIDE_HIDDEN (__preinit_array_end = .);<br>
> + } > REGION_RODATA AT > REGION_RODATA_LOAD<br>
> + .init_array : {<br>
> + PROVIDE_HIDDEN (__init_array_start = .);<br>
> + KEEP (*(SORT(.init_array.*)))<br>
> + KEEP (*(.init_array))<br>
> + PROVIDE_HIDDEN (__init_array_end = .);<br>
> + } > REGION_RODATA AT > REGION_RODATA_LOAD<br>
> + .fini_array : {<br>
> + PROVIDE_HIDDEN (__fini_array_start = .);<br>
> + KEEP (*(.fini_array))<br>
> + KEEP (*(SORT(.fini_array.*)))<br>
> + PROVIDE_HIDDEN (__fini_array_end = .);<br>
> + } > REGION_RODATA AT > REGION_RODATA_LOAD<br>
> + .ctors : {<br>
> + /* gcc uses crtbegin.o to find the start of<br>
> + the constructors, so we make sure it is<br>
> + first. Because this is a wildcard, it<br>
> + doesn't matter if the user does not<br>
> + actually link against crtbegin.o; the<br>
> + linker won't look for a file to match a<br>
> + wildcard. The wildcard also means that it<br>
> + doesn't matter which directory crtbegin.o<br>
> + is in. */<br>
> + KEEP (*crtbegin.o(.ctors))<br>
> + KEEP (*crtbegin?.o(.ctors))<br>
> + /* We don't want to include the .ctor section from<br>
> + the crtend.o file until after the sorted ctors.<br>
> + The .ctor section from the crtend file contains the<br>
> + end of ctors marker and it must be last */<br>
> + KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))<br>
> + KEEP (*(SORT(.ctors.*)))<br>
> + KEEP (*(.ctors))<br>
> + } > REGION_RODATA AT > REGION_RODATA_LOAD<br>
> + .dtors : {<br>
> + KEEP (*crtbegin.o(.dtors))<br>
> + KEEP (*crtbegin?.o(.dtors))<br>
> + KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))<br>
> + KEEP (*(SORT(.dtors.*)))<br>
> + KEEP (*(.dtors))<br>
> + } > REGION_RODATA AT > REGION_RODATA_LOAD<br>
> + .<a href="http://data.rel.ro" rel="noreferrer" target="_blank">data.rel.ro</a> : {<br>
> + *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*<wbr>)<br>
> + *(.<a href="http://data.rel.ro" rel="noreferrer" target="_blank">data.rel.ro</a>* .gnu.linkonce.d.rel.ro.*)<br>
> + } > REGION_RODATA AT > REGION_RODATA_LOAD<br>
> + .jcr : {<br>
> + KEEP (*(.jcr))<br>
> + } > REGION_RODATA AT > REGION_RODATA_LOAD<br>
> + .interp : {<br>
> + *(.interp)<br>
> + } > REGION_RODATA AT > REGION_RODATA_LOAD<br>
> + .note.gnu.build-id : {<br>
> + *(.note.gnu.build-id)<br>
> + } > REGION_RODATA AT > REGION_RODATA_LOAD<br>
> + .hash : {<br>
> + *(.hash)<br>
> + } > REGION_RODATA AT > REGION_RODATA_LOAD<br>
> + .gnu.hash : {<br>
> + *(.gnu.hash)<br>
> + } > REGION_RODATA AT > REGION_RODATA_LOAD<br>
> + .dynsym : {<br>
> + *(.dynsym)<br>
> + } > REGION_RODATA AT > REGION_RODATA_LOAD<br>
> + .dynstr : {<br>
> + *(.dynstr)<br>
> + } > REGION_RODATA AT > REGION_RODATA_LOAD<br>
> + .gnu.version : {<br>
> + *(.gnu.version)<br>
> + } > REGION_RODATA AT > REGION_RODATA_LOAD<br>
> + .gnu.version_d : {<br>
> + *(.gnu.version_d)<br>
> + } > REGION_RODATA AT > REGION_RODATA_LOAD<br>
> + .gnu.version_r : {<br>
> + *(.gnu.version_r)<br>
> + } > REGION_RODATA AT > REGION_RODATA_LOAD<br>
> + .rel.dyn : {<br>
> + *(.rel.init)<br>
> + *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*)<br>
> + *(.rel.fini)<br>
> + *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*)<br>
> + *(.<a href="http://rel.data.rel.ro" rel="noreferrer" target="_blank">rel.data.rel.ro</a>* .rel.gnu.linkonce.d.rel.ro.*)<br>
> + *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*)<br>
> + *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*)<br>
> + *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*)<br>
> + *(.rel.ctors)<br>
> + *(.rel.dtors)<br>
> + *(.rel.got)<br>
> + *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*)<br>
> + PROVIDE_HIDDEN (__rel_iplt_start = .);<br>
> + *(.rel.iplt)<br>
> + PROVIDE_HIDDEN (__rel_iplt_end = .);<br>
> + PROVIDE_HIDDEN (__rela_iplt_start = .);<br>
> + PROVIDE_HIDDEN (__rela_iplt_end = .);<br>
> + } > REGION_RODATA AT > REGION_RODATA_LOAD<br>
> + .rela.dyn : {<br>
> + *(.rela.init)<br>
> + *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)<br>
> + *(.rela.fini)<br>
> + *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)<br>
> + *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*)<br>
> + *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*)<br>
> + *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*)<br>
> + *(.rela.ctors)<br>
> + *(.rela.dtors)<br>
> + *(.rela.got)<br>
> + *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*)<br>
> + PROVIDE_HIDDEN (__rel_iplt_start = .);<br>
> + PROVIDE_HIDDEN (__rel_iplt_end = .);<br>
> + PROVIDE_HIDDEN (__rela_iplt_start = .);<br>
> + *(.rela.iplt)<br>
> + PROVIDE_HIDDEN (__rela_iplt_end = .);<br>
> + } > REGION_RODATA AT > REGION_RODATA_LOAD<br>
> + .rel.plt : {<br>
> + *(.rel.plt)<br>
> + } > REGION_RODATA AT > REGION_RODATA_LOAD<br>
> + .rela.plt : {<br>
> + *(.rela.plt)<br>
> + } > REGION_RODATA AT > REGION_RODATA_LOAD<br>
> + .plt : {<br>
> + *(.plt)<br>
> + } > REGION_RODATA AT > REGION_RODATA_LOAD<br>
> + .iplt : {<br>
> + *(.iplt)<br>
> + } > REGION_RODATA AT > REGION_RODATA_LOAD<br>
> + .dynamic : {<br>
> + *(.dynamic)<br>
> + } > REGION_RODATA AT > REGION_RODATA_LOAD<br>
> + .got : {<br>
> + *(.got.plt) *(.igot.plt) *(.got) *(.igot)<br>
> + } > REGION_RODATA AT > REGION_RODATA_LOAD<br>
> + .rtemsroset : {<br>
> + /* Special FreeBSD linker set sections */<br>
> + __start_set_sysctl_set = .;<br>
> + *(set_sysctl_*);<br>
> + __stop_set_sysctl_set = .;<br>
> + *(set_domain_*);<br>
> + *(set_pseudo_*);<br>
> +<br>
> + KEEP (*(SORT(.rtemsroset.*)))<br>
> + . = ALIGN(8);<br>
> + bsp_section_rodata_end = .;<br>
> + __data_start_rom = .;<br>
> + } > REGION_RODATA AT > REGION_RODATA_LOAD<br>
> + bsp_section_rodata_size = bsp_section_rodata_end - bsp_section_rodata_begin;<br>
> + bsp_section_rodata_load_begin = LOADADDR (.rodata);<br>
> + bsp_section_rodata_load_end = bsp_section_rodata_load_begin + bsp_section_rodata_size;<br>
> +<br>
> +<br>
> +<br>
> +.data : AT (__data_start_rom) {<br>
> + . = ALIGN(8);<br>
> + bsp_section_data_begin = .;<br>
> + PROVIDE (_copy_start = .);<br>
> + *(.data .data.* .gnu.linkonce.d.* .data1)<br>
> + SORT(CONSTRUCTORS)<br>
> + } > REGION_DATA<br>
> + .rtemsrwset : AT (__data_start_rom + SIZEOF (.data)) {<br>
> + KEEP (*(SORT(.rtemsrwset.*)))<br>
> + . = ALIGN(8);<br>
> +<br>
> + } > REGION_DATA<br>
> + bsp_section_data_size = bsp_section_data_end - bsp_section_data_begin;<br>
> + bsp_section_data_load_begin = LOADADDR (.data);<br>
> + bsp_section_data_load_end = bsp_section_data_load_begin + bsp_section_data_size;<br>
> +<br>
> +.rwbarrier : AT (__data_start_rom + SIZEOF (.data) + SIZEOF (.rtemsrwset)) {<br>
> + . = ALIGN(8);<br>
> + . = ALIGN (bsp_section_rwbarrier_align);<br>
> + bsp_section_data_end = .;<br>
> + PROVIDE (_copy_end = .);<br>
> + } > REGION_DATA<br>
> +<br>
> + .bss : {<br>
> + . = ALIGN(8);<br>
> + bsp_section_bss_begin = .;<br>
> + *(.dynbss)<br>
> + *(.bss .bss.* .gnu.linkonce.b.*)<br>
> + *(COMMON)<br>
> + . = ALIGN(8);<br>
> + bsp_section_bss_end = .;<br>
> + } > REGION_BSS AT > REGION_BSS<br>
> + bsp_section_bss_size = bsp_section_bss_end - bsp_section_bss_begin;<br>
> +<br>
> +.work : {<br>
> + /*<br>
> + * The work section will occupy the remaining REGION_WORK region and<br>
> + * contains the RTEMS work space and heap.<br>
> + */<br>
> + . = ALIGN(8);<br>
> + bsp_section_work_begin = .;<br>
> + . += ORIGIN (REGION_WORK) + LENGTH (REGION_WORK) - ABSOLUTE (.) - STACK_LENGTH;<br>
> + . = ALIGN(8);<br>
> + bsp_section_work_end = .;<br>
> + } > REGION_WORK AT > REGION_WORK<br>
> + bsp_section_work_size = bsp_section_work_end - bsp_section_work_begin;<br>
> +<br>
> + .stack : {<br>
> + . = ALIGN(8);<br>
> + bsp_section_stack_begin = .;<br>
> + . += ORIGIN (REGION_STACK) + LENGTH (REGION_STACK) - ABSOLUTE (.);<br>
> + . = ALIGN(8);<br>
> + bsp_section_stack_end = .;<br>
> + } > REGION_STACK AT > REGION_STACK<br>
> + bsp_section_stack_size = bsp_section_stack_end - bsp_section_stack_begin;<br>
> +<br>
> + RamBase = ORIGIN (REGION_WORK);<br>
> + RamSize = LENGTH (REGION_WORK);<br>
> + WorkAreaBase = bsp_section_work_begin;<br>
> + HeapSize = 0;<br>
> +}<br>
> --<br>
> 2.1.4<br>
><br>
</div></div>> ______________________________<wbr>_________________<br>
> devel mailing list<br>
> <a href="mailto:devel@rtems.org">devel@rtems.org</a><br>
> <a href="http://lists.rtems.org/mailman/listinfo/devel" rel="noreferrer" target="_blank">http://lists.rtems.org/<wbr>mailman/listinfo/devel</a><br>
</blockquote></div><br></div><div class="gmail_extra">Yes, there is only 16 KiB of RAM, should remove the comment.</div><div class="gmail_extra">I remember about linkcmds, but don't have time to implement it properly now.<br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">Regards, Denis Obrezkov</div>
</div></div>