Philip Guenther wrote:
> On Mon, Aug 1, 2016 at 11:45 AM, Mark Kettenis <mark.kette...@xs4all.nl> 
> wrote:
> >> From: j...@wxcvbn.org (Jeremie Courreges-Anglas)
> >> Date: Mon, 01 Aug 2016 20:30:33 +0200
> >>
> >> Stefan Kempf <sisnk...@gmail.com> writes:
> >>
> >> > The constructor and destructor tables are declared as arrays with one
> >> > non-NULL element. Walking those until a NULL element is reached looks
> >> > like out-of-bound accesses to newer compilers, and they turn the code
> >> > into infinite loops (e.g. clang 3.8), because it is undefined behavior.
> 
> So it needs to reference the pointers via an extern incomplete array?
> Can we move to setting up the leading count via the linker script
> magic documented in the ld info page, and then just use __CTOR_LIST__
> as the extern array?
 
Right, we need the extern trick.
I'll take a look into doing it with counts and __CTOR_LIST__ and
__CTOR_END__. We want __CTOR_LIST__ and __CTOR_END__ to be .hidden
symbols, right?
 
> >> > While there, clean up crtbegin.c and crtbegin.S a little and make them
> >> > more similar.
> 
> I'm fine with this being done...once we sure we actually have nailed
> down what are the actual changes necessary to get the code to compile
> correctly without changing behavior.
> 
> ...
> >> The existing code tries to retrieve the number of valid ctors entries
> >> from __CTOR_LIST__[0], only when that number is -1 it tries to find
> >> the actual value by walking the array.
> 
> Since we only have one version of ld doing linking now, can't we
> switch from the -1 to the real count version?
> 
> ...
> > Also, aren't ctor_list and dtor_list polluting the namespace?
> 
> Yep.
 
> Philip

Reply via email to