How to link function at specific address

arpa
2007-10-18
2013-03-12
  • arpa

    arpa - 2007-10-18

    How can I get the linker to locate a specific function to a specific address?

     
    • Maarten Brock

      Maarten Brock - 2007-10-19

      1. You could write it in assembler using an ABSolute area and a .org address.
      2. You could put the function in a separate source file and compile it with a named code segment (--codeseg MYCODE or #pragma codeseg MYCODE) and tell the linker where to put that segment with -Wl,bMYCODE=0xaaaa.
      3. You could use a trampoline/jumptable written in assembler and put that at the specific address.

      But the real question is: WHY do you want to put a function at a specific address? Do you want to share it between different programs? If so, have you thought about the variables (RAM) it uses?

       

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks