Merge pull request #1314 from jpoimboe/unique-id-fix

create-diff-object: fix __UNIQUE_ID() variable correlation
This commit is contained in:
Josh Poimboeuf 2022-11-30 14:55:18 -06:00 committed by GitHub
commit 984e7de2fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 1 deletions

View File

@ -396,6 +396,35 @@ static bool has_digit_tail(char *tail)
return false;
}
/*
* Hack for __UNIQUE_ID(). The following should match:
*
* __UNIQUE_ID_ddebug1131.186
* __UNIQUE_ID_ddebug1132.187
*/
static int __kpatch_unique_id_strcmp(char *s1, char *s2)
{
/* match '__UNIQUE_ID_ddebug' */
while (*s1 == *s2) {
if (!*s1)
return 0;
s1++;
s2++;
}
/* skip digits before '.' or EOL */
while (isdigit(*s1))
s1++;
while (isdigit(*s2))
s2++;
if ((!*s1 || has_digit_tail(s1)) &&
(!*s2 || has_digit_tail(s2)))
return 0;
return 1;
}
/*
* This is like strcmp, but for gcc-mangled symbols. It skips the comparison
* of any substring which consists of '.' followed by any number of digits.
@ -409,6 +438,9 @@ static int kpatch_mangled_strcmp(char *s1, char *s2)
if (strstr(s1, ".str1."))
return strcmp(s1, s2);
if (!strncmp(s1, "__UNIQUE_ID_", 12))
return __kpatch_unique_id_strcmp(s1, s2);
while (*s1 == *s2) {
if (!*s1)
return 0;

@ -1 +1 @@
Subproject commit d084a0fbd02d15d45ba3224d15a9ebaab0db0cd7
Subproject commit 6485a329826b7299859b246e2f9850ea19f52e77