[PATCH] D44633: missing FILE symbol for .(s|S) files

Robert Nagy via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 19 08:49:25 PDT 2018


rnagy created this revision.
Herald added a subscriber: llvm-commits.

Hello

When compiling .(s|S) files with clang, a FILE symbol is missing from the object
file, unless explicitly setting one with the .file directive. Not using the integrated as, also fixes the issue:

$ clang -g bzero.S a.c && readelf -Ws a.out | grep FILE

  33: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS a.c

$ clang -no-integrated-as -g bzero.S a.c && readelf -Ws a.out | grep FILE

  31: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS bzero.S
  33: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS a.c

$ gcc -g bzero.S a.c && readelf -Ws a.out | grep FILE

  31: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS bzero.S
  33: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS a.c

This seems like a bug and the FILE symbol should be added with the integrated
as as well.

The patch that I've attached works for me and generates the
proper file directive.

https://bugs.llvm.org/show_bug.cgi?id=34019

Thank you!


Repository:
  rL LLVM

https://reviews.llvm.org/D44633

Files:
  lib/MC/MCParser/AsmParser.cpp


Index: lib/MC/MCParser/AsmParser.cpp
===================================================================
--- lib/MC/MCParser/AsmParser.cpp
+++ lib/MC/MCParser/AsmParser.cpp
@@ -836,6 +836,8 @@
   AsmCond StartingCondState = TheCondState;
   SmallVector<AsmRewrite, 4> AsmStrRewrites;
 
+  StringRef Filename = getContext().getMainFileName();
+
   // If we are generating dwarf for assembly source files save the initial text
   // section and generate a .file directive.
   if (getContext().getGenDwarfForAssembly()) {
@@ -849,9 +851,12 @@
     assert(InsertResult && ".text section should not have debug info yet");
     (void)InsertResult;
     getContext().setGenDwarfFileNumber(getStreamer().EmitDwarfFileDirective(
-        0, StringRef(), getContext().getMainFileName()));
+        0, StringRef(), Filename));
   }
 
+  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);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44633.138947.patch
Type: text/x-patch
Size: 1068 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180319/d81d3e29/attachment.bin>


More information about the llvm-commits mailing list