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 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.

	$ cat s.s
	.section frobozz,"a",%progbits
	.weak etext
	.weak __start_frobozz
	.weak __stop_frobozz
	.dc.a __start_frobozz
	.dc.a __stop_frobozz
	.dc.a etext
	$ ./gas/as-new -o s.o s.s
	$ nm s.o
			 w __start_frobozz
			 w __stop_frobozz
			 w etext
	$ ./ld/ld-new -o s s.o
	./ld/ld-new: warning: cannot find entry symbol _start; defaulting to
	$ nm s
	0000000000601000 R __bss_start
	0000000000400078 A __start_frobozz
	0000000000400090 R __stop_frobozz
	0000000000601000 R _edata
	0000000000601000 R _end
			 U _start
	0000000000400078 R etext

> I've just recently changed a lot of places where the linker defines
> symbols that hold a virtual address to *not* use absolute symbols.
> Absolute syms shouldn't be relocated by ?They are currently,
> but if this is ever fixed your __ehdr_start sym won't relocate when a
> shared lib or pie is loaded at some address other than the one it was
> linked at.

I guess I'd expect PIC code using this symbol to always use PC-relative or
GOT-relative relocs (i.e. __attribute__ ((visibility ("hidden"))) in C) and
thus get correct link-time resolution.  Using a dynamic reloc for
__ehdr_start is liable to find one belonging to another object that has
sloppy exports.

> Maybe
> ? ? ? ? ?if (hdrs_segment->count != 0)
> ? ? ? ? ? ?{
> ? ? ? ? ? ? ?asection *s = hdrs_segment->sections[0];
> ? ? ? ? ? ? ?hash->root.u.def.value = filehdr_vaddr - s->vma;
> ? ? ? ? ? ? ?hash->root.u.def.section = s;
> ? ? ? ? ? ?}
> and look through other elf_segment_map entries for the lowest vma
> section if you happen to have ehdr in a segment by itself, falling
> back to bfd_abs_section_ptr if there are no sections.

The headers won't ever be inside a section, I don't think.  (I don't know
how to write a linker script such that they would be.)  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).


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