title: Use another ELF file's symbol table for symbol resolution when linking
body: <p>I am writing an operating system. I currently compile my kernel to a file called <code>kernel.elf</code>, and it's symbol table contains functions such as <code>tty_printf</code> and it's address in memory.</p>
  <p>I wrote an ELF loader to load a separate program from disk, and I want to be able to call kernel functions from this program.</p>
  <p>The only way I've been able to do this is declaring a function pointer with the function address that I get from reading the symbol table from my kernel:</p>
  <pre><code>void (*tty_printf)(const char*, ...) = 0x9E80;
  
  void main() {
      tty_printf(&quot;Hello, World!\n&quot;);
      asm (&quot;cli; hlt&quot;);
  }
  </code></pre>
  <p>I know this entire idea is not ideal, and I should just be using system calls, but because it is just a small hobby project and some other reasons, I don't want to bother with entering ring 3 right now.</p>
  <p>So, I want to know if there's a way that I can just declare the function, like this</p>
  <pre><code>void tty_printf(const char*, ...);
  </code></pre>
  <p>and have the linker resolve it's address based on my <code>kernel.elf</code> symbol table, so I don't have to manually replace this and every other function's address every time I make a change to my kernel.</p>
  <p>Thank you.</p>