<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html lang="en" style='--code-editor-font: var(--default-mono-font, "GitLab Mono"), JetBrains Mono, Menlo, DejaVu Sans Mono, Liberation Mono, Consolas, Ubuntu Mono, Courier New, andale mono, lucida console, monospace;'>
<head>
<meta content="text/html; charset=US-ASCII" http-equiv="Content-Type">
<title>
GitLab
</title>
<style data-premailer="ignore" type="text/css">
a { color: #1068bf; }
</style>
<style>img {
max-width: 100%; height: auto;
}
body {
font-size: .875rem;
}
body {
-webkit-text-shadow: rgba(255,255,255,.01) 0 0 1px;
}
body {
font-family: "GitLab Sans",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Noto Sans",Ubuntu,Cantarell,"Helvetica Neue",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji"; font-size: inherit;
}
</style>
</head>
<body style='font-size: inherit; -webkit-text-shadow: rgba(255,255,255,.01) 0 0 1px; font-family: "GitLab Sans",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Noto Sans",Ubuntu,Cantarell,"Helvetica Neue",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";'>
<div class="content">
<p style="color: #777777;">
<a href="https://gitlab.rtems.org/ppisa">Pavel Pisa</a>
<a href="https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/312#note_115090">commented</a>:
</p>
<div class="md" style="position: relative; z-index: 1; color: #28272d; word-wrap: break-word;">
<p dir="auto" style="color: #28272d; margin: 0 0 16px;" align="initial">I have applied your changes and tried to call <code style='font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; margin-top: 0; font-weight: inherit; font-family: "GitLab Mono","JetBrains Mono","Menlo","DejaVu Sans Mono","Liberation Mono","Consolas","Ubuntu Mono","Courier New","andale mono","lucida console",monospace; vertical-align: bottom; white-space: pre-wrap; overflow-wrap: break-word; word-break: keep-all; padding: 2px 4px;'>dlopen</code> on BeaglV-Fire from my test application</p>
<p dir="auto" style="color: #28272d; margin: 0 0 16px;" align="initial"><a href="https://github.com/ppisa/rtems-devel/tree/master/rtems-omk-template/appdl" rel="nofollow noreferrer noopener" target="_blank" style="margin-top: 0;">https://github.com/ppisa/rtems-devel/tree/master/rtems-omk-template/appdl</a></p>
<p dir="auto" style="color: #28272d; margin: 0 0 16px;" align="initial">which calls <code style='font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; margin-top: 0; font-weight: inherit; font-family: "GitLab Mono","JetBrains Mono","Menlo","DejaVu Sans Mono","Liberation Mono","Consolas","Ubuntu Mono","Courier New","andale mono","lucida console",monospace; vertical-align: bottom; white-space: pre-wrap; overflow-wrap: break-word; word-break: keep-all; padding: 2px 4px;'>shell_dlopen</code> and tries to load simple ELF file</p>
<p dir="auto" style="color: #28272d; margin: 0 0 16px;" align="initial">build from <a href="https://github.com/ppisa/rtems-devel/blob/master/rtems-omk-template/appdl/examples/appdl_print.c" rel="nofollow noreferrer noopener" target="_blank" style="margin-top: 0;">https://github.com/ppisa/rtems-devel/blob/master/rtems-omk-template/appdl/examples/appdl_print.c</a></p>
<p dir="auto" style="color: #28272d; margin: 0 0 16px;" align="initial">And the result is exception</p>
<div class="gl-relative markdown-code-block js-markdown-code">
<pre class="code highlight js-syntax-highlight language-plaintext" v-pre="true" style='display: block; font-size: 14px; color: #28272d; line-height: 1.6em; overflow-x: auto; border-radius: .25rem; position: relative; font-family: "GitLab Mono","JetBrains Mono","Menlo","DejaVu Sans Mono","Liberation Mono","Consolas","Ubuntu Mono","Courier New","andale mono","lucida console",monospace; word-break: break-all; word-wrap: break-word; background-color: #fbfafd; margin: 0 0 16px; padding: 12px; border: 1px solid #dcdcde;'><code style='font-size: inherit; color: inherit; word-wrap: normal; word-break: keep-all; background-color: inherit; border-radius: .25rem; white-space: pre; margin-top: 0; font-family: "GitLab Mono","JetBrains Mono","Menlo","DejaVu Sans Mono","Liberation Mono","Consolas","Ubuntu Mono","Courier New","andale mono","lucida console",monospace; vertical-align: bottom; overflow-wrap: normal; padding: unset;'><span id="LC1" class="line" lang="plaintext" style="margin-top: 0;">SHLL [/] # dlopen bin/appdl_print-riscv64.o</span>
<span id="LC2" class="line" lang="plaintext"></span>
<span id="LC3" class="line" lang="plaintext">*** FATAL ***</span>
<span id="LC4" class="line" lang="plaintext">fatal source: 9 (RTEMS_FATAL_SOURCE_EXCEPTION)</span>
<span id="LC5" class="line" lang="plaintext">CPU: 0</span>
<span id="LC6" class="line" lang="plaintext">mstatus 0x8000000a00007880</span>
<span id="LC7" class="line" lang="plaintext">mcause 0x0000000000000004</span>
<span id="LC8" class="line" lang="plaintext">mepc 0x00000010000271a8</span>
<span id="LC9" class="line" lang="plaintext">ra 0x000000100002949c</span>
<span id="LC10" class="line" lang="plaintext">sp 0x00000010000d9ef0</span>
<span id="LC11" class="line" lang="plaintext">gp 0x0000001000093800</span>
<span id="LC12" class="line" lang="plaintext">tp 0x00000010000dabc8</span>
<span id="LC13" class="line" lang="plaintext">t0 0x0000000000000000</span>
<span id="LC14" class="line" lang="plaintext">t1 0x0000000000000001</span>
<span id="LC15" class="line" lang="plaintext">t2 0xffffffffffffffff</span>
<span id="LC16" class="line" lang="plaintext">s0 0x00000010001b97e6</span>
<span id="LC17" class="line" lang="plaintext">s1 0x00000010001b8660</span>
<span id="LC18" class="line" lang="plaintext">a0 0xffffffffffe986c2</span>
<span id="LC19" class="line" lang="plaintext">a1 0x0000001000089e48</span>
<span id="LC20" class="line" lang="plaintext">a2 0x00000010001b8940</span>
<span id="LC21" class="line" lang="plaintext">a3 0x0000006000000013</span>
<span id="LC22" class="line" lang="plaintext">a4 0x00000010000271a8</span>
<span id="LC23" class="line" lang="plaintext">a5 0x0000000000051ea8</span>
<span id="LC24" class="line" lang="plaintext">a6 0x00000010001a67a6</span>
<span id="LC25" class="line" lang="plaintext">a7 0x0000000000051ea8</span>
<span id="LC26" class="line" lang="plaintext">s2 0x0000000000051ea8</span>
<span id="LC27" class="line" lang="plaintext">s3 0x00000010000da008</span>
<span id="LC28" class="line" lang="plaintext">s4 0x00000010001a67a6</span>
<span id="LC29" class="line" lang="plaintext">s5 0x00000010001b88e0</span>
<span id="LC30" class="line" lang="plaintext">s6 0x00000010001b0ea0</span>
<span id="LC31" class="line" lang="plaintext">s7 0x0000000000000018</span>
<span id="LC32" class="line" lang="plaintext">s8 0x0000000000000060</span>
<span id="LC33" class="line" lang="plaintext">s9 0x0000000000000004</span>
<span id="LC34" class="line" lang="plaintext">s10 0x0000000000000001</span>
<span id="LC35" class="line" lang="plaintext">s11 0x00000010001b8d60</span>
<span id="LC36" class="line" lang="plaintext">t3 0x0000000000000038</span>
<span id="LC37" class="line" lang="plaintext">t4 0x0000000000000000</span>
<span id="LC38" class="line" lang="plaintext">t5 0x000000580000003c</span>
<span id="LC39" class="line" lang="plaintext">t6 0x0000000000000038</span>
<span id="LC40" class="line" lang="plaintext">fcsr 0x00000000</span>
<span id="LC41" class="line" lang="plaintext">RTEMS version: 6.0.0.e049757c58-modified</span>
<span id="LC42" class="line" lang="plaintext">RTEMS tools: 13.3.0 20240521 (RTEMS 6, RSB e52d2288c8a0df64466010839ca1eb40c6d243ed, Newlib 1b3dcfd)</span>
<span id="LC43" class="line" lang="plaintext">executing thread ID: 0x0a010004</span>
<span id="LC44" class="line" lang="plaintext">executing thread name: SHLL</span></code></pre>
<copy-code></copy-code><insert-code-snippet></insert-code-snippet>
</div>
<p dir="auto" style="color: #28272d; margin: 0 0 16px;" align="initial">I do not have JTAG cable with special connector yet. So I have trued to decode problem from the reported mepc. GDB decodes location as</p>
<div class="gl-relative markdown-code-block js-markdown-code">
<pre class="code highlight js-syntax-highlight language-plaintext" v-pre="true" style='display: block; font-size: 14px; color: #28272d; line-height: 1.6em; overflow-x: auto; border-radius: .25rem; position: relative; font-family: "GitLab Mono","JetBrains Mono","Menlo","DejaVu Sans Mono","Liberation Mono","Consolas","Ubuntu Mono","Courier New","andale mono","lucida console",monospace; word-break: break-all; word-wrap: break-word; background-color: #fbfafd; margin: 0 0 16px; padding: 12px; border: 1px solid #dcdcde;'><code style='font-size: inherit; color: inherit; word-wrap: normal; word-break: keep-all; background-color: inherit; border-radius: .25rem; white-space: pre; margin-top: 0; font-family: "GitLab Mono","JetBrains Mono","Menlo","DejaVu Sans Mono","Liberation Mono","Consolas","Ubuntu Mono","Courier New","andale mono","lucida console",monospace; vertical-align: bottom; overflow-wrap: normal; padding: unset;'><span id="LC1" class="line" lang="plaintext" style="margin-top: 0;">0x10000271a8 <rtems_rtl_elf_relocate_rela+270>: lw a4,0(s0)</span></code></pre>
<copy-code></copy-code><insert-code-snippet></insert-code-snippet>
</div>
<p dir="auto" style="color: #28272d; margin: 0 0 16px;" align="initial">If I try to decode to line <code style='font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; margin-top: 0; font-weight: inherit; font-family: "GitLab Mono","JetBrains Mono","Menlo","DejaVu Sans Mono","Liberation Mono","Consolas","Ubuntu Mono","Courier New","andale mono","lucida console",monospace; vertical-align: bottom; white-space: pre-wrap; overflow-wrap: break-word; word-break: keep-all; padding: 2px 4px;'>l * 0x10000271a8</code></p>
<p dir="auto" style="color: #28272d; margin: 0 0 16px;" align="initial">then it points to the function <code style='font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; margin-top: 0; font-weight: inherit; font-family: "GitLab Mono","JetBrains Mono","Menlo","DejaVu Sans Mono","Liberation Mono","Consolas","Ubuntu Mono","Courier New","andale mono","lucida console",monospace; vertical-align: bottom; white-space: pre-wrap; overflow-wrap: break-word; word-break: keep-all; padding: 2px 4px;'>rtems_rtl_elf_relocate_rela</code></p>
<div class="gl-relative markdown-code-block js-markdown-code">
<pre class="code highlight js-syntax-highlight language-plaintext" v-pre="true" style='display: block; font-size: 14px; color: #28272d; line-height: 1.6em; overflow-x: auto; border-radius: .25rem; position: relative; font-family: "GitLab Mono","JetBrains Mono","Menlo","DejaVu Sans Mono","Liberation Mono","Consolas","Ubuntu Mono","Courier New","andale mono","lucida console",monospace; word-break: break-all; word-wrap: break-word; background-color: #fbfafd; margin: 0 0 16px; padding: 12px; border: 1px solid #dcdcde;'><code style='font-size: inherit; color: inherit; word-wrap: normal; word-break: keep-all; background-color: inherit; border-radius: .25rem; white-space: pre; margin-top: 0; font-family: "GitLab Mono","JetBrains Mono","Menlo","DejaVu Sans Mono","Liberation Mono","Consolas","Ubuntu Mono","Courier New","andale mono","lucida console",monospace; vertical-align: bottom; overflow-wrap: normal; padding: unset;'><span id="LC1" class="line" lang="plaintext" style="margin-top: 0;">0x10000271a8 is in rtems_rtl_elf_relocate_rela (../../../../../git/rtems/cpukit/libdl/rtl-mdreloc-riscv.c:128).</span></code></pre>
<copy-code></copy-code><insert-code-snippet></insert-code-snippet>
</div>
<p dir="auto" style="color: #28272d; margin: 0 0 16px;" align="initial">But if I try next location then it points to</p>
<div class="gl-relative markdown-code-block js-markdown-code">
<pre class="code highlight js-syntax-highlight language-plaintext" v-pre="true" style='display: block; font-size: 14px; color: #28272d; line-height: 1.6em; overflow-x: auto; border-radius: .25rem; position: relative; font-family: "GitLab Mono","JetBrains Mono","Menlo","DejaVu Sans Mono","Liberation Mono","Consolas","Ubuntu Mono","Courier New","andale mono","lucida console",monospace; word-break: break-all; word-wrap: break-word; background-color: #fbfafd; margin: 0 0 16px; padding: 12px; border: 1px solid #dcdcde;'><code style='font-size: inherit; color: inherit; word-wrap: normal; word-break: keep-all; background-color: inherit; border-radius: .25rem; white-space: pre; margin-top: 0; font-family: "GitLab Mono","JetBrains Mono","Menlo","DejaVu Sans Mono","Liberation Mono","Consolas","Ubuntu Mono","Courier New","andale mono","lucida console",monospace; vertical-align: bottom; overflow-wrap: normal; padding: unset;'><span id="LC1" class="line" lang="plaintext" style="margin-top: 0;">0x10000271aa is in rtems_rtl_elf_relocate_rela (../../../../../git/rtems/cpukit/libdl/rtl-mdreloc-riscv.c:364).</span>
<span id="LC2" class="line" lang="plaintext"></span></code></pre>
<copy-code></copy-code><insert-code-snippet></insert-code-snippet>
</div>
<div class="gl-relative markdown-code-block js-markdown-code">
<pre class="code highlight js-syntax-highlight language-plaintext" v-pre="true" style='display: block; font-size: 14px; color: #28272d; line-height: 1.6em; overflow-x: auto; border-radius: .25rem; position: relative; font-family: "GitLab Mono","JetBrains Mono","Menlo","DejaVu Sans Mono","Liberation Mono","Consolas","Ubuntu Mono","Courier New","andale mono","lucida console",monospace; word-break: break-all; word-wrap: break-word; background-color: #fbfafd; margin: 0 0 16px; padding: 12px; border: 1px solid #dcdcde;'><code style='font-size: inherit; color: inherit; word-wrap: normal; word-break: keep-all; background-color: inherit; border-radius: .25rem; white-space: pre; margin-top: 0; font-family: "GitLab Mono","JetBrains Mono","Menlo","DejaVu Sans Mono","Liberation Mono","Consolas","Ubuntu Mono","Courier New","andale mono","lucida console",monospace; vertical-align: bottom; overflow-wrap: normal; padding: unset;'><span id="LC1" class="line" lang="plaintext" style="margin-top: 0;">359 case R_TYPE(CALL): {</span>
<span id="LC2" class="line" lang="plaintext">360 int64_t hi = SignExtend64(pcrel_val + 0x800, bits);</span>
<span id="LC3" class="line" lang="plaintext">361 write32le(where, (read32le(where) & 0xFFF) | (hi & 0xFFFFF000));</span>
<span id="LC4" class="line" lang="plaintext">362 int64_t hi20 = SignExtend64(pcrel_val + 0x800, bits);</span>
<span id="LC5" class="line" lang="plaintext">363 int64_t lo = pcrel_val - (hi20 << 12);</span>
<span id="LC6" class="line" lang="plaintext">364 write32le(((char *) where) + 4, (read32le(((char *) where) + 4) & 0xFFFFF) | ((lo & 0xFFF) << 20));</span>
<span id="LC7" class="line" lang="plaintext">365 }</span>
<span id="LC8" class="line" lang="plaintext">366 break;</span></code></pre>
<copy-code></copy-code><insert-code-snippet></insert-code-snippet>
</div>
<p dir="auto" style="color: #28272d; margin: 0 0 16px;" align="initial">I have found way how to convert RTEMS generate ELF to HSS payload relatively easily by direct call of <code style='font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; margin-top: 0; font-weight: inherit; font-family: "GitLab Mono","JetBrains Mono","Menlo","DejaVu Sans Mono","Liberation Mono","Consolas","Ubuntu Mono","Courier New","andale mono","lucida console",monospace; vertical-align: bottom; white-space: pre-wrap; overflow-wrap: break-word; word-break: keep-all; padding: 2px 4px;'>hss-payload-generator</code>.</p>
<p dir="auto" style="color: #28272d; margin: 0 0 16px;" align="initial">I use <code style='font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; margin-top: 0; font-weight: inherit; font-family: "GitLab Mono","JetBrains Mono","Menlo","DejaVu Sans Mono","Liberation Mono","Consolas","Ubuntu Mono","Courier New","andale mono","lucida console",monospace; vertical-align: bottom; white-space: pre-wrap; overflow-wrap: break-word; word-break: keep-all; padding: 2px 4px;'>rtems-config.yaml</code>:</p>
<div class="gl-relative markdown-code-block js-markdown-code">
<pre class="code highlight js-syntax-highlight language-plaintext" v-pre="true" style='display: block; font-size: 14px; color: #28272d; line-height: 1.6em; overflow-x: auto; border-radius: .25rem; position: relative; font-family: "GitLab Mono","JetBrains Mono","Menlo","DejaVu Sans Mono","Liberation Mono","Consolas","Ubuntu Mono","Courier New","andale mono","lucida console",monospace; word-break: break-all; word-wrap: break-word; background-color: #fbfafd; margin: 0 0 16px; padding: 12px; border: 1px solid #dcdcde;'><code style='font-size: inherit; color: inherit; word-wrap: normal; word-break: keep-all; background-color: inherit; border-radius: .25rem; white-space: pre; margin-top: 0; font-family: "GitLab Mono","JetBrains Mono","Menlo","DejaVu Sans Mono","Liberation Mono","Consolas","Ubuntu Mono","Courier New","andale mono","lucida console",monospace; vertical-align: bottom; overflow-wrap: normal; padding: unset;'><span id="LC1" class="line" lang="plaintext" style="margin-top: 0;">set-name: 'PolarFire-SoC-HSS::RTEMSImage'</span>
<span id="LC2" class="line" lang="plaintext">hart-entry-points: {u54_1: '0x1000000000', u54_2: '0x1000000000', u54_3: '0x1000000000', u54_4: '0x1000000000'}</span>
<span id="LC3" class="line" lang="plaintext">payloads:</span>
<span id="LC4" class="line" lang="plaintext"> rtems-app.elf: {exec-addr: '0x1000000000', owner-hart: u54_1, secondary-hart: u54_2, secondary-hart: u54_3, secondary-hart: u54_4, priv-mode: prv_m, skip-opensbi: true, payload-name: "rtems-app"}</span></code></pre>
<copy-code></copy-code><insert-code-snippet></insert-code-snippet>
</div>
<p dir="auto" style="color: #28272d; margin: 0 0 16px;" align="initial">and then run in terminal</p>
<div class="gl-relative markdown-code-block js-markdown-code" style="margin-bottom: 0;">
<pre class="code highlight js-syntax-highlight language-plaintext" v-pre="true" style='display: block; font-size: 14px; color: #28272d; line-height: 1.6em; overflow-x: auto; border-radius: .25rem; position: relative; font-family: "GitLab Mono","JetBrains Mono","Menlo","DejaVu Sans Mono","Liberation Mono","Consolas","Ubuntu Mono","Courier New","andale mono","lucida console",monospace; word-break: break-all; word-wrap: break-word; background-color: #fbfafd; margin: 0 0 16px; padding: 12px; border: 1px solid #dcdcde;'><code style='font-size: inherit; color: inherit; word-wrap: normal; word-break: keep-all; background-color: inherit; border-radius: .25rem; white-space: pre; margin-top: 0; font-family: "GitLab Mono","JetBrains Mono","Menlo","DejaVu Sans Mono","Liberation Mono","Consolas","Ubuntu Mono","Courier New","andale mono","lucida console",monospace; vertical-align: bottom; overflow-wrap: normal; padding: unset;'><span id="LC1" class="line" lang="plaintext" style="margin-top: 0;">hss-payload-generator -c rtems-config.yaml rtems-payload.bin</span></code></pre>
<copy-code></copy-code><insert-code-snippet></insert-code-snippet>
</div>
</div>
</div>
<div class="footer" style="margin-top: 10px;">
<p style="font-size: small; color: #737278;">
—
<br>
<a href="https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/312#note_115090">View it on GitLab</a>.
<br>
You're receiving this email because of your account on <a target="_blank" rel="noopener noreferrer" href="https://gitlab.rtems.org">gitlab.rtems.org</a>. <a href="https://gitlab.rtems.org/-/sent_notifications/56c1b60ee35b8b4620e7bf144bde2f0d/unsubscribe" target="_blank" rel="noopener noreferrer">Unsubscribe</a> from this thread · <a href="https://gitlab.rtems.org/-/profile/notifications" target="_blank" rel="noopener noreferrer" class="mng-notif-link">Manage all notifications</a> · <a href="https://gitlab.rtems.org/help" target="_blank" rel="noopener noreferrer" class="help-link">Help</a>
<script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","action":{"@type":"ViewAction","name":"View Merge request","url":"https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/312#note_115090"}}</script>
</p>
</div>
</body>
</html>