reordering procedures

Ian Lance Taylor
Mon Oct 18 12:49:00 GMT 1999

   Date: Sat, 16 Oct 1999 19:08:10 -0400
   From: Charles Lefurgy <>

   I'm doing some code layout experiments.  I would like to use binutils
   (BFD) to re-order procedures in a binary executable (mips-coff).

   Is it even possible?  If so, is there an easy way to do this?  What
   are the steps involved?  What about relocations?

You can reorder sections easily enough--the linker script language
permits you to do that in various ways--but you can not in general
reorder procedures within a single section.  In certain specific cases
it may be possible.  However, BFD will not help you very much.

I assume that by mips-coff you mean ECOFF.  ECOFF is a poor choice for
this sort of work because it does not permit arbitrary sections.  I
recommend using ELF, and the gcc -ffunction-sections option to put
each function in a different section.  It will then be more or less
straightforward to generate a linker script which puts the sections in
whatever order you like.


More information about the Binutils mailing list