title: Unable to printf floating point numbers from executable shared library
body: <p>I'm developing a shared library which can be executed independently to print it's own version number.</p>
  
  <p>I've defined a custom entry point as:</p>
  
  <pre><code>const char my_interp[] __attribute__((section(".interp"))) = "/lib64/ld-linux-x86-64.so.2";
  
  void my_main() {
     printf("VERSION: %d\n", 0);
     _exit(0);
  }
  </code></pre>
  
  <p>and I compile with </p>
  
  <pre><code>gcc -o list.os -c -g -Wall -fPIC list.c
  gcc -o liblist.so -g -Wl,-e,my_main -shared list.os -lc
  </code></pre>
  
  <p>This code <strong>compiles</strong> and <strong>runs</strong> perfectly. </p>
  
  <p>My issue is when I change the parameter of the printf to be a float or double (%f or %lf). The library will then compile but <strong>segfault</strong> when run.</p>
  
  <p>Anyone have any ideas?</p>
  
  <p><em><strong>edit1:</em></strong></p>
  
  <p>Here is the code that segfaults:</p>
  
  <pre><code>const char my_interp[] __attribute__((section(".interp"))) = "/lib64/ld-linux-x86-64.so.2"; 
  
  void my_main() { 
      printf("VERSION: %f\n", 0.1f); 
      _exit(0); 
  } 
  </code></pre>
  
  <p><em><strong>edit2:</em></strong></p>
  
  <p>Additional environmental details:</p>
  
  <pre><code>uname -a
  </code></pre>
  
  <p>Linux mjolnir.site 3.1.10-1.16-desktop #1 SMP PREEMPT Wed Jun 27 05:21:40 UTC 2012 (d016078) x86_64 x86_64 x86_64 GNU/Linux</p>
  
  <pre><code>gcc --version
  </code></pre>
  
  <p>gcc (SUSE Linux) 4.6.2</p>
  
  <pre><code>/lib64/libc.so.6
  </code></pre>
  
  <p>Configured for x86_64-suse-linux.
  Compiled by GNU CC version 4.6.2.
  Compiled on a Linux 3.1.0 system on 2012-03-30.</p>
  
  <p><em><strong>edit 3:</em></strong></p>
  
  <p>Output in /var/log/messages upon segfault:</p>
  
  <p>Aug 11 08:27:45 mjolnir kernel: [10560.068741] liblist.so[11222] general protection ip:7fc2b3cb2314 sp:7fff4f5c7de8 error:0 in libc-2.14.1.so[7fc2b3c63000+187000]</p>