Logowww.asingh.netHomeNewsBioInterestsTechnicalSearchContact



 Archive :

  May 2006
  June 2006
  July 2006
  July 2007
  August 2007
  April 2008
  June 2008
  December 2008
  January 2009
  March 2009
  June 2009
  January 2010
 

Modifying Hardware Capability (HCAP) Bits of an Object File

Many times in order to optimize software performance programmers use specific compiler flags that generate code tuned to a given hardware architecture. In fact, at times we'd write tight loops in assembly using processor specific instructions to squeeze that extra bit of performance. The peripheral code in "c" or C++ can then call this assembly routine to do the actual intensive work. Further to make the program portable to other platforms code could be enhanced to call different assembly routines based on runtime detection of the hardware architecture. I remember having used an array of function pointers with a separate assembly routine for each kind of platform/processor.

The problem is that if hardware specific instructions gets executed on a different processor the results may be undefined - including the possibility of program getting killed by SIGILL (illegal instruction signal). Well this is where SunStudio comes in - it programs HCAP bits that tell the linker at runtime about presence of such instructions in the binary. At run time the linker would give a message like "fatal: hardware capability unsupported" on detecting such a scenario. Now what if, the hardware specific instructions were never going to get executed on this processor based on program logic, as in the example above? Well, in this case instead of getting forced to create multiple binaries, one can modify the bits in the program binary that tell the linker about the presence of these hardware specific capabilities. Checkout this article and blog that teach how to modify these (HCAP) bits.

posted by Amandeep 8/22/2007 07:01:00 PM | PERMALINK

 

 

| Home | News | Bio | Interests | Technical | Search | Contact |

This page is powered

by Blogger.