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]

Re: [PATCH] ld: provide __ehdr_start magic symbol

On Wed, Jun 20, 2012 at 10:04:17AM -0700, Roland McGrath wrote:
> On Tue, Jun 19, 2012 at 7:29 PM, Alan Modra <> wrote:
> > For other linker PROVIDEd symbols, we don't test for undefweak. ?ie. a
> > weak reference stays undefined.
> That's not what I see.

Hmm.  I was looking at ldexp.c:exp_fold_tree_1<etree_provide> where we

	      h = bfd_link_hash_lookup (link_info.hash, tree->assign.dst,
	      if (h == NULL
		  || (h->type != bfd_link_hash_new
		      && h->type != bfd_link_hash_undefined
		      && h->type != bfd_link_hash_common))
		  /* Do nothing.  The symbol was never referenced, or was
		     defined by some object.  */

"we don't test for undefweak" was correct, but not the conclusion that
undef weaks stay undefined.  What happens is that
bfd_record_link_assignment gets in first and flips
bfd_link_hash_undefweak to bfd_link_hash_new..  So I suppose it
doesn't really matter that your code differs from the ldexp.c code.

> The headers won't ever be inside a section, I don't think.


> Do you really mean
> that it should use a section-relative symbol with a value outside the section?


> I don't think that's really kosher ELF (elflint certainly doesn't like it).

IMNSHO, elflint is wrong.  If you accept that it is wrong for to
relocate absolute symbols, then ld must generate section relative
symbols with values outside of any section in some circumstances.  (Or
ld needs to generate sections to cover gaps in the image, or you need
a special section, SHN_REL say, like SHN_ABS but relocate with the

I'm not suggesting that glibc should be changed.  That obviously
can't happen yet, and perhaps never should, but I'd like to eventually
fix GNU ld for all architectures.  We've had bug reports before about
absolute symbols where people want to legitimately use absolute
symbols to mark memory mapped IO or separate address spaces, for sizes
and suchlike.  They can't because ld generates absolute symbols for
normal addresses, and that forces the kernel loader, embedded loader
or whatever, to relocate absolute symbols.

Alan Modra
Australia Development Lab, IBM

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