[PATCH v3] ld: Maintain the input file order

Alan Modra amodra@gmail.com
Thu Apr 23 02:33:40 GMT 2026


On Thu, Apr 23, 2026 at 09:04:43AM +0800, H.J. Lu wrote:
> My patch only changes the real input file order, not the other
> traversing orders:

Yes, that was what I was flagging as a possible defect.  I don't think
lang_input_statement_type.next is a problem, but header.next may well
be.  Many places traverse that list.

> Do you have a test to show my patch is wrong?

No.  I didn't even try to analyse where things may go wrong, sorry.

Hmm, if you generate a linker map file you can see that although libm
appears before libc on the linker command file, libc object sections
appear before libm object sections.  I haven't checked, but you might
like to verify that library dependencies work.  ie. in this case that
an object in libm-2.42.a with a dependency on a libc.a object will
cause the libc.a object to be extracted.

-- 
Alan Modra


More information about the Binutils mailing list