<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>i.MX RT Crossover MCUsのトピックRe: Position independent code libgcc, libc_nano, libstdc++, libm, etc</title>
    <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/Position-independent-code-libgcc-libc-nano-libstdc-libm-etc/m-p/1451592#M19410</link>
    <description>&lt;P&gt;Ran into &lt;A href="https://community.nxp.com/t5/LPC-Microcontrollers/custom-build-of-newlib-nano-in-MCUXpresso/td-p/1196613" target="_self"&gt;this question&lt;/A&gt;, it seems to confirm my hypothesis that libc_nano is not compiled with -fpic.&lt;/P&gt;&lt;P&gt;I think I need help to obtain or compile libc_nano with -fpic.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 30 Apr 2022 19:37:33 GMT</pubDate>
    <dc:creator>bp1979</dc:creator>
    <dc:date>2022-04-30T19:37:33Z</dc:date>
    <item>
      <title>Position independent code libgcc, libc_nano, libstdc++, libm, etc</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/Position-independent-code-libgcc-libc-nano-libstdc-libm-etc/m-p/1451589#M19409</link>
      <description>&lt;P&gt;I have a working prototype of position independent code, where I can copy my binary to any location in flash, and jump to it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;While testing my app on different locations I ran into an issue. When I only deploy "app2" (thus, I do not write the app to flash on the originally linked location, but I upload the app to some offset location), then my application crashes as soon as it calls `__libc_init_array()` in startup code.&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I upload the app on the originally linked location, and again make my bootloader jump to app2, then it works fine.&lt;/P&gt;&lt;P&gt;So it seems that&amp;nbsp;"libc_nano.a" isn't suitable for position independent code. I have the following library dependencies (taken over from the initially generated linker script by mcuxpresso)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;GROUP (
  "libgcc.a"
  "libc_nano.a"
  "libstdc++_nano.a"
  "libm.a"
  "libcr_newlib_nohost.a"
  "crti.o"
  "crtn.o"
  "crtbegin.o"
  "crtend.o"
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The c runtime object files are compatible for both pic and non pic, I understand from reading &lt;A href="https://docs.oracle.com/cd/E88353_01/html/E37853/crti.o-7.html" target="_self"&gt;this oracle&lt;/A&gt; page.&lt;/P&gt;&lt;P&gt;When I comment the line&amp;nbsp;`__libc_init_array()` in my startup code, my app2 starts fine, even without having app1 available in flash. So I am sure the only problematic line is this one.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a solution for this? Should I compile libc_nano myself with -fpic? And if that's the way to go, where do I find the sources of the libraries nxp is providing me here? I found this &lt;A href="https://github.com/32bitmicro/newlib-nano-1.0" target="_self"&gt;github repo&lt;/A&gt;, but not sure if you compiled it from these sources.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 30 Apr 2022 18:47:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/Position-independent-code-libgcc-libc-nano-libstdc-libm-etc/m-p/1451589#M19409</guid>
      <dc:creator>bp1979</dc:creator>
      <dc:date>2022-04-30T18:47:20Z</dc:date>
    </item>
    <item>
      <title>Re: Position independent code libgcc, libc_nano, libstdc++, libm, etc</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/Position-independent-code-libgcc-libc-nano-libstdc-libm-etc/m-p/1451592#M19410</link>
      <description>&lt;P&gt;Ran into &lt;A href="https://community.nxp.com/t5/LPC-Microcontrollers/custom-build-of-newlib-nano-in-MCUXpresso/td-p/1196613" target="_self"&gt;this question&lt;/A&gt;, it seems to confirm my hypothesis that libc_nano is not compiled with -fpic.&lt;/P&gt;&lt;P&gt;I think I need help to obtain or compile libc_nano with -fpic.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 30 Apr 2022 19:37:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/Position-independent-code-libgcc-libc-nano-libstdc-libm-etc/m-p/1451592#M19410</guid>
      <dc:creator>bp1979</dc:creator>
      <dc:date>2022-04-30T19:37:33Z</dc:date>
    </item>
    <item>
      <title>Re: Position independent code libgcc, libc_nano, libstdc++, libm, etc</title>
      <link>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/Position-independent-code-libgcc-libc-nano-libstdc-libm-etc/m-p/1452574#M19425</link>
      <description>&lt;P&gt;I managed to workaround the first issue by copying the implementation of `__libc_init_array` from &lt;A href="https://github.com/picolibc/picolibc" target="_self"&gt;picolib&lt;/A&gt;. The next call I do towards libc_nano, will hard fault the application again.&lt;/P&gt;&lt;P&gt;Is there something I need to do specifically for the included libs? Are they linked against the .got automatically? Can you share an example please?&lt;/P&gt;</description>
      <pubDate>Wed, 04 May 2022 07:39:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-RT-Crossover-MCUs/Position-independent-code-libgcc-libc-nano-libstdc-libm-etc/m-p/1452574#M19425</guid>
      <dc:creator>bp1979</dc:creator>
      <dc:date>2022-05-04T07:39:13Z</dc:date>
    </item>
  </channel>
</rss>

