Skip to content
This repository has been archived by the owner on Sep 15, 2021. It is now read-only.

ABI alignment #2

Open
tklengyel opened this issue Aug 28, 2017 · 0 comments
Open

ABI alignment #2

tklengyel opened this issue Aug 28, 2017 · 0 comments

Comments

@tklengyel
Copy link

A related issue to ABI types is ABI alignment. Different compilers may decide to align struct members differently if they are not the same width and there are holes. While using compiler directives on the struct like __attribute__((packed)) can help deal with that, not all compilers recognize them. So usually you want to add padding fields to align everything to 8-byte. A useful tool for checking this is pahole

And for example in this struct:

struct kvm_vmi_event_debug {
   __u32 type;
   __u8 single_step;
   __u8 watchpoint; // There is a 2 byte hole after this member, you want a __u16 _pad member added.
   __u64 watchpoint_gva;
   int32_t watchpoint_flags;
   int32_t exception;
};`
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant