mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[ObjC][Gen] Emit ObjC strings to respective sections (#84300)
Clang emits ObjC strings into special sections
d5e7c27d53/clang/lib/CodeGen/CGObjCMac.cpp (L4056-L4072)
As far as I can tell from `CGObjCMac.cpp`:
* types go into `__objc_methtype`
* class, category, and protocol names go into `__objc_classname`
* method names, property names, and property types go into
`__objc_methname`
See also https://github.com/swiftlang/swift/pull/84236.
This commit is contained in:
@@ -1464,7 +1464,8 @@ namespace {
|
||||
|
||||
// struct category_t {
|
||||
// char const *name;
|
||||
fields.add(IGM.getAddrOfGlobalString(CategoryName));
|
||||
fields.add(IGM.getAddrOfGlobalString(CategoryName,
|
||||
CStringSectionType::ObjCClassName));
|
||||
// const class_t *theClass;
|
||||
fields.add(getClassMetadataRef());
|
||||
// const method_list_t *instanceMethods;
|
||||
@@ -1503,7 +1504,8 @@ namespace {
|
||||
// Class super;
|
||||
fields.addNullPointer(IGM.Int8PtrTy);
|
||||
// char const *name;
|
||||
fields.add(IGM.getAddrOfGlobalString(getEntityName(nameBuffer)));
|
||||
fields.add(IGM.getAddrOfGlobalString(getEntityName(nameBuffer),
|
||||
CStringSectionType::ObjCClassName));
|
||||
// const protocol_list_t *baseProtocols;
|
||||
fields.add(buildProtocolList(weakLinkage));
|
||||
// const method_list_t *requiredInstanceMethods;
|
||||
@@ -1724,7 +1726,8 @@ namespace {
|
||||
}
|
||||
|
||||
llvm::SmallString<64> buffer;
|
||||
Name = IGM.getAddrOfGlobalString(getClass()->getObjCRuntimeName(buffer));
|
||||
Name = IGM.getAddrOfGlobalString(getClass()->getObjCRuntimeName(buffer),
|
||||
CStringSectionType::ObjCClassName);
|
||||
return Name;
|
||||
}
|
||||
|
||||
@@ -2088,11 +2091,10 @@ namespace {
|
||||
else
|
||||
fields.addNullPointer(IGM.PtrTy);
|
||||
|
||||
// TODO: clang puts this in __TEXT,__objc_methname,cstring_literals
|
||||
fields.add(IGM.getAddrOfGlobalString(name));
|
||||
|
||||
// TODO: clang puts this in __TEXT,__objc_methtype,cstring_literals
|
||||
fields.add(IGM.getAddrOfGlobalString(typeEnc));
|
||||
fields.add(
|
||||
IGM.getAddrOfGlobalString(name, CStringSectionType::ObjCMethodName));
|
||||
fields.add(IGM.getAddrOfGlobalString(typeEnc,
|
||||
CStringSectionType::ObjCMethodType));
|
||||
|
||||
Size size;
|
||||
Alignment alignment;
|
||||
@@ -2228,8 +2230,11 @@ namespace {
|
||||
buildPropertyAttributes(prop, propertyAttributes);
|
||||
|
||||
auto fields = properties.beginStruct();
|
||||
fields.add(IGM.getAddrOfGlobalString(prop->getObjCPropertyName().str()));
|
||||
fields.add(IGM.getAddrOfGlobalString(propertyAttributes));
|
||||
fields.add(
|
||||
IGM.getAddrOfGlobalString(prop->getObjCPropertyName().str(),
|
||||
CStringSectionType::ObjCPropertyName));
|
||||
fields.add(IGM.getAddrOfGlobalString(
|
||||
propertyAttributes, CStringSectionType::ObjCPropertyName));
|
||||
fields.finishAndAddTo(properties);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user