[Bug ld/30079] Mingw ld : linking against an import lib causes ld to abort() at compare_section in ldlang.c

2023-02-13 Thread reiter.christoph at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=30079

--- Comment #8 from Christoph Reiter  ---
Thanks!

https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=b7eab2a9d4f4e92692daf14b09fc95ca11b72e30

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug ld/30079] Mingw ld : linking against an import lib causes ld to abort() at compare_section in ldlang.c

2023-02-13 Thread matz at suse dot de
https://sourceware.org/bugzilla/show_bug.cgi?id=30079

Michael Matz  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |FIXED

--- Comment #7 from Michael Matz  ---
(In reply to Christoph Reiter from comment #6)
> (In reply to Christoph Reiter from comment #5)
> > I did that in https://github.com/msys2/MINGW-packages/pull/15540 now which
> > fixed it for this example. Once it's in the repo I can ask the affected
> > users to try again.
> 
> All affected downstream users reported that it's working again for them.

Thanks.  After pondering I think it's the right thing to do, the input is sane
and it's (of course) fine that sections are only sorted by filename and not
otherwise, so that case needs dealing with.  I've committed a patch for this.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug ld/30079] Mingw ld : linking against an import lib causes ld to abort() at compare_section in ldlang.c

2023-02-12 Thread reiter.christoph at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=30079

--- Comment #6 from Christoph Reiter  ---
(In reply to Christoph Reiter from comment #5)
> I did that in https://github.com/msys2/MINGW-packages/pull/15540 now which
> fixed it for this example. Once it's in the repo I can ask the affected
> users to try again.

All affected downstream users reported that it's working again for them.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug ld/30079] Mingw ld : linking against an import lib causes ld to abort() at compare_section in ldlang.c

2023-02-07 Thread reiter.christoph at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=30079

--- Comment #5 from Christoph Reiter  ---
(In reply to Michael Matz from comment #3)
> If you can tar up the object files I can take a look myself (I don't have 
> cross compilers here, but cross binutils).

See above, if you want :)

> Or you add the guard
> back again and see how that goes.

I did that in https://github.com/msys2/MINGW-packages/pull/15540 now which
fixed it for this example. Once it's in the repo I can ask the affected users
to try again.

thanks!

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug ld/30079] Mingw ld : linking against an import lib causes ld to abort() at compare_section in ldlang.c

2023-02-07 Thread reiter.christoph at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=30079

--- Comment #4 from Christoph Reiter  ---
Created attachment 14658
  --> https://sourceware.org/bugzilla/attachment.cgi?id=14658&action=edit
object file + lib

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug ld/30079] Mingw ld : linking against an import lib causes ld to abort() at compare_section in ldlang.c

2023-02-07 Thread matz at suse dot de
https://sourceware.org/bugzilla/show_bug.cgi?id=30079

--- Comment #3 from Michael Matz  ---
The guards are supposed to be moved only, not removed:

  if (!wild->filenames_sorted
  && (sec == NULL || sec->spec.sorted == none
  || sec->spec.sorted == by_none))
{
  return wild->rightmost;
}
  ...
  while (*tree) {
if (wild->filenames_sorted) {
  ...
  if (i > 0) ... continue; else if (i < 0) ... continue;
  if (fa || la) {
...
if (i > 0) ... continue else if (i < 0) ... continue;
  }
}
...
compare_section (sec->spec.sorted, section, (*tree)->section) < 0)
  ...

So it could only get to calling compare_section() (with sec->spec.sorted being
none or by_none) when ->filename_sorted _and_ it falls through the compare
based on these names (i.e. if filenames are equal and containing archives (if
they exist) are equal).

I probably convinced myself that this situation is not supposed to happen,
and as testcases were totally missing I didn't notice otherwise.

If you can tar up the object files I can take a look myself (I don't have 
cross compilers here, but cross binutils).  Or you add the guard
back again and see how that goes.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug ld/30079] Mingw ld : linking against an import lib causes ld to abort() at compare_section in ldlang.c

2023-02-07 Thread reiter.christoph at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=30079

--- Comment #2 from Christoph Reiter  ---
It looks like the guards before calling compare_section() were dropped in the
new sorting code compared to the old one:
https://github.com/bminor/binutils-gdb/commit/af31506c31a59a6edbb13498d6075fa704b801cd#diff-a914d0473272b436f9df11b7baced0716e595c73daca00d118a733bf3d915b02L2866-L2870

For extra context, here is a downstream bug report:
https://github.com/msys2/MINGW-packages/issues/15469

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug ld/30079] Mingw ld : linking against an import lib causes ld to abort() at compare_section in ldlang.c

2023-02-07 Thread reiter.christoph at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=30079

Christoph Reiter  changed:

   What|Removed |Added

 CC||matz at suse dot de

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug ld/30079] Mingw ld : linking against an import lib causes ld to abort() at compare_section in ldlang.c

2023-02-07 Thread reiter.christoph at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=30079

Christoph Reiter  changed:

   What|Removed |Added

 CC||reiter.christoph at gmail dot 
com

--- Comment #1 from Christoph Reiter  ---
Using the reproducer bisected to:

I can also confirm that reverting it on top of 2.40 makes things work again
(assuming I resolved the conflicts correctly) .

---

af31506c31a59a6edbb13498d6075fa704b801cd is the first bad commit
commit af31506c31a59a6edbb13498d6075fa704b801cd
Author: Michael Matz 
Date:   Thu Nov 10 16:06:20 2022 +0100

Only use wild_sort_fast

there's no reason why the tree-based variant can't always be used
when sorting is required, it merely needs to also support filename
sorting and have a fast path for insertion at end (aka rightmost tree
leaf).

The filename sorting isn't tested anywhere and the only scripttempl
that uses it is avr (for 'SORT(*)(.ctors)'), and I believe even there it
was a mistake.  Either way, this adds a testcase for filename sorting as
well.

Then the non-BST based sorting can be simplified to only support
the fast case of no sorting required at all (at the same time renaming
the two variants to _sort and _nosort).

 ld/ldlang.c  | 302 +++
 ld/ldlang.h  |   3 +-
 ld/testsuite/ld-scripts/sort-file.d  |  18 +++
 ld/testsuite/ld-scripts/sort-file.t  |   6 +
 ld/testsuite/ld-scripts/sort-file1.s |   6 +
 ld/testsuite/ld-scripts/sort-file2.s |   6 +
 6 files changed, 163 insertions(+), 178 deletions(-)
 create mode 100644 ld/testsuite/ld-scripts/sort-file.d
 create mode 100644 ld/testsuite/ld-scripts/sort-file.t
 create mode 100644 ld/testsuite/ld-scripts/sort-file1.s
 create mode 100644 ld/testsuite/ld-scripts/sort-file2.s

-- 
You are receiving this mail because:
You are on the CC list for the bug.