Fix multiple rpath tccmacho

If multiple rpaths are specified then output multiple LC_RPATH load
commands instead of one with : seperator.
This commit is contained in:
herman ten brugge 2022-12-23 19:48:39 +01:00
parent 03841b6f16
commit 3fd6a05fff

View File

@ -1771,11 +1771,19 @@ static void collect_sections(TCCState *s1, struct macho *mo, const char *filenam
}
if (s1->rpath) {
i = (sizeof(*rpath) + strlen(s1->rpath) + 1 + 7) &-8;
rpath = add_lc(mo, LC_RPATH, i);
rpath->path = sizeof(*rpath);
str = (char*)rpath + rpath->path;
strcpy(str, s1->rpath);
char *path = s1->rpath, *end;
do {
end = strchr(path, ':');
if (!end)
end = strchr(path, 0);
i = (sizeof(*rpath) + (end - path) + 1 + 7) &-8;
rpath = add_lc(mo, LC_RPATH, i);
rpath->path = sizeof(*rpath);
str = (char*)rpath + rpath->path;
memcpy(str, path, end - path);
str[end - path] = 0;
path = end + 1;
} while (*end);
}
fileofs = 4096; /* leave space for mach-o headers */