[Mingw-w64-public] [PATCH] crt: Unify and simplify handling of constructor/destructor lists

2018-08-02 Thread Martin Storsjö
GNU binutils ld traditionally provides __CTOR_LIST__ and __DTOR_LIST__ symbols via a linker script, while lld doesn't. Due to this, we previously provided our own copy of these symbols while building with clang (assuming that means we'd be linking with lld), see 1e81200e88f. In an attempt to unif

[Mingw-w64-public] [PATCH] crt: Unify and simplify handling of constructor/destructor lists

2018-08-02 Thread Martin Storsjö
GNU binutils ld traditionally provides __CTOR_LIST__ and __DTOR_LIST__ symbols via a linker script, while lld doesn't. Due to this, we previously provided our own copy of these symbols while building with clang (assuming that means we'd be linking with lld), see 1e81200e88f. In an attempt to unif

Re: [Mingw-w64-public] [PATCH] crt: Unify and simplify handling of constructor/destructor lists

2018-08-02 Thread Martin Storsjö
On Thu, 2 Aug 2018, Liu Hao wrote: 在 2018-08-02 19:02, Martin Storsjö 写道: Signed-off-by: Martin Storsjö --- mingw-w64-crt/crt/crtdll.c | 2 -- mingw-w64-crt/crt/crtexe.c | 2 -- mingw-w64-crt/crt/gccmain.c | 34 -- 3 files changed, 8 insertions(+), 30 d

Re: [Mingw-w64-public] [PATCH] crt: Unify and simplify handling of constructor/destructor lists

2018-08-02 Thread Liu Hao
在 2018/8/2 19:02, Martin Storsjö 写道: > -#ifdef __clang__ > extern func_ptr __CTOR_END__[]; > extern func_ptr __DTOR_END__[]; > > void __do_global_ctors (void) > { > static func_ptr *p = __CTOR_END__ - 1; > + // If the linker provided its own __CTOR_LIST__ in addition to the one > +

Re: [Mingw-w64-public] [PATCH] crt: Unify and simplify handling of constructor/destructor lists

2018-08-02 Thread Martin Storsjö
On Thu, 2 Aug 2018, Liu Hao wrote: 在 2018/8/2 19:02, Martin Storsjö 写道: -#ifdef __clang__ extern func_ptr __CTOR_END__[]; extern func_ptr __DTOR_END__[]; void __do_global_ctors (void) { static func_ptr *p = __CTOR_END__ - 1; + // If the linker provided its own __CTOR_LIST__ in add

Re: [Mingw-w64-public] [PATCH] crt: Unify and simplify handling of constructor/destructor lists

2018-08-02 Thread Martin Storsjö
On Thu, 2 Aug 2018, Martin Storsjö wrote: On Thu, 2 Aug 2018, Liu Hao wrote: 在 2018/8/2 19:02, Martin Storsjö 写道: -#ifdef __clang__ extern func_ptr __CTOR_END__[]; extern func_ptr __DTOR_END__[]; void __do_global_ctors (void) { static func_ptr *p = __CTOR_END__ - 1; + // If the

Re: [Mingw-w64-public] [PATCH] crt: Unify and simplify handling of constructor/destructor lists

2018-08-02 Thread Martin Storsjö
On Thu, 2 Aug 2018, Liu Hao wrote: index 54cbf02..44ff653 100644 --- a/mingw-w64-crt/crt/gccmain.c +++ b/mingw-w64-crt/crt/gccmain.c @@ -23,18 +23,24 @@ __do_global_dtors (void) while (*p) { - (*(p)) (); + // If the linker provided its own __DTOR_LIST__ in addition to the +

Re: [Mingw-w64-public] [PATCH] crt: Unify and simplify handling of constructor/destructor lists

2018-08-02 Thread JonY via Mingw-w64-public
On 08/02/2018 08:25 PM, Martin Storsjö wrote: > On Thu, 2 Aug 2018, Liu Hao wrote: > >>> index 54cbf02..44ff653 100644 >>> --- a/mingw-w64-crt/crt/gccmain.c >>> +++ b/mingw-w64-crt/crt/gccmain.c >>> @@ -23,18 +23,24 @@ __do_global_dtors (void) >>>   while (*p) >>>   { >>> -  (*(p)) ();

Re: [Mingw-w64-public] [PATCH] crt: Unify and simplify handling of constructor/destructor lists

2018-08-02 Thread Liu Hao
在 2018-08-03 03:16, Martin Storsjö 写道: > GNU binutils ld traditionally provides __CTOR_LIST__ and __DTOR_LIST__ > symbols via a linker script, while lld doesn't. > (... ...) > -#else > -// old method that iterates the list twice because old linker scripts do not > have __CTOR_END__ This drops th

Re: [Mingw-w64-public] [PATCH] crt: Unify and simplify handling of constructor/destructor lists

2018-08-02 Thread Martin Storsjö
On Fri, 3 Aug 2018, Liu Hao wrote: 在 2018-08-03 03:16, Martin Storsjö 写道: GNU binutils ld traditionally provides __CTOR_LIST__ and __DTOR_LIST__ symbols via a linker script, while lld doesn't. (... ...) -#else -// old method that iterates the list twice because old linker scripts do not have

Re: [Mingw-w64-public] [PATCH] crt: Unify and simplify handling of constructor/destructor lists

2018-08-07 Thread Martin Storsjö
On Fri, 3 Aug 2018, Liu Hao wrote: 在 2018-08-03 03:16, Martin Storsjö 写道: GNU binutils ld traditionally provides __CTOR_LIST__ and __DTOR_LIST__ symbols via a linker script, while lld doesn't. (... ...) -#else -// old method that iterates the list twice because old linker scripts do not have

Re: [Mingw-w64-public] [PATCH] crt: Unify and simplify handling of constructor/destructor lists

2018-08-27 Thread Liu Hao
This patch breaks libgcc. At the moment the `__main()` function which performs global initialization for static objects cannot handle `__CTOR_LIST__` with two pointers of `-1` in the front of it [1]. The code is presumed to call every function via pointers between the first `-1` and final null

Re: [Mingw-w64-public] [PATCH] crt: Unify and simplify handling of constructor/destructor lists

2018-08-27 Thread Martin Storsjö
On Mon, 27 Aug 2018, Liu Hao wrote: This patch breaks libgcc. At the moment the `__main()` function which performs global initialization for static objects cannot handle `__CTOR_LIST__` with two pointers of `-1` in the front of it [1]. The code is presumed to call every function via pointers

Re: [Mingw-w64-public] [PATCH] crt: Unify and simplify handling of constructor/destructor lists

2018-08-27 Thread Liu Hao
在 2018/8/27 20:21, Martin Storsjö 写道: > Yes, unless we come up with something better, soon. Feel free to revert, > but please amend the commit message to clarify that there are two > different implementations of the __main function; the one we have worked > fine but the libgcc one didn't handle