title: GCC refuses to emit long calls for operator new/delete on PowerPC
body: <p>PowerPC branches only have 24 bits available for the target offset, so if the text section gets too big, branches on one end won't be able to reach targets on the other. There's a longer sequence of instructions that can reach targets farther away (the offset is 32 bits instead of 24), but GCC doesn't use it by default unless you pass it the <code>-mlongcall</code> option. However, even with this option on, GCC still generates short calls for certain functions, namely <code>operator new</code> and <code>operator delete</code></p>
  
  <p>For example, given this code:</p>
  
  <pre><code>extern void foo();
  
  int main(int argc, char** argv) {
      foo();
      new char;
  }
  </code></pre>
  
  <p>A normal run of GCC will generate the assembly:</p>
  
  <pre><code>bl _Z3foov // void foo()
  bl _Znwj   // operator new(unsigned int)
  </code></pre>
  
  <p>Running GCC with the <code>-mlongcall</code> option generates:</p>
  
  <pre><code>lis r9, _Z3foov@ha
  addi r9, r9, _Z3foov@l
  mtctr r9
  bctrl
  bl _Znwj
  </code></pre>
  
  <p>The first four instructions are a long call to <code>foo()</code>, as expected, but the call to <code>operator new</code> is unchanged. Calls to random libc and libstdc++ functions are all converted to long calls as expected. Why do <code>operator new</code> and <code>operator delete</code> calls still end up as <code>bl</code> instructions? Is there any way to force GCC to make them long calls as well? I'm using GCC 4.7.2 on a 64-bit PowerPC Fedora machine (although I'm building 32-bit)</p>