From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22608 invoked by alias); 7 Jul 2011 16:18:16 -0000 Received: (qmail 22567 invoked by uid 22791); 7 Jul 2011 16:18:12 -0000 X-SWARE-Spam-Status: No, hits=-0.5 required=5.0 tests=AWL,BAYES_05,TW_OV,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.cds1.net (HELO mail.cds1.net) (209.204.131.36) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 07 Jul 2011 16:17:56 +0000 Received: from [192.168.1.100] (173-164-133-8-SFBA.hfc.comcastbusiness.net [173.164.133.8]) by mail.cds1.net (Postfix) with ESMTP id 5C32DE00BDAB; Thu, 7 Jul 2011 09:17:55 -0700 (PDT) Message-ID: <4E15DC32.40901@cds1.net> Date: Thu, 07 Jul 2011 16:30:00 -0000 From: Bob Plantz Reply-To: plantz@ieee.org User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110516 Lightning/1.0b2 Thunderbird/3.1.10 MIME-Version: 1.0 To: Oleksandr Gavenko CC: binutils@sources.redhat.com Subject: Re: How define absolute local symbol by GNU as? References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2011-07/txt/msg00089.txt.bz2 On 07/07/2011 07:40 AM, Oleksandr Gavenko wrote: > On 07.07.2011 17:25, Andreas Schwab wrote: >> Oleksandr Gavenko writes: >> >>> But how declare it local? >> >> Don't declare it global. >> > OK, but how? > > If I write: > > .global @feat.00 > @feat.00=1 > > I get: > > $ nm test.obj | grep feat > 00000001 A @feat.00 > > If I write: > > /* .global @feat.00 */ > @feat.00=1 > > I get: > > $ nm test.obj | grep feat > > > So I expect existence of some directive to get wanted. One suggestion is to write what you want in C, then use gcc's -S option to produce the assembly language, and look to see how gcc does it. For example, int y = 456; int func() { static int x = 123; x = x + 1; y = y + 1; return x + y; } gives .file "static.c" .globl y .data .align 4 .type y, @object .size y, 4 y: .long 456 .text .globl func .type func, @function func:On 07/07/2011 07:40 AM, Oleksandr Gavenko wrote: > On 07.07.2011 17:25, Andreas Schwab wrote: >> Oleksandr Gavenko writes: >> >>> But how declare it local? >> >> Don't declare it global. >> > OK, but how? > > If I write: > > .global @feat.00 > @feat.00=1 > > I get: > > $ nm test.obj | grep feat > 00000001 A @feat.00 > > If I write: > > /* .global @feat.00 */ > @feat.00=1 > > I get: > > $ nm test.obj | grep feat > > > So I expect existence of some directive to get wanted. One suggestion is to write what you want in C, then use gcc's -S option to produce the assembly language, and look to see how gcc does it. For example, int y = 456; int func() { static int x = 123; x = x + 1; y = y + 1; return x + y; } gives .file "static.c" .globl y .data .align 4 .type y, @object .size y, 4 y: .long 456 .text .globl func .type func, @function func: .LFB0: .cfi_startproc pushq %rbp .cfi_def_cfa_offset 16 movq %rsp, %rbp .cfi_offset 6, -16On 07/07/2011 07:40 AM, Oleksandr Gavenko wrote: > On 07.07.2011 17:25, Andreas Schwab wrote: >> Oleksandr Gavenko writes: >> >>> But how declare it local? >> >> Don't declare it global. >> > OK, but how? > > If I write: > > .global @feat.00 > @feat.00=1 > > I get: > > $ nm test.obj | grep feat > 00000001 A @feat.00 > > If I write: > > /* .global @feat.00 */ > @feat.00=1 > > I get: > > $ nm test.obj | grep feat > > > So I expect existence of some directive to get wanted. One suggestion is to write what you want in C, then use gcc's -S option to produce the assembly language, and look to see how gcc does it. For example, int y = 456; int func() { static int x = 123; x = x + 1; y = y + 1; return x + y; } gives .file "static.c" .globl y .data .align 4 .type y, @object .size y, 4 y: .long 456 .text .globl func .type func, @function func: .LFB0: .cfi_startproc pushq %rbp .cfi_def_cfa_offset 16 movq %rsp, %rbp .cfi_offset 6, -16 .cfi_def_cfa_register 6 movl x.1616(%rip), %eax addl $1, %eax movl %eax, x.1616(%rip) movl y(%rip), %eax addl $1, %eax movl %eax, y(%rip) movl x.1616(%rip), %edx movl y(%rip), %eax leal (%rdx,%rax), %eax leave .cfi_def_cfa 7, 8 ret .cfi_endproc .LFE0: .size func, .-func .data .align 4 .type x.1616, @object .size x.1616, 4 x.1616: .long 123 .ident "GCC: (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2" .section .note.GNU-stack,"",@progbits .cfi_def_cfa_register 6 movl x.1616(%rip), %eax addl $1, %eax movl %eax, x.1616(%rip) movl y(%rip), %eax addl $1, %eax movl %eax, y(%rip) movl x.1616(%rip), %edx movl y(%rip), %eax leal (%rdx,%rax), %eax leave .cfi_def_cfa 7, 8 ret .cfi_endproc .LFE0: .size func, .-func .data .align 4 .type x.1616, @object .size x.1616, 4 x.1616: .long 123 .ident "GCC: (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2" .section .note.GNU-stack,"",@progbits .LFB0: .cfi_startproc pushq %rbp .cfi_def_cfa_offset 16 movq %rsp, %rbp .cfi_offset 6, -16 .cfi_def_cfa_register 6 movl x.1616(%rip), %eax addl $1, %eax movl %eax, x.1616(%rip) movl y(%rip), %eax addl $1, %eax movl %eax, y(%rip) movl x.1616(%rip), %edx movl y(%rip), %eax leal (%rdx,%rax), %eax leave .cfi_def_cfa 7, 8 ret .cfi_endproc .LFE0: .size func, .-func .data .align 4 .type x.1616, @object .size x.1616, 4 x.1616: .long 123 .ident "GCC: (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2" .section .note.GNU-stack,"",@progbits which causes me to believe that placing your variable in the .data segment without a .global directive would give what you want. --Bob