News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Automatic structure alignment?

Started by jorgon, November 05, 2006, 09:28:48 AM

Previous topic - Next topic

jorgon

I would like to consult with GoAsm users about whether to introduce automatic structure alignment in GoAsm.

I raise this because I am about to add such automatic structure alignment to GoAsm for 64-bit programming.  This is because structure alignment is much more important under that platform, and in fact, padding must be applied to adjust the position of the structure members themselves, and padding sometimes needs to be added at the end of the structure too.  This is probably too difficult to organise within the include files, so the assembler will need to do it.  See this thread and my article writing 64-bit programs (alignment requirements) for more information about this.

Debali's query about the API AdjustTokenPrivileges which failed under Win32 because the structure given to that API was not aligned on a dword boundary, raises the question whether automatic structure alignment ought to be added to GoAsm when assembling for 32-bits as well.  This would save time chasing such a problem.  On the other hand it would add material to the output file "behind your back", which may not be welcome.

GoAsm already ensures dword alignment in the case of local data, but I could extend it to structures declared in the data section (public data).

If so, would users like such automatic alignment to be by default, with a switch to stop it happening?  Or the other way round?

Author of the "Go" tools (GoAsm, GoLink, GoRC, GoBug)

Vortex

QuoteIf so, would users like such automatic alignment to be by default, with a switch to stop it happening?

Hi Jeremy,

Automatic alignment and a switch to stop it are good ideas. This should satisfy all the users. Personnaly, I had this structure alignment problem with binary resource templates.

Keep up the good work :U

donkey

Hi Jeremy,

This would be very handy, I have also been caught in the alignment trap and spent a frustrating few minutes trying to figure out what was going on. Though I suspect it would be much more involved, it would be very handy to have structure alignment handled like this...

MyData STRUCT ALIGN 4
blah DD ?
blagh DD ?
ENDS

Ensuring that all occurences of MyData would be DWORD aligned (or 16 for QWORD etc...). Just a suggestion though, the automatic alignment to DWORD would work just fine as well.

Edgar
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

debali

  Hi Jeremy.

  I agree,  it can save time to many people and avoid many headaches because if you don't know nothing about the problem can be impossible to know whats happen.

bushpilot

I think aligning by default, with the ability to override is good.

Greg

Relvinian

I agree with others...Automatic alignment by default for both 32-bit and 64-bit with an option to turn it off or override it with your own alignment values.

Relvinian

pro3carp3

I agree that this is a positive feature as long as it can be switched on/off.  Be sure that it is well-documented.

LGC
LGC

P1

Maybe a console line out during the assembly, "Warning Automatic Alignment Adjustment to:  XXXXXXXXXX".

Which could be overrided by a suppress warning messages switch.

Regards,  P1  :8)