From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29552 invoked by alias); 10 Nov 2004 00:17:02 -0000 Mailing-List: contact binutils-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sources.redhat.com Received: (qmail 29421 invoked from network); 10 Nov 2004 00:16:52 -0000 Received: from unknown (HELO rwcrmhc11.comcast.net) (204.127.198.35) by sourceware.org with SMTP; 10 Nov 2004 00:16:52 -0000 Received: from lucon.org ([24.6.212.230]) by comcast.net (rwcrmhc11) with ESMTP id <2004111000164601300mjab1e>; Wed, 10 Nov 2004 00:16:51 +0000 Received: by lucon.org (Postfix, from userid 1000) id E64726405F; Tue, 9 Nov 2004 16:16:45 -0800 (PST) Date: Wed, 10 Nov 2004 00:17:00 -0000 From: "H. J. Lu" To: "Aaron W. LaFramboise" Cc: binutils@sources.redhat.com, gcc@gcc.gnu.org Subject: Re: PATCH: PR 528: .set is broken for weak symbols Message-ID: <20041110001645.GA8419@lucon.org> References: <20041108235940.GA18970@lucon.org> <20041109003025.GA19446@lucon.org> <41906859.60608@aaronwl.com> <20041109162932.GA1112@lucon.org> <4191370E.2090503@aaronwl.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4191370E.2090503@aaronwl.com> User-Agent: Mutt/1.4.1i X-SW-Source: 2004-11/txt/msg00171.txt.bz2 On Tue, Nov 09, 2004 at 03:30:54PM -0600, Aaron W. LaFramboise wrote: > H. J. Lu wrote: > > > The key is ".set" is not used to equate symbols. It is used to set a > > symbol with the same value and type. If the symbol doesn't exist > > before, the new symbol will be local. > > I am not so sure this is absolutely correct though. Consider: > > .text > .global a > .set a, b > jmp a > > RELOCATION RECORDS FOR [.text]: > OFFSET TYPE VALUE > 00000001 DISP32 b > > Note that the two symbols are equated with .set and that the relocation > is adjusted from being against a to being against b. That is because b is undefined. > > In my mind, a weak symbol is semantically much more like an undefined > symbol than a defined symbol. For weak symbols, like undefined symbols, > we don't actually know the final value until the final link. > Specifically, I think a weak symbol (even a defined weak symbol) is just > a special case of an undefined symbol, in which special semantics are > invoked if the symbol is not strongly defined rather than just failing. > You are talking different weak symbol. See http://www.sco.com/developers/gabi/latest/ch4.symtab.html for weak symbols in ELF. > So, it seems contradictory and arbitrary that .set for .weak doesn't > have similar semantics as .set for undefined symbols. > > In any case, PECOFF doesn't have the distinction between defweak and > undefweak, with final semantics being a little bit of both. It makes a > lot of sense, for PECOFF, for weak symbols to have the semantics I > described, so I think that the current handling is correct. (I don't > like having an #ifdef TE_PE in the target-independent part of gas > though; how can this be fixed?) > You can define #define TC_CONVERT_WEAK ..... or something like that and default it to the old semantics. You can do it differently for PECOFF. H.J.