Use of '\01' prefix' in symbols ?

Some of the linker strings are apparently prefixed with \01. I assume this is some sort of escaping mechanism to prevent mangling or demangling.

void CGDebugInfo::EmitFunctionDecl(GlobalDecl GD, SourceLocation Loc,
                                    QualType FnType) {
...
   // the mangled name of the enclosing function.
   if (!name.empty() && name[0] == '\01')
     name = name.substr(1);

So is it harmless to prefix everything (non C++) with '\01' or are there
reasons not to ? For example in CGObjCMac.cpp everything starting with "l_OBJC_" is prefixed with '\01' where as symbols prefixed with 'OBJC_' are not.

Ciao
    Nat!

Some of the linker strings are apparently prefixed with \01. I assume this
is some sort of escaping mechanism to prevent mangling or demangling.

Correct, \01 is used as an indicator to the backend that the name is not to
be touched for decoration purposes.

void CGDebugInfo::EmitFunctionDecl(GlobalDecl GD, SourceLocation Loc,
                                   QualType FnType) {
...
  // the mangled name of the enclosing function.
  if (!name.empty() && name[0] == '\01')
    name = name.substr(1);

So is it harmless to prefix everything (non C++) with '\01' or are there
reasons not to ? For example in CGObjCMac.cpp everything starting with
"l_OBJC_" is prefixed with '\01' where as symbols prefixed with 'OBJC_' are
not.

You should not prefix everything with '\01' as that can potentially give
you the wrong label name. Consider the case of user label prefix being
non-empty (e.g. Windows m68k). The result would be that the label would be
named incorrectly.