From bb780987778c461b1edc4b455af0fee607c8f812 Mon Sep 17 00:00:00 2001 From: Chris Novakovic Date: Thu, 27 Nov 2025 23:16:50 +0000 Subject: [PATCH] Reader: resolve BSD-variant file names before checking for symbol tables Darwin's `ar(1)` writes BSD-variant archives and treats file names containing exactly 16 characters as long file names; this causes it to write sorted symbol tables with the file name `#1/16`, which only becomes `__.SYMDEF SORTED` after long file names have been resolved. Parse the file name before checking whether it is indicative of the archive member being a symbol table. Fixes #22. --- reader.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/reader.go b/reader.go index a0e7b76..593c605 100644 --- a/reader.go +++ b/reader.go @@ -186,14 +186,14 @@ func (rd *Reader) Next() (*Header, error) { return nil, err } case BSD: + if err := rd.parseBSDFileName(header); err != nil { + return nil, err + } // The special file name "__.SYMDEF" (and variations of it) indicates that the data section contains a symbol table. if header.Name == "__.SYMDEF" || header.Name == "__.SYMDEF SORTED" || header.Name == "__.SYMDEF_64" { // The symbol table should be invisible to the caller - skip over it. return rd.Next() } - if err := rd.parseBSDFileName(header); err != nil { - return nil, err - } } // The file name has now been resolved; make sure it doesn't contain any illegal characters.