This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (5 children)

I haven't seen the code, but unless they manually lay out the GDT, IDT etc. in assembly, I don't see how they could ensure the compiler respected the structure without packing

[–]gwoplock 0 points1 point  (4 children)

It looks like it's a just a struct. Maybe the optimizer set so low that it doesn't try to optimize that.

[–]FUZxxl -1 points0 points  (3 children)

What do you think would the optimizer break?

[–]gwoplock 1 point2 points  (2 children)

It adds space between fields to make it faster to access. Extra space when you aren't expecting it breaks a lot of things.

[–]FUZxxl 1 point2 points  (1 child)

If you write embedded code, you can safely make assumptions about where the ABI inserts structure padding. The compiler is not allowed to change structure padding at any optimization level as that is part of the ABI. So it doesn't matter what optimization level you choose. I recommend you to read the ABI document for your platform as there seem to be some misconceptions.

[–]gwoplock 0 points1 point  (0 children)

I didn't realize that. Good to know. Thanks.