can you dump out the .s file after your change?
Thx!
Sun
On Wed, Apr 25, 2012 at 3:07 PM, zhangliwei <lifelong830...@gmail.com>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
> Open64-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/open64-devel
>
>
------------------------------------------------------------------------------
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
Open64-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/open64-devel