How to get the relative address of a field in a structure dump. [C]

后端 未结 4 527
鱼传尺愫
鱼传尺愫 2021-01-31 11:50

We\'re working on a C program compiled with arm-eabi-gcc under Linux.

We\'re using a dump of a large structure and we\'re having problems determining at which adress we

4条回答
  •  粉色の甜心
    2021-01-31 12:54

    Seems to me you could write a bit of code like this for the required fields

    struct MyStruct S;
    int Offset_of_X=((long)&(S.X))-((long)&S);
    

    to calculate the offset in bytes in this compile situation.

    This should account for any alignment issues the compiler has.

提交回复
热议问题