···7788Class* __CFConstantStringClassReference __attribute__ ((weak, alias ("_OBJC_CLASS_AppleCFString")));
991010+__attribute__((constructor)) static void forceAppleCFStringLoad()
1111+{
1212+ // The runtime seems to expect at least one instance of AppleCFString to be created
1313+ // before it starts working. Since constant string in application images are not
1414+ // "created", random failures occured.
1515+ [[AppleCFString alloc] dealloc];
1616+}
1717+1018@implementation AppleCFString
1119- (NSUInteger)length
1220{
···7078- (NSZone*) zone
7179{
7280 return NSDefaultMallocZone();
8181+}
8282+8383+- (CFTypeID) _cfTypeID
8484+{
8585+ return CFStringGetTypeID();
7386}
74877588@end
+13-18
src/dyld/DylibSearch.cpp
···1212namespace Darling {
13131414DylibSearch::DylibSearch()
1515+ : m_reFrameworkPath("/System/Library/Frameworks/([a-zA-Z0-9\\.]+)/Versions/([a-zA-Z0-9\\.]+)/.*")
1516{
1617 try
1718 {
1818- int rv = regcomp(&m_reFrameworkPath, "/System/Library/Frameworks/([a-zA-Z0-9\\.]+)/Versions/([a-zA-Z0-9\\.]+)/.*", REG_EXTENDED);
1919- assert(rv == 0);
2020-2119 m_config = new IniConfig(ETC_DARLING_PATH "/dylib.conf");
2220 }
2321 catch (const std::exception& e)
···119117 if (it != m->end())
120118 return it->second.c_str();
121119 }
122122- if (library.compare(0, 27, "/System/Library/Frameworks/", 27) == 0)
120120+121121+ if (m_reFrameworkPath.matches(library))
123122 {
124124- regmatch_t match[3];
125125- if (regexec(&m_reFrameworkPath, library.c_str(), sizeof(match)/sizeof(match[0]), match, 0) != REG_NOMATCH)
123123+ std::string name, version;
124124+125125+ name = m_reFrameworkPath.group(1);
126126+ version = m_reFrameworkPath.group(2);
127127+128128+ if (m_config->hasSection(name))
126129 {
127127- std::string name, version;
128128-129129- name = library.substr(match[1].rm_so, match[1].rm_eo - match[1].rm_so);
130130- version = library.substr(match[2].rm_so, match[2].rm_eo - match[2].rm_so);
131131-132132- if (m_config->hasSection(name))
133133- {
134134- const IniConfig::ValueMap* m = m_config->getSection(name);
135135- auto it = m->find(version);
130130+ const IniConfig::ValueMap* m = m_config->getSection(name);
131131+ auto it = m->find(version);
136132137137- if (it != m->end())
138138- return it->second.c_str();
139139- }
133133+ if (it != m->end())
134134+ return it->second.c_str();
140135 }
141136 }
142137 return nullptr;