| 1134 | } |
| 1135 | |
| 1136 | void ObjCProcessor::PostProcessObjCSections(ObjCReader* reader) |
| 1137 | { |
| 1138 | auto ptrSize = m_data->GetAddressSize(); |
| 1139 | if (auto imageInfo = GetSectionWithName("__objc_imageinfo")) |
| 1140 | { |
| 1141 | auto start = imageInfo->GetStart(); |
| 1142 | auto type = Type::NamedType(m_data, m_typeNames.imageInfo); |
| 1143 | m_data->DefineDataVariable(start, type); |
| 1144 | } |
| 1145 | if (auto selrefs = GetSectionWithName("__objc_selrefs")) |
| 1146 | { |
| 1147 | auto start = selrefs->GetStart(); |
| 1148 | auto end = selrefs->GetEnd(); |
| 1149 | auto type = Type::PointerType(ptrSize, Type::IntegerType(1, false)); |
| 1150 | for (view_ptr_t i = start; i < end; i += ptrSize) |
| 1151 | { |
| 1152 | reader->Seek(i); |
| 1153 | auto selLoc = ReadPointerAccountingForRelocations(reader); |
| 1154 | std::string sel; |
| 1155 | if (const auto& it = m_selectorCache.find(selLoc); it != m_selectorCache.end()) |
| 1156 | sel = it->second; |
| 1157 | else |
| 1158 | { |
| 1159 | reader->Seek(selLoc); |
| 1160 | sel = reader->ReadCString(); |
| 1161 | m_selectorCache[selLoc] = sel; |
| 1162 | DefineObjCSymbol(DataSymbol, Type::ArrayType(Type::IntegerType(1, true), sel.size() + 1), "sel_" + sel, |
| 1163 | selLoc, true); |
| 1164 | } |
| 1165 | DefineObjCSymbol(DataSymbol, type, "selRef_" + sel, i, true); |
| 1166 | } |
| 1167 | } |
| 1168 | if (auto superRefs = GetSectionWithName("__objc_classrefs")) |
| 1169 | { |
| 1170 | auto start = superRefs->GetStart(); |
| 1171 | auto end = superRefs->GetEnd(); |
| 1172 | auto type = Type::PointerType(ptrSize, Type::NamedType(m_data, m_typeNames.cls)); |
| 1173 | for (view_ptr_t i = start; i < end; i += ptrSize) |
| 1174 | { |
| 1175 | reader->Seek(i); |
| 1176 | auto clsLoc = ReadPointerAccountingForRelocations(reader); |
| 1177 | if (const auto& it = m_classes.find(clsLoc); it != m_classes.end()) |
| 1178 | { |
| 1179 | auto& cls = it->second; |
| 1180 | std::string name = cls.name; |
| 1181 | if (!name.empty()) |
| 1182 | DefineObjCSymbol(DataSymbol, type, "clsRef_" + name, i, true); |
| 1183 | } |
| 1184 | } |
| 1185 | } |
| 1186 | if (auto superRefs = GetSectionWithName("__objc_superrefs")) |
| 1187 | { |
| 1188 | auto start = superRefs->GetStart(); |
| 1189 | auto end = superRefs->GetEnd(); |
| 1190 | auto type = Type::PointerType(ptrSize, Type::NamedType(m_data, m_typeNames.cls)); |
| 1191 | for (view_ptr_t i = start; i < end; i += ptrSize) |
| 1192 | { |
| 1193 | reader->Seek(i); |
nothing calls this directly
no test coverage detected