This is the mail archive of the binutils@sourceware.org mailing list for the binutils 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: ld can leave undefined symbols in non-relocatable output


On Tue, 2009-08-04 at 11:41 +0100, Dave Korn wrote:
> Dave Korn wrote:
> > Joshua Oreman wrote:
> >> Hi everyone,
> >>
> >> I'm on x86_64 using binutils 2.18.0 on GNU/Linux. I've recently run
> >> across some counterintuitive behavior in the linker, but I'm not sure
> >> whether it's intended or not. I was hoping someone on this list might
> >> be able to clarify whether this is intended and dependable behavior,
> >> or a bug.
> > 
> >   This is completely as intended and by design.  You can leave undefined
> > references in ELF executables (both SO libs and applications) and they are
> > filled in by the dynamic loader at runtime.  Therefore it is not seen as an
> > error at link-time if the definition is not available then; it may be supplied
> > by a library that is only available then.
> 
>   PS: See also the documentation for the "--no-undefined" option in the LD
> man/info page.

I did read all of that, and I'd like to clarify that I'm building a
statically linked executable, and "normal" undefined symbol references
(e.g. calling an undefined function) cause errors. It's just this
special type of reference with an unused .equ that puts an undefined
symbol entry into the symbol table without causing the link to fail.

I believe the difference may lie in the fact that the unused .equ does
not have any relocations that reference the undefined symbol, so there
is no impediment to proper execution of the code. It seems that the
static linker decides whether an undefined symbol "matters" based on its
impact, in terms of relocations that reference it, rather than its
simple existence. Is this accurate?

Thanks, and sorry if these are novice questions,

-- Josh

Attachment: signature.asc
Description: This is a digitally signed message part


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