This is the mail archive of the binutils@sourceware.org mailing list for the binutils 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: Show number of padding bytes in data structures


>>>>> "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


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