This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Show number of padding bytes in data structures
- From: Paul Koning <pkoning at equallogic dot com>
- To: frank dot winklmeier at cern dot ch
- Cc: binutils at sourceware dot org
- Date: Wed, 2 May 2007 12:11:10 -0400
- Subject: Re: Show number of padding bytes in data structures
- References: <4638B3B8.9090908@cern.ch>
>>>>> "Frank" == Frank Winklmeier <frank.winklmeier@cern.ch> writes:
Frank> Hi, is there any way of using one of the binutils to show the
Frank> additional padding bytes that a compiler inserted into a
Frank> struct/class to make it align according to the systems memory
Frank> alignment rules? Or is this information lost once the compiler
Frank> has done its job?
Frank> For example, for the following data structure compiled on x64,
Frank> I would expect the tool to tell me that the compiler added 4
Frank> padding bytes:
Frank> class MyData { int i; double d; };
I don't know about any binutils. You can easily do this in gdb if
your binary still contains the necessary debug data.
For example:
print ((int)(((MyData *)0)->d))-((int)((((MyData *)0)->i)+1))
will do the job for the example you gave.
paul