This is the mail archive of the 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]

Undef weak ref to _init/_fini causes DT_INIT/DT_FINI in DSO

But should it be that way?  Right now you get those DT_INIT and
DT_FINI tags, with 0 for the address (their d_ptr value).

To wit, if I create a shared library consisting only of (by way
of -fpic -nostdlib -nostartfiles -shared):

extern char _init[] __attribute__ ((__weak__));
void *f(void)
  return _init;

Should that shared library have a DT_INIT due to this weak
undefined reference?

I can't find anything conclusive in
which should be all the RTFM needed (other pointers welcome).

IMHO, there should be no DT_INIT or DT_FINI if there are only
(weak) undefined references.  Note that the d_ptr value isn't
relocated; it will stay 0 no matter what _init or _fini are in
other libraries at runtime.  (Even if it could, another
libraries _init or _fini shouldn't be used for this library.)

Of course, relying on behavior one way or the other is improper.
(Found in uClibc,  they say it's 0.9.10.)

(Place to patch: elflink.h:NAME(bfd_elf,size_dynamic_sections),
about line 3172.)

brgds, H-P

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