From 6e9e5e82469837c43c75f86c8c12cab99eb47a9f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20Chigot?= <clement.chigot@atos.net>
Date: Thu, 20 May 2021 08:44:44 +0200
Subject: [PATCH] collect2: avoid failure when passing text files in an AIX
 archive
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

AIX ld allows archives to contain text files by simply ignoring
them and printing a warning.
This patch enables the same behavior for collect2.

gcc/ChangeLog:
2021-05-20  Clément Chigot  <clement.chigot@atos.net>

	* collect2.c (scan_prog_file): Skip none-COFF files instead
	of raising an error.
---
 gcc/collect2.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/gcc/collect2.c b/gcc/collect2.c
index bd371430ab7..51933662f38 100644
--- a/gcc/collect2.c
+++ b/gcc/collect2.c
@@ -2783,7 +2783,10 @@ scan_prog_file (const char *prog_name, scanpass which_pass,
       if ((ldptr = ldopen (CONST_CAST (char *, prog_name), ldptr)) != NULL)
 	{
 	  if (! MY_ISCOFF (HEADER (ldptr).f_magic))
-	    fatal_error (input_location, "%s: not a COFF file", prog_name);
+	    {
+	      warning_at (input_location, 0, "%s: not a COFF file", prog_name);
+	      continue;
+	    }
 
 	  if (GCC_CHECK_HDR (ldptr))
 	    {
-- 
2.31.1

