$OpenBSD: patch-lib_MC_MCParser_AsmParser_cpp,v 1.4 2021/05/18 03:35:07 rsadowski Exp $

make clang include a FILE symbol for .(s|S) files

This is mostly needed by syspatch at the moment to be
to be able to re-link in the same order as the original
libraries were linked with by relying on the readelf(1)
and without this .(s|S) assembly files were not getting
a file directive.

Index: lib/MC/MCParser/AsmParser.cpp
--- lib/MC/MCParser/AsmParser.cpp.orig
+++ lib/MC/MCParser/AsmParser.cpp
@@ -909,6 +909,10 @@ bool AsmParser::Run(bool NoInitialTextSection, bool No
     (void)InsertResult;
   }
 
+  StringRef Filename = getContext().getMainFileName();
+  if (!Filename.empty() && (Filename.compare(StringRef("-")) != 0))
+    Out.emitFileDirective(Filename);
+
   // While we have input, parse each statement.
   while (Lexer.isNot(AsmToken::Eof)) {
     ParseStatementInfo Info(&AsmStrRewrites);
