@@ -20,6 +20,11 @@ extern char** environ;
2020static const char HYPHEN [] = "-" ;
2121static const char BINUTILS_STRIP [] = "strip" ;
2222
23+ static const char LLVM_STRIP [] = "llvm-strip" ;
24+ static const char LLVM_OBJCOPY [] = "llvm-objcopy" ;
25+
26+ static const char LLVM_COMMAND_PREFIX [] = "llvm-" ;
27+
2328#define BINFMT_X86_64 (0x01)
2429#define BINFMT_i386 (0x02)
2530#define BINFMT_MIPS64EL (0x03)
@@ -203,6 +208,7 @@ int main(int argc, char* argv[], char* envp[]) {
203208 const char * triplet = NULL ;
204209 char * input = NULL ;
205210
211+ const char * file_name = NULL ;
206212 char * parent_directory = NULL ;
207213 char * app_filename = NULL ;
208214
@@ -269,6 +275,13 @@ int main(int argc, char* argv[], char* envp[]) {
269275 goto end ;
270276 }
271277
278+ file_name = basename (app_filename );
279+
280+ if (!(strcmp (file_name , LLVM_STRIP ) == 0 || strcmp (file_name , LLVM_OBJCOPY ) == 0 )) {
281+ err = ERR_UNKNOWN_BINUTILS_WRAPPER ;
282+ goto end ;
283+ }
284+
272285 parent_directory = malloc (strlen (app_filename ) + 1 );
273286
274287 if (parent_directory == NULL ) {
@@ -314,7 +327,7 @@ int main(int argc, char* argv[], char* envp[]) {
314327
315328 free (executable );
316329
317- executable = malloc (strlen (parent_directory ) + strlen (PATHSEP_S ) + strlen (triplet ) + strlen (HYPHEN ) + strlen (BINUTILS_STRIP ) + 1 );
330+ executable = malloc (strlen (parent_directory ) + strlen (PATHSEP_S ) + strlen (triplet ) + strlen (HYPHEN ) + strlen (file_name ) + 1 );
318331
319332 if (executable == NULL ) {
320333 err = ERR_MEM_ALLOC_FAILURE ;
@@ -325,7 +338,7 @@ int main(int argc, char* argv[], char* envp[]) {
325338 strcat (executable , PATHSEP_S );
326339 strcat (executable , triplet );
327340 strcat (executable , HYPHEN );
328- strcat (executable , BINUTILS_STRIP );
341+ strcat (executable , file_name + strlen ( LLVM_COMMAND_PREFIX ) );
329342
330343 args [0 ] = executable ;
331344 args [kargc ] = input ;
0 commit comments