git: 783bf3a6159a - main - devel/binutils: Fix abort() in mingw32

From: Cy Schubert <cy_at_FreeBSD.org>
Date: Sun, 14 May 2023 05:02:44 UTC
The branch main has been updated by cy:

URL: https://cgit.FreeBSD.org/ports/commit/?id=783bf3a6159aadc5696192e040abae2c311c8b8c

commit 783bf3a6159aadc5696192e040abae2c311c8b8c
Author:     Cy Schubert <cy@FreeBSD.org>
AuthorDate: 2023-05-14 04:50:30 +0000
Commit:     Cy Schubert <cy@FreeBSD.org>
CommitDate: 2023-05-14 04:50:30 +0000

    devel/binutils: Fix abort() in mingw32
    
    Building mingw32 results in a binutils abort() trap. Upstream commit
    b7eab2a9d4f fixes this. Upstream commit log message states:
    
        the early-out in wild_sort is not enough, it might still be
        that filenames are equal _and_ the wildcard list doesn't specify
        a sort order either.  Don't call compare_section then.
    
    PR:                     271405
    Reported by:            shurd
    Upstream commit:        b7eab2a9d4f (identified by shurd)
    MFH                     2023Q3
---
 devel/binutils/Makefile                |  2 +-
 devel/binutils/files/patch-ld_ldlang.c | 12 ++++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/devel/binutils/Makefile b/devel/binutils/Makefile
index f33baaa17357..0530c4bbc988 100644
--- a/devel/binutils/Makefile
+++ b/devel/binutils/Makefile
@@ -1,6 +1,6 @@
 PORTNAME=	binutils
 DISTVERSION=	2.40
-PORTREVISION=	3
+PORTREVISION=	4
 PORTEPOCH?=	1
 CATEGORIES?=	devel
 MASTER_SITES=	SOURCEWARE/binutils/releases
diff --git a/devel/binutils/files/patch-ld_ldlang.c b/devel/binutils/files/patch-ld_ldlang.c
new file mode 100644
index 000000000000..7652eabe9184
--- /dev/null
+++ b/devel/binutils/files/patch-ld_ldlang.c
@@ -0,0 +1,12 @@
+--- ld/ldlang.c.orig	2023-01-13 16:00:00.000000000 -0800
++++ ld/ldlang.c	2023-05-13 21:48:06.006092000 -0700
+@@ -649,7 +649,8 @@
+ 	 looking at the sections for this file.  */
+ 
+       /* Find the correct node to append this section.  */
+-      if (compare_section (sec->spec.sorted, section, (*tree)->section) < 0)
++      if (sec && sec->spec.sorted != none && sec->spec.sorted != by_none
++	  && compare_section (sec->spec.sorted, section, (*tree)->section) < 0)
+ 	tree = &((*tree)->left);
+       else
+ 	tree = &((*tree)->right);