<HTML><HEAD></HEAD>
<BODY dir=ltr>
<DIV dir=ltr>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: 'Calibri'; COLOR: #000000">
<DIV>I don’t know how to issue ticket to trac and link <A
title=https://devel.rtems.org/wiki/NewTicket
href="https://devel.rtems.org/wiki/NewTicket">https://devel.rtems.org/wiki/NewTicket</A>
not working <IMG class="wlEmoticon wlEmoticon-sadsmile"
style="BORDER-TOP-STYLE: none; BORDER-BOTTOM-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none"
alt="Печальная рожица" src="cid:A3B86F9162B94CBDB839AB25CDBE5163@NOK"></DIV>
<DIV>1. Current version libdl incorrect relocate MIPS16hi/lo (not supported
nested instructions) and I wrote small patch for this (similar gnu as for
mips)</DIV>
<DIV>diff -Naur ./org/rtl-mdreloc-mips.c ./new/rtl-mdreloc-mips.c</DIV>
<DIV>--- ./org/rtl-mdreloc-mips.c 2015-03-27 14:59:47
+0300</DIV>
<DIV>+++ ./new/rtl-mdreloc-mips.c 2016-01-21 17:59:09
+0300</DIV>
<DIV>@@ -36,6 +36,18 @@</DIV>
<DIV> * symbol is STT_SECTION, it must be STB_LOCAL. Thus</DIV>
<DIV> * just consider symtype here.</DIV>
<DIV> */</DIV>
<DIV>+</DIV>
<DIV>+struct mips_hi16 {</DIV>
<DIV>+ Elf_Addr *where_hi16;</DIV>
<DIV>+ Elf_Addr ahl;</DIV>
<DIV>+};</DIV>
<DIV>+</DIV>
<DIV>+extern struct {</DIV>
<DIV>+ Elf_Addr *where_hi16;</DIV>
<DIV>+ Elf_Addr ahl;</DIV>
<DIV>+} *mips_hi16_list;</DIV>
<DIV>+extern int mips_hi16_list_cnt;</DIV>
<DIV>+</DIV>
<DIV>bool</DIV>
<DIV>rtems_rtl_elf_relocate_rel (const
rtems_rtl_obj_t* obj,</DIV>
<DIV>
const
Elf_Rel*
rel,</DIV>
<DIV>@@ -50,10 +62,6 @@</DIV>
<DIV> Elf_Word local = 0;</DIV>
<DIV> uint32_t t;</DIV>
<DIV> </DIV>
<DIV>-</DIV>
<DIV>- static Elf_Addr *where_hi16;</DIV>
<DIV>- static Elf_Addr ahl;</DIV>
<DIV>-</DIV>
<DIV> where = (Elf_Addr *)(sect->base + rel->r_offset);</DIV>
<DIV> addend = *where;</DIV>
<DIV> </DIV>
<DIV>@@ -119,9 +127,15 @@</DIV>
<DIV> break;</DIV>
<DIV> </DIV>
<DIV> case R_TYPE(HI16):</DIV>
<DIV>- ahl = addend << 16;</DIV>
<DIV>- where_hi16 = where;</DIV>
<DIV> </DIV>
<DIV>+ mips_hi16_list_cnt++;</DIV>
<DIV>+ if (mips_hi16_list_cnt > 32) {</DIV>
<DIV>+ printf("rtl:Error, too many
HI16 relocs!\n");</DIV>
<DIV>+ return false;</DIV>
<DIV>+ }</DIV>
<DIV>+ mips_hi16_list++;</DIV>
<DIV>+ mips_hi16_list->where_hi16 = where;</DIV>
<DIV>+ mips_hi16_list->ahl = addend << 16;</DIV>
<DIV> </DIV>
<DIV> if (rtems_rtl_trace
(RTEMS_RTL_TRACE_RELOC))</DIV>
<DIV> printf ("rtl: R_MIPS_HI16
%p @ %p in %s\n",</DIV>
<DIV>@@ -129,31 +143,37 @@</DIV>
<DIV> break;</DIV>
<DIV> </DIV>
<DIV> case R_TYPE(LO16):</DIV>
<DIV>- //ahl += (int16_t)addend;</DIV>
<DIV>- t = ahl + (int16_t)addend;</DIV>
<DIV>- tmp = symvalue;</DIV>
<DIV>- if (tmp == 0)</DIV>
<DIV>- return false;</DIV>
<DIV>-</DIV>
<DIV>- addend &= 0xffff0000;</DIV>
<DIV>- addend |= (uint16_t)(t + tmp);</DIV>
<DIV>- *where = addend;</DIV>
<DIV>-</DIV>
<DIV>- if (rtems_rtl_trace
(RTEMS_RTL_TRACE_RELOC))</DIV>
<DIV>- printf("*where %lx where %p\n",
*where, where);</DIV>
<DIV>-</DIV>
<DIV>- addend = *where_hi16;</DIV>
<DIV>- addend &= 0xffff0000;</DIV>
<DIV>- addend |= ((t + tmp) - (int16_t)(t + tmp))
>> 16;</DIV>
<DIV>- *where_hi16 = addend;</DIV>
<DIV>-</DIV>
<DIV>- if (rtems_rtl_trace
(RTEMS_RTL_TRACE_RELOC))</DIV>
<DIV>- printf("*where_hi %lx where_hi
%p\n", *where_hi16, where_hi16);</DIV>
<DIV> </DIV>
<DIV>- if (rtems_rtl_trace
(RTEMS_RTL_TRACE_RELOC))</DIV>
<DIV>- printf ("rtl: R_MIPS_LO16 %p @
%p in %s\n",</DIV>
<DIV>-
(void *)*(where), where, rtems_rtl_obj_oname (obj));</DIV>
<DIV>- break;</DIV>
<DIV>+ t = (int16_t) addend;</DIV>
<DIV>+ tmp = symvalue;</DIV>
<DIV>+ if (tmp == 0)</DIV>
<DIV>+ return false;</DIV>
<DIV>+ /* reloc low part */</DIV>
<DIV>+ addend &= 0xffff0000;</DIV>
<DIV>+ addend |= (uint16_t) (t + tmp);</DIV>
<DIV>+ *where = addend;</DIV>
<DIV>+</DIV>
<DIV>+ if (rtems_rtl_trace(RTEMS_RTL_TRACE_RELOC))</DIV>
<DIV>+ printf("*where %x where %x\n",
*where, where);</DIV>
<DIV>+ /* reloc hi parts */</DIV>
<DIV>+ while (mips_hi16_list_cnt != 0) {</DIV>
<DIV>+ addend =
*(mips_hi16_list->where_hi16);</DIV>
<DIV>+ addend &= 0xffff0000;</DIV>
<DIV>+ addend |=
((mips_hi16_list->ahl + t + tmp)</DIV>
<DIV>+
- (int16_t) (mips_hi16_list->ahl + t + tmp)) >> 16;</DIV>
<DIV>+
*(mips_hi16_list->where_hi16) = addend;</DIV>
<DIV>+ if
(rtems_rtl_trace(RTEMS_RTL_TRACE_RELOC))</DIV>
<DIV>+
printf("*where_hi %x where_hi %x ahl=%08x\n",</DIV>
<DIV>+
*(mips_hi16_list->where_hi16),</DIV>
<DIV>+
mips_hi16_list->where_hi16, mips_hi16_list->ahl);</DIV>
<DIV>+ mips_hi16_list--;</DIV>
<DIV>+ mips_hi16_list_cnt--;</DIV>
<DIV>+ }</DIV>
<DIV>+</DIV>
<DIV>+ if (rtems_rtl_trace(RTEMS_RTL_TRACE_RELOC))</DIV>
<DIV>+ printf("rtl: R_MIPS_LO16 %p @
%p in %s\n", (void *) *(where), where,</DIV>
<DIV>+
rtems_rtl_obj_oname(obj));</DIV>
<DIV>+ break;</DIV>
<DIV> </DIV>
<DIV> case R_TYPE(PC16):</DIV>
<DIV> tmp = addend & 0xffff;</DIV>
<DIV>diff -Naur ./org/rtl-rap.c ./new/rtl-rap.c</DIV>
<DIV>--- ./org/rtl-rap.c 2015-03-23 11:08:38 +0300</DIV>
<DIV>+++ ./new/rtl-rap.c 2016-01-21 17:52:15 +0300</DIV>
<DIV>@@ -217,6 +217,13 @@</DIV>
<DIV> return rtems_rtl_obj_comp_read (rap->decomp, sect->base,
sect->size);</DIV>
<DIV>}</DIV>
<DIV> </DIV>
<DIV>+struct {</DIV>
<DIV>+ Elf_Addr *where_hi16;</DIV>
<DIV>+ Elf_Addr ahl;</DIV>
<DIV>+} *mips_hi16_list;</DIV>
<DIV>+</DIV>
<DIV>+int mips_hi16_list_cnt;</DIV>
<DIV>+</DIV>
<DIV>static bool</DIV>
<DIV>rtems_rtl_rap_relocate (rtems_rtl_rap_t* rap, rtems_rtl_obj_t* obj)</DIV>
<DIV>{</DIV>
<DIV>@@ -270,6 +277,13 @@</DIV>
<DIV>
rap_sections[section].name,</DIV>
<DIV>
header, relocs, is_rela ? "rela" : "rel");</DIV>
<DIV> </DIV>
<DIV>+ mips_hi16_list = malloc(sizeof(*mips_hi16_list) * (32 +
1));</DIV>
<DIV>+ if (mips_hi16_list == NULL) {</DIV>
<DIV>+ printf("rtl: No enough memory
for hi16_list\n");</DIV>
<DIV>+ return false;</DIV>
<DIV>+ }</DIV>
<DIV>+ mips_hi16_list_cnt = 0;</DIV>
<DIV>+</DIV>
<DIV> for (r = 0; r < relocs; ++r)</DIV>
<DIV> {</DIV>
<DIV> uint32_t info =
0;</DIV>
<DIV>@@ -419,6 +433,14 @@</DIV>
<DIV> }</DIV>
<DIV> }</DIV>
<DIV> }</DIV>
<DIV>+</DIV>
<DIV>+ free(mips_hi16_list);</DIV>
<DIV>+ if (mips_hi16_list_cnt != 0) {</DIV>
<DIV>+ printf("rtl:Error, not empty
mips_hi16_list!\n");</DIV>
<DIV>+ free(symname_buffer);</DIV>
<DIV>+ return false;</DIV>
<DIV>+ }</DIV>
<DIV>+</DIV>
<DIV> }</DIV>
<DIV> </DIV>
<DIV> free (symname_buffer);</DIV>
<DIV> </DIV>
<DIV>2. Small patch for imfs_memfile (I some time ago offered). </DIV>
<DIV>If variable unsigned int block == 0 – for loop work incorrectly (and I have
this after error fs).</DIV>
<DIV> </DIV>
<DIV>diff -Naur ./orgimfs/imfs_memfile.c ./newimfs/imfs_memfile.c</DIV>
<DIV>--- ./orgimfs/imfs_memfile.c 2015-02-16 10:03:17
+0300</DIV>
<DIV>+++ ./newimfs/imfs_memfile.c 2016-01-22 11:13:15
+0300</DIV>
<DIV>@@ -188,9 +188,10 @@</DIV>
<DIV> offset =
0;</DIV>
<DIV> }</DIV>
<DIV> } else {</DIV>
<DIV>- for ( ; block>=old_blocks ;
block-- ) {</DIV>
<DIV>-
IMFS_memfile_remove_block( memfile, block );</DIV>
<DIV>- }</DIV>
<DIV>+ if ( !block )</DIV>
<DIV>+ for ( ;
block>=old_blocks ; block-- ) {</DIV>
<DIV>+
IMFS_memfile_remove_block( memfile, block );</DIV>
<DIV>+ }</DIV>
<DIV>
rtems_set_errno_and_return_minus_one( ENOSPC );</DIV>
<DIV> }</DIV>
<DIV> }</DIV>
<DIV> </DIV>
<DIV>3. For test per-section compilation and dynamic linking support I wrote 3
small project (indifferently cpu)</DIV>
<DIV>project a) static library libtst.a with tst.c</DIV>
<DIV>tst.c </DIV>
<DIV> </DIV>
<DIV>int abcd=5;</DIV>
<DIV>void funcA(void)</DIV>
<DIV>{</DIV>
<DIV> abcd=7;</DIV>
<DIV>}</DIV>
<DIV>void funcB(void)</DIV>
<DIV>{</DIV>
<DIV>}</DIV>
<DIV>project b) minimal rtems project have only Init function and linked with
this libtst.a</DIV>
<DIV> </DIV>
<DIV>extern void funcA(void);</DIV>
<DIV>extern int abcd;</DIV>
<DIV>rtems_task Init(rtems_task_argument argument) {</DIV>
<DIV> funcA();</DIV>
<DIV> abcd = 9;</DIV>
<DIV> rtems_task_delete(RTEMS_SELF);</DIV>
<DIV>}</DIV>
<DIV>project c) make rap file with test.c and linked library libtst.a and kernel
image</DIV>
<DIV>test.c</DIV>
<DIV> </DIV>
<DIV>extern void funcB(void);</DIV>
<DIV>void rtems(void)</DIV>
<DIV>{</DIV>
<DIV> funcB();</DIV>
<DIV>}</DIV>
<DIV> </DIV>
<DIV>Map file without per-section compilation </DIV>
<DIV>testrap.rap:</DIV>
<DIV> Strings: 0x00000074 (116) size: 14</DIV>
<DIV>
0 (0x000000): </DIV>
<DIV>
1 (0x000001): rtems</DIV>
<DIV>
2 (0x000007): rtems</DIV>
<DIV>
3 (0x00000d): </DIV>
<DIV> Symbols: 0x00000082 (130) size: 12</DIV>
<DIV>
data section value name</DIV>
<DIV>
0: 0x0012 .text 0x00000000 rtems</DIV>
<DIV> Relocations: 0x0000008e (142)</DIV>
<DIV> .text:
info offset
addend symbol name</DIV>
<DIV>
0: 0x80000504 0x00000008 0x00000000 funcB</DIV>
<DIV> </DIV>
<DIV>Map file with per-section compilation </DIV>
<DIV>testrap.rap:</DIV>
<DIV> Strings: 0x00000090 (144) size: 31</DIV>
<DIV>
0 (0x000000): </DIV>
<DIV>
1 (0x000001): rtems</DIV>
<DIV>
2 (0x000007): funcA</DIV>
<DIV>
3 (0x00000d): abcd</DIV>
<DIV>
4 (0x000012): funcB</DIV>
<DIV>
5 (0x000018): rtems</DIV>
<DIV>
6 (0x00001e): </DIV>
<DIV> Symbols: 0x000000af (175) size: 48</DIV>
<DIV>
data section value name</DIV>
<DIV>
0: 0x0012 .text 0x00000000 rtems</DIV>
<DIV>
1: 0x0012 .text 0x00000000 funcA</DIV>
<DIV>
2: 0x0011 .data 0x00000000 abcd</DIV>
<DIV>
3: 0x0012 .text 0x00000000 funcB</DIV>
<DIV> Relocations: 0x000000df (223)</DIV>
<DIV> .text:
info offset
addend symbol name</DIV>
<DIV>
0: 0xc0001204 0x00000008 0x00000000 </DIV>
<DIV>
1: 0xc0000d05 0x00000024 0x00000000 </DIV>
<DIV>
2: 0xc0000d06 0x0000002c 0x00000000 </DIV>
<DIV> </DIV>
<DIV>If use per-section compilation while insert funcB (from library libtst.a)
get full tst.o from library. </DIV>
<DIV>Objects funcA and abcd duplicate already available in kernel. </DIV>
<DIV> </DIV>
<DIV>I do not know as it to correct and remove excess symbols and
objects.</DIV></DIV></DIV></BODY></HTML>