<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>Am I confused, or Did Clay ask about Microchip and Dave gave him
      the answer for ST chips?<br>
      <br>
      I do not check the list very often. So sorry for the delay. <br>
      <br>
      Clay did you find the answer you wanted? if not I can probably
      help with a little research. <br>
      <br>
      I think there is an ABSOLUTE macro when you define the variable
      that lets you define the address of the variable. They use it in
      the .h files that you include for HW, as many of them are memory
      mapped. I do not have a Microchip project handy to look, but if
      you are still having problems let me know. I think it will take 30
      minutes to get the exact answer. <br>
      <br>
      It is documented in the Compiler Reference for the compiler you
      are using C8, C16, C32. Go to the compiler directory and find the
      docs subdirectory and get the PDF. <br>
    </p>
    <p>Kip<br>
      <br>
    </p>
    <div class="moz-cite-prefix">On 1/30/20 11:32 PM, Dave Hylands via
      DPRGlist wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CABi1daF_UPMCVvZKuy94+J8JQqjymZbhvvZ0hOx-CN6b98-=-g@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">You need to create a linker script file and use
        that to control where things go.
        <div><br>
        </div>
        <div>The linker controls things using object files and sections.
          By default, functions go into .text sections. There are
          compiler options which cause each function to go into a
          separate section.</div>
        <div><br>
        </div>
        <div>The syntax in the linker script files is a bit arcane.<br>
        </div>
        <div><a
href="https://ftp.gnu.org/old-gnu/Manuals/ld-2.9.1/html_chapter/ld_3.html#SEC6"
            moz-do-not-send="true">https://ftp.gnu.org/old-gnu/Manuals/ld-2.9.1/html_chapter/ld_3.html#SEC6</a><br>
        </div>
        <div><br>
        </div>
        <div>Here's an example linker file used on an STM32F103
          microcontroller and it places the isr vectors at address
          0x8002000.</div>
        <div><a
href="https://github.com/dhylands/stm32-test/blob/master/board-STM32F103-Mini/STM32F103RBTx_FLASH.ld"
            moz-do-not-send="true">https://github.com/dhylands/stm32-test/blob/master/board-STM32F103-Mini/STM32F103RBTx_FLASH.ld</a><br>
        </div>
        <div><br>
        </div>
        <div>This linker file shows putting particular object files into
          a particular section:</div>
        <div><a
href="https://github.com/micropython/micropython/blob/master/ports/stm32/boards/common_ifs.ld#L35"
            moz-do-not-send="true">https://github.com/micropython/micropython/blob/master/ports/stm32/boards/common_ifs.ld#L35</a><br>
        </div>
        <div><br>
        </div>
      </div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">On Thu, Jan 30, 2020 at 12:55
          PM Clayton Timmons via DPRGlist <<a
            href="mailto:dprglist@lists.dprg.org" moz-do-not-send="true">dprglist@lists.dprg.org</a>>
          wrote:<br>
        </div>
        <blockquote class="gmail_quote" style="margin:0px 0px 0px
          0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
          <div dir="ltr">
            <div><br>
            </div>
            <div>I'm searching for an answer to a simple question.  My
              friend Google tried to help but so far Google hasn't given
              me a good answer.   I'm hoping some savvy DPRG member
              probably has the wisdom I seek.       </div>
            <div><br>
            </div>
            <div><br>
            </div>
            <br>
            <div>I'm using a microchip processor writing code in C. 
               The code consists of several C source files which are
              compiled into object code then linked together.  Something
              like this simplified example.</div>
            <div><br>
            </div>
            <div>gcc -c   foo.c             <<<  compile C code
              into object file</div>
            <div>gcc -c   bar.c             <<<  compile C code
              into object file</div>
            <div><br>
            </div>
            <div>gcc   foo.o  bar.o   -o  foobar.cof     <<< 
              link all object files together</div>
            <div><br>
            </div>
            <div>The final output is in cof format which is converted to
              hex format used by the programmer.   There is a map file
              created by the linker which allows me to see where all the
              C functions end up in memory, something like this.</div>
            <div><br>
            </div>
            <div>External Symbols in Program Memory (by address):<br>
              <br>
            </div>
            <div>                     .  .  .</div>
            <div>                  0x003b18                  _foo<br>
                                   .  .  . </div>
            <div>                  0x003e1e                  _bar<br>
               <br>
            </div>
            <div>  <br>
            </div>
            <div>My question is -   How can I force the linker to put a
              specific function at a specific location?     Say I want
              the function bar to start at 0x004000.</div>
            <div><br>
            </div>
            <div>There should be some compiler or linker directives to
              accomplish that.</div>
            <div><br>
            </div>
            <div>Any help is appreciated.</div>
            <div><br>
            </div>
            <div>-Clay Timmons-</div>
            <div><br>
            </div>
            <div><br>
            </div>
            <div><br>
            </div>
            <div><br>
            </div>
            <div><br>
            </div>
            <div><br>
            </div>
            <div><br>
            </div>
            <div><br>
            </div>
            <div> <br>
            </div>
          </div>
          _______________________________________________<br>
          DPRGlist mailing list<br>
          <a href="mailto:DPRGlist@lists.dprg.org" target="_blank"
            moz-do-not-send="true">DPRGlist@lists.dprg.org</a><br>
          <a href="http://lists.dprg.org/listinfo.cgi/dprglist-dprg.org"
            rel="noreferrer" target="_blank" moz-do-not-send="true">http://lists.dprg.org/listinfo.cgi/dprglist-dprg.org</a><br>
        </blockquote>
      </div>
      <br clear="all">
      <div><br>
      </div>
      -- <br>
      <div dir="ltr" class="gmail_signature">
        <div dir="ltr">
          <div>Dave Hylands<br>
            Peachland, BC, Canada<br>
            <a href="http://www.davehylands.com" target="_blank"
              moz-do-not-send="true">http://www.davehylands.com</a></div>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
DPRGlist mailing list
<a class="moz-txt-link-abbreviated" href="mailto:DPRGlist@lists.dprg.org">DPRGlist@lists.dprg.org</a>
<a class="moz-txt-link-freetext" href="http://lists.dprg.org/listinfo.cgi/dprglist-dprg.org">http://lists.dprg.org/listinfo.cgi/dprglist-dprg.org</a>
</pre>
    </blockquote>
  </body>
</html>