From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1909 invoked by alias); 3 Aug 2009 18:54:42 -0000 Received: (qmail 1899 invoked by uid 22791); 3 Aug 2009 18:54:41 -0000 X-SWARE-Spam-Status: No, hits=-1.3 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_13 X-Spam-Check-By: sourceware.org Received: from mail.redpinesignals.com (HELO mail.redpinesignals.com) (203.196.161.92) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 03 Aug 2009 18:54:35 +0000 Received: from [192.168.40.84] ([192.168.40.84]) (authenticated user sumanth.gundapneni@redpinesignals.com) by mail.redpinesignals.com; Tue, 4 Aug 2009 00:15:31 +0530 Message-ID: <4A772E41.6090302@redpinesignals.com> Date: Mon, 03 Aug 2009 18:54:00 -0000 From: sumanth User-Agent: Thunderbird 2.0.0.16 (X11/20080707) MIME-Version: 1.0 To: Jim Wilson CC: gcc@gcc.gnu.org Subject: Re: extern variable References: <4A71B07A.1030600@redpinesignals.com> <4A75EA44.8050201@codesourcery.com> <4A76641A.1010503@redpinesignals.com> <1249315349.2559.12.camel@localhost> In-Reply-To: <1249315349.2559.12.camel@localhost> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2009-08/txt/msg00039.txt.bz2 Hi Jim, that seems to be a promising solution. If I keep the prefix "_" for a global variable , there is a problem in accessing it in gdb...let me explain you with an example Eg: file1.c int a = 10; int main() { int b =10; int c; c = add( a , b); return 0; } file2.c int add( int x, int y) { return x+y ; } > mycompiler-gcc -g file1.c file2.c > mycompiler-gdb a.out >> when i print "a" in file1.c , i am able to see value 10; >> when i print "a" int file2.c, it prints , no symbol defined. Instead I can access it with " print _a" Thats the problem; guess i am clear this time. prefixing registers is out of scope for me , as people got used to register names r0, r1...... Regards, Sumanth G Jim Wilson wrote: > On Mon, 2009-08-03 at 09:44 +0530, sumanth wrote: > >> How can i make sure my tool chain knows the difference between >> global variable r0 and register r0. >> > > The simple solution is to either add a prefix to variable names, or to > add a prefix to register names. In ELF, the convention is to not add a > prefix to variables names, we add a prefix to register names instead if > we need one, e.g. %eax on i386, or $4 on mips. > > You can of course choose to add a prefix to variable names. It just > isn't the convention. See for instance how the arm-elf port works when > you use the -fleading-underscore option. > > A less simple solution is to have an assembler syntax that avoids > ambiguity between register names and variable names. If for instance > you have a move instruction that can accept either a register or a > variable as source, then you have an ambiguity. You could instead have > a load instruction for reading memory, and a move instruction for > reading registers, and then you don't have an ambiguity anymore. You > can also do things with addressing modes and relocation operators to > reduce ambiguities. > > Jim > > > > >