diff options
| author | Fariborz Jahanian <fjahanian@apple.com> | 2012-03-11 19:41:56 +0000 |
|---|---|---|
| committer | Fariborz Jahanian <fjahanian@apple.com> | 2012-03-11 19:41:56 +0000 |
| commit | 008dfe2fb3354e281de87adc9a7f95b5f09e769a (patch) | |
| tree | 8322315c744d05ed2cdfbac470a4e67f686da968 /clang/lib | |
| parent | 0f90695e31405bffe7fb487183f4d106ee6a1e60 (diff) | |
| download | bcm5719-llvm-008dfe2fb3354e281de87adc9a7f95b5f09e769a.tar.gz bcm5719-llvm-008dfe2fb3354e281de87adc9a7f95b5f09e769a.zip | |
objective-c modern abi rewriter: provide section pragmas for
statically writter metadata.
// rdar://11023490
llvm-svn: 152546
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Rewrite/RewriteModernObjC.cpp | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/clang/lib/Rewrite/RewriteModernObjC.cpp b/clang/lib/Rewrite/RewriteModernObjC.cpp index 5aea70133ea..a22f8fad728 100644 --- a/clang/lib/Rewrite/RewriteModernObjC.cpp +++ b/clang/lib/Rewrite/RewriteModernObjC.cpp @@ -5158,6 +5158,14 @@ void RewriteModernObjC::Initialize(ASTContext &context) { Preamble += "struct __rw_objc_super { struct objc_object *object; "; Preamble += "struct objc_object *superClass; "; if (LangOpts.MicrosoftExt) { + // Define all sections using syntax that makes sense. + Preamble += "\n#pragma section(\".datacoal_nt$B\", long, read, write)\n"; + Preamble += "#pragma section(\".cat_cls_meth$B\", long, read, write)\n"; + Preamble += "#pragma section(\".objc_classlist$B\", long, read, write)\n"; + Preamble += "#pragma section(\".objc_catlist$B\", long, read, write)\n"; + Preamble += "#pragma section(\".inst_meth$B\", long, read, write)\n"; + Preamble += "#pragma section(\".cls_meth$B\", long, read, write)\n"; + // Add a constructor for creating temporary objects. Preamble += "__rw_objc_super(struct objc_object *o, struct objc_object *s) " ": "; @@ -6013,7 +6021,10 @@ void RewriteModernObjC::RewriteObjCProtocolMetaData(ObjCProtocolDecl *PDecl, PDecl->getNameAsString()); // Writer out root metadata for current protocol: struct _protocol_t - Result += "\nstatic struct _protocol_t _OBJC_PROTOCOL_"; + Result += "\n"; + if (LangOpts.MicrosoftExt) + Result += "__declspec(allocate(\".datacoal_nt$B\")) "; + Result += "static struct _protocol_t _OBJC_PROTOCOL_"; Result += PDecl->getNameAsString(); Result += " __attribute__ ((used, section (\"__DATA,__datacoal_nt,coalesced\"))) = {\n"; Result += "\t0,\n"; // id is; is null @@ -6092,7 +6103,10 @@ void RewriteModernObjC::RewriteObjCProtocolListMetaData( struct _objc_protocol *class_protocols[]; } */ - Result += "\nstatic struct {\n"; + Result += "\n"; + if (LangOpts.MicrosoftExt) + Result += "__declspec(allocate(\".cat_cls_meth$B\")) "; + Result += "static struct {\n"; Result += "\tstruct _objc_protocol_list *next;\n"; Result += "\tint protocol_count;\n"; Result += "\tstruct _objc_protocol *class_protocols["; @@ -6312,6 +6326,8 @@ void RewriteModernObjC::RewriteMetaDataIntoBuffer(std::string &Result) { RewriteObjCCategoryImplDecl(CategoryImplementation[i], Result); if (ClsDefCount > 0) { + if (LangOpts.MicrosoftExt) + Result += "__declspec(allocate(\".objc_classlist$B\")) "; Result += "static struct _class_t *L_OBJC_LABEL_CLASS_$ ["; Result += llvm::utostr(ClsDefCount); Result += "]"; Result += @@ -6326,6 +6342,8 @@ void RewriteModernObjC::RewriteMetaDataIntoBuffer(std::string &Result) { } if (CatDefCount > 0) { + if (LangOpts.MicrosoftExt) + Result += "__declspec(allocate(\".objc_catlist$B\")) "; Result += "static struct _category_t *L_OBJC_LABEL_CATEGORY_$ ["; Result += llvm::utostr(CatDefCount); Result += "]"; Result += @@ -6470,7 +6488,14 @@ void RewriteModernObjC::RewriteObjCMethodsMetaData(MethodIterator MethodBegin, } */ unsigned NumMethods = std::distance(MethodBegin, MethodEnd); - Result += "\nstatic struct {\n"; + Result += "\n"; + if (LangOpts.MicrosoftExt) { + if (IsInstanceMethod) + Result += "__declspec(allocate(\".inst_meth$B\")) "; + else + Result += "__declspec(allocate(\".cls_meth$B\")) "; + } + Result += "static struct {\n"; Result += "\tstruct _objc_method_list *next_method;\n"; Result += "\tint method_count;\n"; Result += "\tstruct _objc_method method_list["; |

