From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10210 invoked by alias); 10 Dec 2003 17:04:31 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 10203 invoked from network); 10 Dec 2003 17:04:30 -0000 Received: from unknown (HELO yosemite.airs.com) (209.128.65.135) by sources.redhat.com with SMTP; 10 Dec 2003 17:04:30 -0000 Received: (qmail 26232 invoked by uid 10); 10 Dec 2003 17:04:29 -0000 Received: (qmail 3359 invoked by uid 500); 10 Dec 2003 17:04:22 -0000 From: Ian Lance Taylor To: Baurjan Ismagulov Cc: gdb@sources.redhat.com Subject: Re: optind References: <20031210142045.GL23712@ata.cs.hacettepe.edu.tr> <20031210144917.GA9115@nevyn.them.org> <20031210160910.GM23712@ata.cs.hacettepe.edu.tr> <20031210165318.GO23712@ata.cs.hacettepe.edu.tr> Date: Wed, 10 Dec 2003 17:04:00 -0000 In-Reply-To: <20031210165318.GO23712@ata.cs.hacettepe.edu.tr> Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2003-12/txt/msg00165.txt.bz2 Baurjan Ismagulov writes: > On Wed, Dec 10, 2003 at 05:12:56PM +0100, Andreas Schwab wrote: > > It also exists in the executable, due to a COPY relocation. > > Thanks much, I see it now! > > And how should gdb know which one to use? gdb should always use the one in the executable. That is the one the code in the shared library will also be using, because that is the address will be in the GOT. In principle, while debugging shared library code, gdb could observe that there is a GOT relocation for optind, and look at the GOT table in memory to decide which address to use. Alternatively, gdb could guess that if there is a global variable in the executable, that any reference to that global variable in the shared library will refer to the one in the executable. This will normally be true, but will fail in cases where the library is controlling visibility in any of various different ways. In practice I have no idea what gdb actually does. Ian