Fix for class lookup when using the 2.0 ABI

This commit is contained in:
Richard Frith-Macdonald 2020-02-24 10:23:22 +00:00
parent 5626a9a76d
commit d1af1d0244
2 changed files with 18 additions and 4 deletions

View file

@ -1,3 +1,10 @@
2020-02-24 Richard Frith-Macdonald <rfm@gnu.org>
* Source/objc-load.m: update GSPrivateSymbolPath() so that, on the
path where LINKER_GETSYMBOL os not available, we attempt to lookup
classes using the prefix ._OBJC_CLASS_ for the 2.0 ABI (earlier
ABIs use a prefix of __objc_class_name_ for the class definition.
2020-02-17 Richard Frith-Macdonald <rfm@gnu.org>
* Tools/gdomap.c: When building the list of hosts to be probed to see

View file

@ -281,15 +281,22 @@ NSString *GSPrivateSymbolPath(Class theClass)
if (theClass != nil)
{
const char *prefix
#if __OBJC_GNUSTEP_RUNTIME_ABI__ >= 20
= "._OBJC_CLASS_";
#else
= "__objc_class_name_";
#endif
const char *ret;
char buf[125];
char *p = buf;
const char *className = class_getName(theClass);
int len = strlen(className);
int plen = strlen(prefix);
if (len + sizeof(char)*19 > sizeof(buf))
if (len + plen + 1 > sizeof(buf))
{
p = malloc(len + sizeof(char)*19);
p = malloc(len + plen + 1);
if (p == NULL)
{
@ -298,8 +305,8 @@ NSString *GSPrivateSymbolPath(Class theClass)
}
}
memcpy(p, "__objc_class_name_", sizeof(char)*18);
memcpy(&p[18*sizeof(char)], className, strlen(className) + 1);
memcpy(p, prefix, plen);
memcpy(&p[plen], className, len + 1);
ret = __objc_dynamic_get_symbol_path(0, p);