Re: [Open64-devel] 答复: 答复: 答复: Code review request for bug968: wrong align for variables
Brought to you by:
ributzka,
suneeljain
From: Sun C. <sun...@gm...> - 2012-04-25 09:29:56
|
I was confused by your example. Change the size of test_align to 1, test_align11 to, say, 19 Sun On Wed, Apr 25, 2012 at 5:22 PM, zhangliwei <lif...@gm...>wrote: > **** > > Sorry, I can’t agree with you.**** > > 0x0~0xf ‘ccc’-----------------------------align by 0x10**** > > 0x800~0xfcf ‘test_align’----------------align by 0x800(2048)**** > > 0x1000~0x1405 ‘test_align**11’**---------align by 0x400(1024)**** > > 0x1410~0x144b ‘aaa’--------------------align by 0x10**** > > 0x1450~0x148b ‘bbb’--------------------align by 0x10**** > > ** ** > > ** ** > > Best wishes,**** > > Zhangliwei**** > ------------------------------ > > *发件人:* Sun Chan [mailto:sun...@gm...] > *发送时间:* **2012年4月25日** 17:09 > *收件人:* zhangliwei > *抄送:* ope...@li...; Ren Dongchen; shenruifen > *主题:* Re: 答复: 答复: [Open64-devel] Code review request for bug968: wrong > align for variables**** > > ** ** > > in this example, test_align11 has the wrong alignment, is it?**** > > Sun**** > > On Wed, Apr 25, 2012 at 4:59 PM, zhangliwei <lif...@gm...> > wrote:**** > > [lwzhang@cario align]$ cat align1.c**** > > int aaa[15]={0};**** > > __attribute__((aligned(2048))) unsigned char test_align[2000]={0};**** > > int bbb[15]={0};**** > > __attribute__((aligned(1024))) unsigned char test_align11[1030]={0};**** > > char ccc[15]={0};**** > > int main()**** > > {**** > > memset(ccc, 0, sizeof(ccc));**** > > memset(test_align, 0, sizeof(test_align));**** > > memset(test_align11, 0, sizeof(test_align11));**** > > } **** > > [lwzhang@cario align]$ vi align1.s**** > > ……**** > > 24 .section .bss**** > > 25 .org 0x0**** > > 26 .align 0**** > > 27 .globl ccc**** > > 28 .type ccc, @object**** > > 29 .size ccc, 15**** > > 30 ccc: # 0x0**** > > 31 .skip 2048**** > > 32 .org 0x800**** > > 33 .align 0**** > > 34 .globl test_align**** > > 35 .type test_align, @object**** > > 36 .size test_align, 2000**** > > 37 test_align: # 0x800 **** > > 38 .skip 2048**** > > 39 .org 0x1000**** > > 40 .align 0**** > > 41 .globl test_align11**** > > 42 .type test_align11, @object**** > > 43 .size test_align11, 1030**** > > 44 test_align11: # 0x1000**** > > 45 .skip 1040**** > > 46 .org 0x1410**** > > 47 .align 0**** > > 48 .globl aaa**** > > 49 .type aaa, @object**** > > 50 .size aaa, 60**** > > 51 aaa: # 0x1410**** > > 52 .skip 64**** > > 53 .org 0x1450**** > > 54 .align 0**** > > 55 .globl bbb**** > > 56 .type bbb, @object**** > > 57 .size bbb, 60**** > > 58 bbb: # 0x1450**** > > 59 .skip 60**** > > ……**** > > **** > > Best wishes,**** > > ZhangLiwei**** > ------------------------------ > > *发件人:* Sun Chan [mailto:sun...@gm...] **** > > *发送时间:* **2012年4月25日** 16:48**** > > *收件人:* zhangliwei > *抄送:* ope...@li...; Ren Dongchen; shenruifen**** > > *主题:* Re: 答复: [Open64-devel] Code review request for bug968: wrong align > for variables **** > > **** > > suppose you change one of the alignment requirement, say, test_align to, > say, 2048. And also change ccc to be of type char.**** > > Can you dump out the alignment for this new example?**** > > Thx!**** > > Sun**** > > On Wed, Apr 25, 2012 at 4:23 PM, zhangliwei <lif...@gm...> > wrote:**** > > Sorry. I have sent the mail to wrong receiver.**** > > Send again:**** > > Here is the .s file:**** > > ......**** > > 24 .section .bss**** > > 25 .org 0x0**** > > 26 .align 0**** > > 27 .globl ccc**** > > 28 .type ccc, @object**** > > 29 .size ccc, 60**** > > 30 ccc: # 0x0**** > > 31 .skip 1024**** > > 32 .org 0x400**** > > 33 .align 0**** > > 34 .globl test_align**** > > 35 .type test_align, @object**** > > 36 .size test_align, 2000**** > > 37 test_align: # 0x400**** > > 38 .skip 2048**** > > 39 .org 0xc00**** > > 40 .align 0**** > > 41 .globl test_align11**** > > 42 .type test_align11, @object**** > > 43 .size test_align11, 1030**** > > 44 test_align11: # 0xc00**** > > 45 .skip 1040**** > > 46 .org 0x1010**** > > 47 .align 0**** > > 48 .globl aaa**** > > 49 .type aaa, @object**** > > 50 .size aaa, 60**** > > 51 aaa: # 0x1010**** > > 52 .skip 64**** > > 53 .org 0x1050**** > > 54 .align 0**** > > 55 .globl bbb**** > > 56 .type bbb, @object**** > > 57 .size bbb, 60**** > > 58 bbb: # 0x1050**** > > 59 .skip 60**** > > ......**** > > **** > > Best wishes,**** > > ZhangLiwei**** > > **** > > **** > ------------------------------ > > *发件人:* Sun Chan [mailto:sun...@gm...] > *发送时间:* **2012年4月25日** 16:01 > *收件人:* zhangliwei > *抄送:* ope...@li...; Ren Dongchen; shenruifen > *主题:* Re: [Open64-devel] Code review request for bug968: wrong align for > variables**** > > **** > > can you dump out the .s file after your change?**** > > Thx!**** > > Sun**** > > On Wed, Apr 25, 2012 at 3:07 PM, zhangliwei <lif...@gm...> > wrote:**** > > Hi,**** > > could a gatekeeper please help review the fix for bug968? **** > > (https://bugs.open64.net/show_bug.cgi?id=968)**** > > **** > > [lwzhang@cario align]$ cat align1.c**** > > int aaa[15]={0};**** > > __attribute__((aligned(1024))) unsigned char test_align[2000]={0};**** > > int bbb[15]={0};**** > > __attribute__((aligned(1024))) unsigned char test_align11[1030]={0};**** > > int ccc[15]={0};**** > > int main()**** > > {**** > > memset(ccc, 0, sizeof(ccc));**** > > memset(test_align, 0, sizeof(test_align));**** > > memset(test_align11, 0, sizeof(test_align11));**** > > }**** > > **** > > [lwzhang@cario align]$ opencc align1.c -o a1 -keep**** > > [lwzhang@cario align]$ vi align1.s**** > > ......**** > > In align1.s:**** > > 24 .section .bss**** > > 25 .org 0x0**** > > 26 .align 0**** > > 27 .globl ccc**** > > 28 .type ccc, @object**** > > 29 .size ccc, 60**** > > 30 ccc: # 0x0**** > > 31 .skip 1024**** > > 32 .org 0x400**** > > 33 .align 0**** > > 34 .globl test_align**** > > 35 .type test_align, @object**** > > 36 .size test_align, 2000**** > > 37 test_align: # 0x400**** > > 38 .skip 2048**** > > 39 .org 0xc00**** > > 40 .align 0**** > > 41 .globl test_align11**** > > 42 .type test_align11, @object**** > > 43 .size test_align11, 1030**** > > 44 test_align11: # 0xc00**** > > 45 .skip 2048**** > > 46 .org 0x1400**** > > 47 .align 0**** > > 48 .globl aaa**** > > 49 .type aaa, @object**** > > 50 .size aaa, 60**** > > 51 aaa: # 0x1400**** > > 52 .skip 64**** > > 53 .org 0x1440**** > > 54 .align 0**** > > 55 .globl bbb**** > > 56 .type bbb, @object**** > > 57 .size bbb, 60**** > > 58 bbb: # 0x1440**** > > 59 .skip 60**** > > ......**** > > **** > > (1)Problem:**** > > For variable 'aaa': .org 0x1400 that means 'aaa''s align is same with > the**** > > last variable 'test_align11' 1024. **** > > But 'aaa''s align should be 16, not 1024. So here align for 'aaa' is wrong. > **** > > **** > > (2)Analysis:**** > > From the source code of open64, I found the reason as follows:**** > > Data_layout.cxx:**** > > static void**** > > Allocate_Space(ST *base, ST *blk, INT32 lpad, INT32 rpad, INT64 maxsize)** > ** > > {**** > > ……**** > > if (!STB_decrement(base)) {**** > > old_offset = STB_size(base);**** > > Set_ST_ofst(blk, ROUNDUP(old_offset + lpad, align));**** > > Set_STB_size(base, ROUNDUP(ST_ofst(blk) + size + rpad, align));**** > > }**** > > else {**** > > old_offset = STB_size(base);**** > > /* align object end */**** > > Set_ST_ofst(blk, ROUNDUP(old_offset + lpad, align)); **** > > Set_ST_ofst(blk,**** > > -(INT64) ROUNDUP(ST_ofst(blk) + size + rpad, align)); /* start */**** > > Set_STB_size(base, -ST_ofst(blk));**** > > }**** > > ……**** > > }**** > > For variable ‘test_align**11’**, it’s offset is 0xc00, and the .bss > size update to 0x1400. Then for ‘aaa’, it’s offset is .bss size, that is > 0x1400. It’s wrong.**** > > The reason is that after allocating space for ‘test_align**11’**, .bss > size update align with current variable’s align. **** > > I think it should update by adding current variable’s size without any > align.**** > > (3)Patch:**** > > Index: data_layout.cxx**** > > ===================================================================**** > > --- data_layout.cxx (revision 3916)**** > > +++ data_layout.cxx (working copy)**** > > @@ -679,12 +679,13 @@**** > > if (!STB_decrement(base)) {**** > > old_offset = STB_size(base);**** > > Set_ST_ofst(blk, ROUNDUP(old_offset + lpad, align));**** > > - Set_STB_size(base, ROUNDUP(ST_ofst(blk) + size + rpad, align));**** > > + Set_STB_size(base, ST_ofst(blk) + size + rpad);**** > > }**** > > else {**** > > old_offset = STB_size(base);**** > > /* align object end */**** > > - Set_ST_ofst(blk, ROUNDUP(old_offset + lpad, align));**** > > + /* open64.net bug968: here need not align object end */**** > > + Set_ST_ofst(blk, old_offset + lpad);**** > > Set_ST_ofst(blk,**** > > -(INT64) ROUNDUP(ST_ofst(blk) + size + rpad, align)); /* start */* > *** > > Set_STB_size(base, -ST_ofst(blk));**** > > **** > > **** > > Best wishes,**** > > ZhangLiwei**** > > > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > Open64-devel mailing list > Ope...@li... > https://lists.sourceforge.net/lists/listinfo/open64-devel**** > > **** > > **** > > ** ** > |