https://gcc.gnu.org/g:6b8e90b02f68ebe27c4a069c6f4b08191e285116

commit r16-9301-g6b8e90b02f68ebe27c4a069c6f4b08191e285116
Author: Pietro Monteiro <[email protected]>
Date:   Tue Jun 9 11:20:09 2026 -0400

    libiberty, Darwin: Read dylibs too
    
    The Algol 68 frontend adds a section with information on exported
    modes and procedures to libraries and object files.  Instead of
    erroring out when encountering a Mach-O library keep reading it so the
    frontend can find the exports section.
    
    libiberty/ChangeLog:
    
            * simple-object-mach-o.c (MACH_O_MH_DYLIB): New definition.
            (simple_object_mach_o_match): Accept dylibs as well as object files.
    
    Signed-off-by: Pietro Monteiro <[email protected]>
    (cherry picked from commit f746787e2c347585110765ac8bd2bd0b6bf4413b)

Diff:
---
 libiberty/simple-object-mach-o.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libiberty/simple-object-mach-o.c b/libiberty/simple-object-mach-o.c
index 0897a3edf7d5..f7d54889976e 100644
--- a/libiberty/simple-object-mach-o.c
+++ b/libiberty/simple-object-mach-o.c
@@ -78,6 +78,7 @@ struct mach_o_header_64
 /* For filetype field in header.  */
 
 #define MACH_O_MH_OBJECT               0x01
+#define MACH_O_MH_DYLIB                        0x06
 
 /* A Mach-O file is a list of load commands.  This is the header of a
    load command.  */
@@ -312,9 +313,9 @@ simple_object_mach_o_match (
   b = &buf[0];
 
   filetype = (*fetch_32) (b + offsetof (struct mach_o_header_32, filetype));
-  if (filetype != MACH_O_MH_OBJECT)
+  if (!(filetype == MACH_O_MH_OBJECT || filetype == MACH_O_MH_DYLIB))
     {
-      *errmsg = "Mach-O file is not object file";
+      *errmsg = "Mach-O file is neither object file nor dylib";
       *err = 0;
       return NULL;
     }

Reply via email to