Make 'as' relocatable

This commit is contained in:
Thomas Pöchtrager 2019-08-17 11:48:05 +02:00
parent 3f979bbcd7
commit 5674c31aac

View File

@ -29,6 +29,26 @@ int argc,
char **argv,
char **envp)
{
/* cctools-port */
char libexec[MAXPATHLEN], libexec_old[MAXPATHLEN];
unsigned int libexec_len = sizeof(libexec);
_Static_assert(sizeof(ASLIBEXECDIR) < sizeof(libexec), "");
strcpy(libexec_old, ASLIBEXECDIR);
#undef ASLIBEXECDIR
const char *ASLIBEXECDIR = libexec;
if (!_NSGetExecutablePath(libexec, &libexec_len))
{
char *p = strrchr(libexec, '/');
if (sizeof(libexec) - (p - libexec) < 5)
abort();
strcpy(p, "/../");
}
else
{
strcpy(libexec, libexec_old);
}
/* cctools-port end */
const char *LIB = ASLIBEXECDIR;
const char *LOCALLIB = ASLIBEXECDIR;
const char *AS = "/as";