From 10e590e950b80dd1cef95c5ec3cfc11b513343da Mon Sep 17 00:00:00 2001 From: David Chisnall Date: Thu, 12 Apr 2018 06:46:15 +0000 Subject: ObjCGNU: Fix empty v3 protocols being emitted two fields short Summary: Protocols that were being referenced but could not be fully realized were being emitted without `properties`/`optional_properties`. Since all v3 protocols must be 9 processor words wide, the lack of these fields is catastrophic for the runtime. As an example, the runtime cannot know [here](https://github.com/gnustep/libobjc2/blob/master/protocol.c#L73) that `properties` and `optional_properties` are invalid. Reviewers: rjmccall, theraven Reviewed By: rjmccall, theraven Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D45305 llvm-svn: 329882 --- clang/lib/CodeGen/CGObjCGNU.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'clang/lib/CodeGen/CGObjCGNU.cpp') diff --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp index a6b6c38d5cc..6f4cde569f8 100644 --- a/clang/lib/CodeGen/CGObjCGNU.cpp +++ b/clang/lib/CodeGen/CGObjCGNU.cpp @@ -1748,11 +1748,13 @@ CGObjCGNU::GenerateEmptyProtocol(const std::string &ProtocolName) { llvm::ConstantInt::get(Int32Ty, ProtocolVersion), IdTy)); Elements.add(MakeConstantString(ProtocolName, ".objc_protocol_name")); - Elements.add(ProtocolList); - Elements.add(MethodList); - Elements.add(MethodList); - Elements.add(MethodList); - Elements.add(MethodList); + Elements.add(ProtocolList); /* .protocol_list */ + Elements.add(MethodList); /* .instance_methods */ + Elements.add(MethodList); /* .class_methods */ + Elements.add(MethodList); /* .optional_instance_methods */ + Elements.add(MethodList); /* .optional_class_methods */ + Elements.add(NULLPtr); /* .properties */ + Elements.add(NULLPtr); /* .optional_properties */ return Elements.finishAndCreateGlobal(".objc_protocol", CGM.getPointerAlign()); } -- cgit v1.2.3