diff --git a/src/logic/slbt_exec_link.c b/src/logic/slbt_exec_link.c
index a9782fb..1ef8b77 100644
--- a/src/logic/slbt_exec_link.c
+++ b/src/logic/slbt_exec_link.c
@@ -7,13 +7,13 @@
 #include <string.h>
 #include <stdbool.h>
 #include <fcntl.h>
+#include <limits.h>
 #include <errno.h>
 #include <sys/stat.h>
 
 #include <slibtool/slibtool.h>
 #include "slibtool_spawn_impl.h"
 
-
 /*******************************************************************/
 /*                                                                 */
 /* -o <ltlib>  switches              input   result                */
@@ -25,6 +25,10 @@
 /*                                                                 */
 /*******************************************************************/
 
+#ifndef PATH_MAX
+#define PATH_MAX _XOPEN_PATH_MAX
+#endif
+
 static bool slbt_adjust_input_argument(char * arg, bool fpic)
 {
 	char *	dot;
@@ -56,8 +60,8 @@ static int slbt_exec_link_static_archive(
 	char ** 	aarg;
 	char ** 	parg;
 	char *		ranlib[3];
-	char		program[2048];
-	char		output[2048];
+	char		program[PATH_MAX];
+	char		output [PATH_MAX];
 
 	/* placeholders */
 	slbt_reset_placeholders(ectx);