www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - 16 byte alignment

reply Shahid <Shahid party.van> writes:
I'm working with 64bit iasm and I would like to have some constant data 
16 byte aligned.

I have near the top of my source file:

__gshared immutable 
	ulong[2] sse_0F = [0x0F0F_0F0F_0F0F_0F0F,0x0F0F_0F0F_0F0F_0F0F];
	ulong[2] sse_30 = [0x3030_3030_3030_3030,0x3030_3030_3030_3030];

However getting this to be 16 byte aligned is a bit of a headache.

I noticed in the DMD changelog:

DMD 2.007
"Data items in static data segment >= 16 bytes in size are now paragraph 

I have no idea what "paragraph aligned" means.

If it's not possible, could someone point me whereabouts in the dmd 
source is responsible for static data alignment?
Jun 02 2011
parent Shahid <Shahid party.van> writes:
I made the Following change to backend/elfobj.c
I have no idea what I just did but it has solved my problem
Could anyone explain?

-- align16.patch --

diff --u a/src/backend/elfobj.c b/src/backend/elfobj.c
--- a/src/backend/elfobj.c
+++ b/src/backend/elfobj.c
   -683,7 +683,7    void obj_init(Outbuffer *objbuf, const char *filename,
const char *csegname)
         elf_newsection2(0,               SHT_NULL,   0,                
0,0,0,0,0, 0,0);
XECINSTR,0,0,0,0,0, 4,0);
         elf_newsection2(NAMIDX_RELTEXT,SHT_RELA, 0,0,0,0,SHI_SYMTAB,    
SHI_TEXT, 8,0x18);
-        elf_newsection2(NAMIDX_DATA,SHT_PROGDEF,SHF_ALLOC|SHF_WRITE,   
0,0,0,0,0, 8,0);
+        elf_newsection2(NAMIDX_DATA,SHT_PROGDEF,SHF_ALLOC|SHF_WRITE,   
0,0,0,0,0, 16,0);
         elf_newsection2(NAMIDX_RELDATA64,SHT_RELA, 0,0,0,0,SHI_SYMTAB,  
SHI_DATA, 8,0x18);
         elf_newsection2(NAMIDX_BSS, SHT_NOBITS,SHF_ALLOC|SHF_WRITE,    
0,0,0,0,0, 16,0);
0,0,0,0,0, 16,0);
Jun 03 2011