[dmd-internals] How to avoid 4-word padding for symbols?

Michel Fortin michel.fortin at michelf.com
Mon Nov 8 14:02:32 PST 2010


Le 2010-11-08 à 16:01, Walter Bright a écrit :

> Michel Fortin wrote:
>> Turns out it doesn't work because those symbols refer to each other, so by coalescing them in one symbol I'm creating a self-referenced symbol and the backend doesn't like that.
>> 
>> I resorted to adding a 'noalign' flag to outdata() in the backend. It's a small change and it works, but it feels like a hack. Ideally there should be a way to specify the alignment per segment (there might already be one, but I can't figure it out). Since the Objective-C stuff belongs to separate segments it'd make things really easy.
>> 
>> I know there is the 'align' parameter in mach_getsegment(), but it doesn't seem to have any effect other than changing alignment value for the section in the object file.
> 
> Do you mean alignment per segment, or per symbol?

I mean the alignment of the symbols in a specific segment. In this case I need symbols inside the __protocol segment of the __OBJC section to have a 4-byte alignment. I'd have expected the align parameter of mach_getsegment() to do that, but setting it to 2 doesn't do anything.

Since all the symbols are 20 bytes I can just emit them with no alignment at all and I get the same result, that's what my small hack does.

If you clone the Git repository you'll see it's the last commit (01c7708c82).

-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/





More information about the dmd-internals mailing list