title: segmentation fault when trying to execute a function from a shared object file with gdb
body: <p>I'm trying to make the inferior call a function from a <code>.so</code> file with gdb.</p>
  
  <p>I've wrote a simple <code>test.c</code> to simplify the problem:</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  
  void asdasdasd()
  {
      printf("asdasdasd");
  }
  </code></pre>
  
  <p>Then compiled it to a <code>.so</code> file by doing <code>gcc -shared -g -o test.so -fPIC test.c</code>. Then attached to the target process with gdb and loaded the <code>.so</code> file I have created by doing <code>symbol-file /home/korcan/PINCE/Injection/test.so</code>. It has been loaded successfully(I understood it by pressing the <code>Tab</code> after writing <code>call asd</code>, it auto-completed).</p>
  
  <p>And here comes the problem, whenever I try to execute a function from the <code>test.so</code>, gdb gives this error:</p>
  
  <pre><code>Program received signal SIGSEGV, Segmentation fault.
  asdasdasd () at test.c:4
  4       {
  The program being debugged was signaled while in a function called from GDB.
  GDB remains in the frame where the signal was received.
  To change this behavior use "set unwindonsignal on".
  Evaluation of the expression containing the function
  (asdasdasd) will be abandoned.
  When the function is done executing, GDB will silently stop.
  </code></pre>
  
  <p>I've wrote a few more test files after this attempt to understand what's going wrong and it seems like gdb always gives segmentation fault at the first line of the function, it's always like this:</p>
  
  <pre><code>Program received signal SIGSEGV, Segmentation fault.
  functionname () at test.c:linenumber
  linenumber       {
  </code></pre>