Re: gcc behavior of init priority of .ctors and .dtors section

2024-06-04 Thread John Baldwin
On 5/16/24 4:05 PM, Lorenzo Salvadore wrote: On Thursday, May 16th, 2024 at 20:26, Konstantin Belousov wrote: gcc13 from ports `# gcc ctors.c && ./a.out init 1 init 2 init 5 init 4 init 3 main fini 3 fini 4 fini 5 fini 2 fini 1` The above order is not expected. I think clang's one is correct

Re: gcc behavior of init priority of .ctors and .dtors section

2024-05-16 Thread Zhenlei Huang
> On May 17, 2024, at 2:26 AM, Konstantin Belousov wrote: > > On Thu, May 16, 2024 at 08:06:46PM +0800, Zhenlei Huang wrote: >> Hi, >> >> I'm recently working on https://reviews.freebsd.org/D45194 and got noticed >> that gcc behaves weirdly. >> >> A simple source file to demonstrate that. >>

Re: gcc behavior of init priority of .ctors and .dtors section

2024-05-16 Thread Konstantin Belousov
On Thu, May 16, 2024 at 08:05:57PM +, Lorenzo Salvadore wrote: > On Thursday, May 16th, 2024 at 20:26, Konstantin Belousov > wrote: > > > gcc13 from ports > > > `# gcc ctors.c && ./a.out init 1 init 2 init 5 init 4 init 3 main fini 3 > > > fini 4 fini 5 fini 2 fini 1` > > > > > > The above

Re: gcc behavior of init priority of .ctors and .dtors section

2024-05-16 Thread Lorenzo Salvadore
On Thursday, May 16th, 2024 at 20:26, Konstantin Belousov wrote: > > gcc13 from ports > > `# gcc ctors.c && ./a.out init 1 init 2 init 5 init 4 init 3 main fini 3 > > fini 4 fini 5 fini 2 fini 1` > > > > The above order is not expected. I think clang's one is correct. > > > > Further hacking w

Re: gcc behavior of init priority of .ctors and .dtors section

2024-05-16 Thread Konstantin Belousov
On Thu, May 16, 2024 at 08:06:46PM +0800, Zhenlei Huang wrote: > Hi, > > I'm recently working on https://reviews.freebsd.org/D45194 and got noticed > that gcc behaves weirdly. > > A simple source file to demonstrate that. > > ``` > # cat ctors.c > > #include > > __attribute__((constructor(101

gcc behavior of init priority of .ctors and .dtors section

2024-05-16 Thread Zhenlei Huang
Hi, I'm recently working on https://reviews.freebsd.org/D45194 and got noticed that gcc behaves weirdly. A simple source file to demonstrate that. ``` # cat ctors.c #include __attribute__((constructor(101))) void init_101() { puts("init 1"); } __attribute__((constructor(65535))) void init_655