From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10608 invoked by alias); 3 Aug 2009 16:02:43 -0000 Received: (qmail 10074 invoked by uid 22791); 3 Aug 2009 16:02:38 -0000 X-SWARE-Spam-Status: No, hits=-1.5 required=5.0 tests=AWL,BAYES_00,SPF_FAIL X-Spam-Check-By: sourceware.org Received: from mx20.gnu.org (HELO mx20.gnu.org) (199.232.41.8) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 03 Aug 2009 16:02:34 +0000 Received: from mail.codesourcery.com ([65.74.133.4]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MXzzb-0005Ym-Hy for gcc@gcc.gnu.org; Mon, 03 Aug 2009 12:02:31 -0400 Received: (qmail 32747 invoked from network); 3 Aug 2009 16:02:30 -0000 Received: from unknown (HELO ?192.168.2.100?) (wilson@127.0.0.2) by mail.codesourcery.com with ESMTPA; 3 Aug 2009 16:02:30 -0000 Subject: Re: extern variable From: Jim Wilson To: sumanth Cc: gcc@gcc.gnu.org In-Reply-To: <4A76641A.1010503@redpinesignals.com> References: <4A71B07A.1030600@redpinesignals.com> <4A75EA44.8050201@codesourcery.com> <4A76641A.1010503@redpinesignals.com> Content-Type: text/plain Date: Mon, 03 Aug 2009 16:02:00 -0000 Message-Id: <1249315349.2559.12.camel@localhost> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Detected-Operating-System: by mx20.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) 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/msg00033.txt.bz2 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