This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: optind


On Wed, Dec 10, 2003 at 12:04:22PM -0500, Ian Lance Taylor wrote:
> Baurjan Ismagulov <ibr@ata.cs.hun.edu.tr> 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.

For global variables the sensible default is to use the one in the
executable.  This gets much more fun, of course, for function
addresses.

> In practice I have no idea what gdb actually does.

Neither does GDB.

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]