Sorry.
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

-----邮件原件-----
发件人: open64-devel-requ...@lists.sourceforge.net
[mailto:open64-devel-requ...@lists.sourceforge.net] 
发送时间: 2012年4月25日 16:01
收件人: open64-devel@lists.sourceforge.net
主题: Open64-devel Digest, Vol 65, Issue 35

Send Open64-devel mailing list submissions to
        open64-devel@lists.sourceforge.net

To subscribe or unsubscribe via the World Wide Web, visit
        https://lists.sourceforge.net/lists/listinfo/open64-devel
or, via email, send a message with subject or body 'help' to
        open64-devel-requ...@lists.sourceforge.net

You can reach the person managing the list at
        open64-devel-ow...@lists.sourceforge.net

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Open64-devel digest..."


Today's Topics:

   1. Re: Code review request for bug968: wrong align for       variables
      (Sun Chan)


----------------------------------------------------------------------

Message: 1
Date: Wed, 25 Apr 2012 16:00:55 +0800
From: Sun Chan <sun.c...@gmail.com>
Subject: Re: [Open64-devel] Code review request for bug968: wrong
        align for       variables
To: zhangliwei <lifelong830...@gmail.com>
Cc: Ren Dongchen <dongchen....@simplnano.com>,  shenruifen
        <ruifen.s...@simplnano.com>, open64-devel@lists.sourceforge.net
Message-ID:
        <CAGtpj4hA=q2gUtne4eEqVsGhjsS=bdhzjoktm5t7fthfbrm...@mail.gmail.com>
Content-Type: text/plain; charset="windows-1252"

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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...

------------------------------

----------------------------------------------------------------------------
--
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


End of Open64-devel Digest, Vol 65, Issue 35
********************************************


------------------------------------------------------------------------------
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

Reply via email to