[PATCH] COFF MC: better handling of tricky symbol and section names

Reid Kleckner rnk at google.com
Tue Oct 15 17:08:49 PDT 2013



================
Comment at: lib/MC/MCParser/AsmParser.cpp:795
@@ -794,2 +794,3 @@
     // This is a symbol reference.
     std::pair<StringRef, StringRef> Split = Identifier.split('@');
+    if (FirstTokenKind == AsmToken::String) {
----------------
Maybe '@' symbols should form separate tokens, but that would be a large change.

================
Comment at: lib/MC/MCSectionCOFF.cpp:42-49
@@ -41,1 +41,10 @@
 
+static bool isAcceptableSectionNameChar(char C) {
+  if ((C < 'a' || C > 'z') &&
+      (C < 'A' || C > 'Z') &&
+      (C < '0' || C > '9') &&
+      C != '_' && C != '$' && C != '.')
+    return false;
+  return true;
+}
+
----------------
This seems easier to implement in the forward sense, like:
  return ('a' <= C && C <= 'z') ||
         ('A' <= C && ...
         C == '_' || C == '$' || ...

================
Comment at: lib/MC/MCSectionCOFF.cpp:71
@@ +70,3 @@
+  if (sectionNameNeedsQuoting(getSectionName()))
+    OS << "\t.section\t" << '"' << getSectionName() << '"' << ",\"";
+  else
----------------
We should escape the quotes.  There's stuff in support that'll help.


http://llvm-reviews.chandlerc.com/D1945



More information about the llvm-commits mailing list