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]

Re: PATCH: Warning relocs against discarded functions


> Date: Thu, 1 Nov 2001 18:35:32 -0500
> From: Daniel Jacobowitz <drow@mvista.com>
> Cc: hjl@lucon.org, kaos@melbourne.sgi.com, gdb@sources.redhat.com,
>         binutils@sourceware.cygnus.com
> Mail-Followup-To: Geoff Keating <geoffk@redhat.com>, hjl@lucon.org,
> 	kaos@melbourne.sgi.com, gdb@sources.redhat.com,
> 	binutils@sourceware.cygnus.com
> Content-Disposition: inline
> User-Agent: Mutt/1.3.23i
> 
> On Thu, Nov 01, 2001 at 03:23:49PM -0800, Geoff Keating wrote:
> > > Date: Thu, 1 Nov 2001 14:28:35 -0800
> > > From: "H . J . Lu" <hjl@lucon.org>
> > > Cc: Daniel Jacobowitz <dan@debian.org>, gdb@sources.redhat.com,
> > >         binutils@sourceware.cygnus.com
> > 
> > > On Thu, Nov 01, 2001 at 11:43:10PM +1100, Keith Owens wrote:
> > > > The problem is worse than stabs.  If a function is marked __exit _and_
> > > > some code in another section refers to that function then :-
> > > > 
> > > > * ld resolves the reference as offset xxx from the start of section
> > > >   .text.exit which is expected to get a decent start address.
> > > > * Section .text.exit is discarded, giving it a zero start address.
> > 
> > That's not right!  When a section is discarded, it goes away, it
> > doesn't go to location 0.  When a section is not in the final object,
> > any non-weak relocations to it (that do make it to the final object)
> > are an error, and should be reported as such ("undefined symbol" or
> > similar).
> 
> If that's so, what would you suggest in the case I described earlier
> (I'm pretty sure I sent it to the binutils list...)?  The single .stab
> section contains relocations to functions in all text sections, as best
> I can tell, including the discarded .text.exit section.

Well, I see these choices:

- Declare that the user is in error, and should not have discarded
  .text.exit without discarding .stabs (or should have put the stabs
  for .text.exit in their own .stabs.exit section, and discarded that
  too); or
- Make the linker smart enough to do what the user really wants, which
  is to delete the debugging information for .text.exit at the time it
  discards the section.

Of course, this raises an interesting question: why not just use the
c preprocessor to prevent the functions for this section being
compiled in the first place?

-- 
- Geoffrey Keating <geoffk@geoffk.org> <geoffk@redhat.com>


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