This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Frame pointer register name


On Jan 15, 2011, at 10:48 PM, Ian Lance Taylor wrote:

> Amittai Aviram <amittai.aviram@yale.edu> writes:
> 
>> I am creating a GCC (4.5.2) that uses a modified libgomp.  My libgomp has a file that contains the following line of code:
>> 
>>      asm volatile("mov %%rbp, %0" : "=m"  (rbp) );
>> 
>> I attempted to compile this on a 64-bit machine running under 64-bit Ubuntu:
>> 
>> $ uname -a
>> 
>> Linux dedis 2.6.32-27-server #49-Ubuntu SMP Thu Dec 2 02:05:21 UTC 2010 x86_64 GNU/Linux
>> 
>> But my build failed, with the assembler error that "rbp" was an unrecognized register name.  I changed this to ebp, and it compiled fine.  However, my code then failed, presumably because it was getting an invalid address.
>> 
>> I figured out a workaround that seems fine, but I wanted to know why I was getting this assembler error and what I should have done about it.
> 
> You got the assembler error in 32-bit mode because in the x86 assembly
> language rbp refers to the 64-bit version of the register and ebp refers
> to the 32-bit version (and bp refers to the 16-bit version).  In 32-bit
> mode there is no 64-bit version of the register and therefore rbp is
> invalid.
> 
> Ian

Oh, I see!  The build includes both 64-bit and 32-bit modes (so that the -m32 option will work), so I get the error when the build process gets to that point.  What preprocessor symbol can I use in my code to identify 64 versus 32 bit modes for conditional compilation?  Do GCC's Makefiles set __x86_64__ and __i386__?  Thanks!

Amittai Aviram
PhD Student in Computer Science
Yale University
646 483 2639
amittai.aviram@yale.edu
http://www.amittai.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]