From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7042C383D81E; Thu, 12 Aug 2021 01:52:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7042C383D81E From: "i at maskray dot me" To: gcc-bugs@gcc.gnu.org Subject: [Bug libgcc/99759] morestack.S should support .init_array.0 besides .ctors.65535 Date: Thu, 12 Aug 2021 01:52:58 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libgcc X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: i at maskray dot me X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 01:52:58 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99759 --- Comment #3 from Fangrui Song --- (In reply to Alan Modra from comment #2) > > this means the ctors.65535 will come last. > Nope, it will come first. And since DT_INIT_ARRAY pointers are executed = in > the order they appear in the array, it will be one of the first to run.=20 > .init_array and .ctors sorting is complicated. ld.bfd will sort > .init_array.0 (highest priority .init_array section) and .ctors.65535 > (highest priority .ctors section) together. >=20 > I assume this comment: > > The input section description is quite close but does not sort .init_ar= ray.* and .ctors.* with the same priority together. > is referring to lld. `KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))` The syntax is ambiguous. I can read it this way: place .init_array.* before .ctors.* , but the behavior is (the ideal way): .init_array 0x0000000000402ff9 0x7 [!provide] PROVIDE (__init_array_sta= rt =3D .) *(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)) .init_array.5 0x0000000000402ff9 0x1 a.o .ctors.65529 0x0000000000402ffa 0x1 a.o .init_array.7 0x0000000000402ffb 0x1 a.o .ctors.65435 0x0000000000402ffc 0x1 a.o .init_array.100 0x0000000000402ffd 0x1 a.o *(.init_array EXCLUDE_FILE(*crtend?.o *crtend.o *crtbegin?.o *crtbegin.o) .ctors) .init_array 0x0000000000402ffe 0x1 a.o .ctors 0x0000000000402fff 0x1 a.o [!provide] PROVIDE (__init_array_end= =3D .) It is unclear that contiguous SORT_BY_INIT_PRIORITY are sorted as a unit. > > I don't see any issue here really in the end because GCC will produce i= nit_array most of the time. > So the issue really is that lld doesn't support mixing of .ctors.* and > .init_array.*. Yes. > It might be nice for libgcc to use .init_array.0 here instead of > .ctors.65536 whenever gcc will use .init_array in compiled code. Yes. This is the only place I know where modern Linux distrubtions is still using .ctors* in .o files.=