public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* cannot undefine with -u option to ld
@ 2001-09-14  9:17 first last
  2001-09-17  8:06 ` Nick Clifton
  0 siblings, 1 reply; 4+ messages in thread
From: first last @ 2001-09-14  9:17 UTC (permalink / raw)
  To: binutils

I am trying to use the -u option of ld to force a
symbol to be undefined in order to have the
linker pull a module out of a library which it
otherwise would not.

The feature does no work consistantly.  If i use
"-u __gccmain", libraries are searched and a
module is extracted which defines the symbol. 
For every other symbol I tried, no library module
is extracted, nor does it appear a library search
is being performed (--verbose).  

The most mysterious part is that the symbol is
inserted into the symbol table from the linker
and it is labelled UND in the Ndx column of the
table.  I assume that means the symbol is
undefined.  But the linker completes with no
error and no resolution of the symbol.

________________________________________
Get your email at 
http://www.prontomail.com 

^ permalink raw reply	[flat|nested] 4+ messages in thread
* Re: cannot undefine with -u option to ld
@ 2001-09-17 19:22 first last
  2001-09-18  2:53 ` Nick Clifton
  0 siblings, 1 reply; 4+ messages in thread
From: first last @ 2001-09-17 19:22 UTC (permalink / raw)
  To: nickc; +Cc: binutils, bug-binutils

I have resolved my immediate problem, but the
larger issue of "silent failure" should probably
be addressed.

Silent Failure ---
It appears that when "-u" is used, ld will
attempt to define the symbol in the usual way
(library searches, etc), but , if it cannot, it
fails silently.  It inserts the symbol in the
symbol table, annotates it with UND (to indicate
that it is undefined), but then completes without
indicating a warning or an error.

How I Fixed Things ---
In my case, I do not remember exactly how I fixed
the problem, but it was definitely caused by 
operator error.  Possibly the symbol was spelled
differently on the ld command line than in the
module where it was defined.  Possibly the
library search order was incorrect.  Once all the
ducks were lined up, "ld -u" worked. 
Unfortunately the silent failure of "-u"
misdirected me for several days.

In my first email, I reported that "-u" worked
for __gccmain but for no other symbol that I
tried.  This was a red herring.  "-u" failed with
__gccmain just as well.  However,__gccmain became
defined later in the link process for other
reasons, unrelated to "-u".  This lead me to
believe that "-u" worked for this one symbol but
for no others.

Recommendation ---
I would like to recommend that ld be modified to
end with an error (or at least a noticeable
warning) when a symbol is undefined with "-u" and
ld never resolves the problem.

(For reference, this thread started in
binutils@sources.redhat.com.)

________________________________________
Get your email at 
http://www.prontomail.com 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2001-09-18  2:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-09-14  9:17 cannot undefine with -u option to ld first last
2001-09-17  8:06 ` Nick Clifton
2001-09-17 19:22 first last
2001-09-18  2:53 ` Nick Clifton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).