From 32e31f063f8c37ec0fb38e648685012e01cd8965 Mon Sep 17 00:00:00 2001 From: davek Date: Tue, 29 Dec 2009 04:13:09 +0000 Subject: [PATCH] 2009-10-06 Iain Sandoe PR objective-c++/41595 * config/darwin.c (darwin_label_is_anonymous_local_objc_name): New function to recognize objective c/c++ internal symbols, including mangled ones. * config/darwin.h (ASM_OUTPUT_LABELREF): Use darwin_label_is_anonymous_local_objc_name to detect both mangled and clear ObjC internal symbols. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@155500 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 12 ++++++++++++ gcc/config/darwin.c | 19 +++++++++++++++++++ gcc/config/darwin.h | 8 ++++++-- 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 022296f..ffe2782 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,15 @@ +2009-12-29 Dave Korn + + 2009-10-06 Iain Sandoe + + PR objective-c++/41595 + * config/darwin.c (darwin_label_is_anonymous_local_objc_name): + New function to recognize objective c/c++ internal symbols, + including mangled ones. + * config/darwin.h (ASM_OUTPUT_LABELREF): Use + darwin_label_is_anonymous_local_objc_name to detect both + mangled and clear ObjC internal symbols. + 2009-12-28 H.J. Lu PR middle-end/41344 diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c index b5c4fb8..1880063 100644 --- a/gcc/config/darwin.c +++ b/gcc/config/darwin.c @@ -1373,6 +1373,25 @@ darwin_globalize_label (FILE *stream, const char *name) default_globalize_label (stream, name); } +/* This routine returns non-zero if 'name' starts with the special objective-c + anonymous file-scope static name. It accommodates c++'s mangling of such + symbols (in this case the symbols will have form _ZL{d}*_OBJC_* d=digit). */ + +int +darwin_label_is_anonymous_local_objc_name (const char *name) +{ + const unsigned char *p = (const unsigned char *) name; + if (*p != '_') + return 0; + if (p[1] == 'Z' && p[2] == 'L') + { + p += 3; + while (*p >= '0' && *p <= '9') + p++; + } + return (!strncmp ((const char *)p, "_OBJC_", 6)); +} + void darwin_asm_named_section (const char *name, unsigned int flags ATTRIBUTE_UNUSED, diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h index 4152f24..2bcc71a 100644 --- a/gcc/config/darwin.h +++ b/gcc/config/darwin.h @@ -647,7 +647,11 @@ extern GTY(()) int darwin_ms_struct; } while (0) /* Wrap new method names in quotes so the assembler doesn't gag. - Make Objective-C internal symbols local. */ + Make Objective-C internal symbols local and in doing this, we need + to accommodate the name mangling done by c++ on file scope locals. */ + + +int darwin_label_is_anonymous_local_objc_name (const char *name); #undef ASM_OUTPUT_LABELREF #define ASM_OUTPUT_LABELREF(FILE,NAME) \ @@ -673,7 +677,7 @@ extern GTY(()) int darwin_ms_struct; } \ else if (xname[0] == '+' || xname[0] == '-') \ fprintf (FILE, "\"%s\"", xname); \ - else if (!strncmp (xname, "_OBJC_", 6)) \ + else if (darwin_label_is_anonymous_local_objc_name (xname)) \ fprintf (FILE, "L%s", xname); \ else if (!strncmp (xname, ".objc_class_name_", 17)) \ fprintf (FILE, "%s", xname); \ -- 2.7.4