public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] gentoo-alt r1652 - trunk/toolchain-prefix-wrapper/ld
@ 2009-07-01 20:14 Michael Haubenwallner (haubi)
  0 siblings, 0 replies; only message in thread
From: Michael Haubenwallner (haubi) @ 2009-07-01 20:14 UTC (permalink / raw
  To: gentoo-commits

Author: haubi
Date: 2009-07-01 20:14:40 +0000 (Wed, 01 Jul 2009)
New Revision: 1652

Modified:
   trunk/toolchain-prefix-wrapper/ld/hpuxplugin.c
Log:
Added hppa-hpux support, hopefully without breaking ia64-hpux.
Basically knows about all ia64/ia64w/hppa/hppa64, but untested.


Modified: trunk/toolchain-prefix-wrapper/ld/hpuxplugin.c
===================================================================
--- trunk/toolchain-prefix-wrapper/ld/hpuxplugin.c	2009-04-12 19:16:44 UTC (rev 1651)
+++ trunk/toolchain-prefix-wrapper/ld/hpuxplugin.c	2009-07-01 20:14:40 UTC (rev 1652)
@@ -17,23 +17,33 @@
 typedef enum { false = 0, true = 1 } bool;
 #endif
 
-typedef enum { envrunpath_no = 0, envrunpath_first = 1, envrunpath_second = 2 } envrunpath_t;
+typedef enum { EnvRpath_No = 0, EnvRpath_First = 1, EnvRpath_Second = 2 } EnvRpathFlag;
+typedef enum { UseRpath_Concat = 0, UseRpath_First = 1, UseRpath_Last = 2 } UseRpathFlag;
+typedef enum { LinkMode_ELF = 0, LinkMode_SOM = 1, LinkMode_Compat = 2 } LinkModeType;
 
 /* HPUX-ld:
- * When there is no explicit runpath on the linker commandline (+b runpath),
- * then all library paths (-L) are recorded as runpath
+ * ELF: When there is no explicit runpath on the linker commandline (+b runpath),
+ *      then all library paths (-L) are recorded as runpath
+ * SOM: Runpath used to be stored on explicit flag (+b runpath) only. 
+ *      When there is "+b :", then library paths (-L) are recorded as runpath.
+ *      We assume "+b :" is set at least, to get our paths searched always.
  */
 int hpuxplugin(LdPluginData *data)
 {
 	int argc = 0;
 	int err;
+	bool isIA64;
+	bool is64bit;
 
-	bool withDefaultRunpath = true;					/* +nodefaultrpath */
-	envrunpath_t withEnvRunpath = envrunpath_no;	/* +s */
+	/* ELF settings */
+	bool needLibpathAsRunpath = true;
+	UseRpathFlag useRpathFlag = UseRpath_Last;
 
+	EnvRpathFlag envRpathFlag = EnvRpath_No;	/* +s */
 	StringList *tmpArgList = NULL;
 	StringList *runpathList = NULL;
 	StringList *defaultRunpathList = NULL;
+	StringList *sysRunpathList = NULL;
 	String *newString = NULL;
 	String const *argString;
 	char const *argBuffer;
@@ -54,27 +64,69 @@
 		if (defaultRunpathList == NULL)
 			break;
 
+		sysRunpathList = StringListCreate(NULL, 0, 0);
+		if (sysRunpathList == NULL)
+			break;
+
+		if (strncmp(StringGetBuffer(data->in->host.triplet), "ia64", strlen("ia64")) == 0) {
+			isIA64 = true;
+			is64bit = false;
+			if (StringGetBuffer(data->in->host.triplet)[strlen("ia64")] == 'w') {
+				/* ia64w: ELF, 64bit */
+				is64bit = true;
+			}
+		} else
+		if (strncmp(StringGetBuffer(data->in->host.triplet), "hppa64", strlen("hppa64")) == 0) {
+			/* hppa64: ELF, 64bit */
+			isIA64 = false;
+			is64bit = true;
+		} else {
+			/* hppa: SOM, 32bit */
+			isIA64 = false;
+			is64bit = false;
+		}
+
+		if (!isIA64 || is64bit) {
+			/* hppa64 only */
+			for(argc = 1; argc < StringListGetSize(data->in->argList); argc++) {
+				argString = StringListGetString(data->in->argList, argc);
+				argBuffer = StringGetBuffer(argString);
+				if (strcmp(argBuffer, "+concatrpath") == 0) {
+					useRpathFlag = UseRpath_Concat;
+				} else 
+				if (strcmp(argBuffer, "+noconcatrpath") == 0) {
+					useRpathFlag = UseRpath_Last;
+				}
+			}
+		}
+
+		if (!isIA64 && !is64bit) {
+			/* hppa only */
+			useRpathFlag = UseRpath_First;
+		}
+
 		for(argc = 1; argc < StringListGetSize(data->in->argList); argc++) {
 			argString = StringListGetString(data->in->argList, argc);
 			argBuffer = StringGetBuffer(argString);
 			argBufferLength = StringGetLength(argString);
 
 			if (strcmp(argBuffer, "+s") == 0) {
-				if (StringListGetSize(runpathList) == 0)
-					withEnvRunpath = envrunpath_first;
+				if (StringListGetSize(runpathList) + StringListGetSize(sysRunpathList))
+					envRpathFlag = EnvRpath_Second;
 				else
-					withEnvRunpath = envrunpath_second;
+					envRpathFlag = EnvRpath_First;
 				continue;
 			} else
 			if (strcmp(argBuffer, "+nodefaultrpath") == 0) {
-				withDefaultRunpath = false;
+				needLibpathAsRunpath = false;
 				continue;
-#if defined(__ia64)
 			} else
 			if (strcmp(argBuffer, "+defaultrpath") == 0) {
-				withDefaultRunpath = true;
-				continue;
-#endif
+				/* SOM: Unrecognized argument */
+				if (isIA64 || is64bit) {
+					needLibpathAsRunpath = true;
+					continue;
+				}
 			} else
 			if (strncmp(argBuffer, "+b", 2) == 0) {
 				/* collect runpath from "+b runpath1:runpathN" */
@@ -90,6 +142,47 @@
 					argBufferLength = StringGetLength(argString);
 				}
 
+				if (useRpathFlag != UseRpath_Concat) {
+					if (StringListGetSize(runpathList) + StringListGetSize(sysRunpathList)) {
+						if (useRpathFlag == UseRpath_First) {
+							continue;
+						}
+						StringListClear(runpathList);
+						StringListClear(sysRunpathList);
+					}
+
+					if (argBufferLength == 1 && argBuffer[0] == ':') {
+						/* "+b:" collects all "-L" paths and LPATH envvar */
+						needLibpathAsRunpath = true;
+						/* TODO: getenv("LPATH") */
+						if (isIA64 && is64bit) {
+							/* ia64w */
+							if (StringListAppendConcat(sysRunpathList,
+									"/usr/lib/hpux64", strlen("/usr/lib/hpux64"),
+							NULL) < 0)
+								break;
+						} else
+						if (isIA64 && !is64bit) {
+							/* ia64 */
+							if (StringListAppendConcat(sysRunpathList,
+									"/usr/lib/hpux32", strlen("/usr/lib/hpux32"),
+							NULL) < 0)
+								break;
+						} else
+						if (is64bit) {
+							/* hppa64 */
+							if (StringListAppendConcat(sysRunpathList,
+									"/usr/lib/pa20_64", strlen("/usr/lib/pa20_64"),
+									"/usr/ccs/lib/pa20_64", strlen("/usr/ccs/lib/pa20_64"),
+							NULL) < 0)
+								break;
+						} else {
+							/* hppa */
+						}
+						continue;
+					}
+				}
+
 				for(curr = next = argBuffer; *next != '\0'; curr = next+1) {
 					for(next = curr; *next != '\0' && *next != ':'; next++);
 
@@ -166,7 +259,7 @@
 			break;
 
 		/* do we need to use env-runpath first? */
-		if (withEnvRunpath == envrunpath_first
+		if (envRpathFlag == EnvRpath_First
 		 && StringListAppendConcat(data->out->argList, "+s", 2, NULL) < 0
 		) break;
 
@@ -182,7 +275,7 @@
 		 * if not disabled with "+nodefaultrpath"
 		 */
 		if (StringListGetSize(runpathList) == 0
-		 && withDefaultRunpath == true
+		 && needLibpathAsRunpath == true
 		 && StringListAppendList(runpathList, data->in->userLibpath, 0, -1) < 0
 		) break;
 
@@ -194,6 +287,10 @@
 		if (StringListAppendList(runpathList, data->in->sysRunpath, 0, -1) < 0)
 			break;
 
+		/* append local sys libpath list to runpath list */
+		if (StringListAppendList(runpathList, sysRunpathList, 0, -1) < 0)
+			break;
+
 		/* create runpath string: runpath1:runpathN */
 		newString = StringListJoin(runpathList, NULL, 0, ":", 1, NULL, 0);
 		if (newString == NULL)
@@ -204,7 +301,7 @@
 			break;
 
 		/* do we need to use env-runpath second? */
-		if (withEnvRunpath == envrunpath_second
+		if (envRpathFlag == EnvRpath_Second
 		 && StringListAppendConcat(data->out->argList, "+s", 2, NULL) < 0
 		) break;
 
@@ -218,6 +315,7 @@
 	} while(0);	/* end dummy loop */
 
 	newString = StringDestroy(newString);
+	sysRunpathList = StringListDestroy(sysRunpathList);
 	defaultRunpathList = StringListDestroy(defaultRunpathList);
 	runpathList = StringListDestroy(runpathList);
 	tmpArgList = StringListDestroy(tmpArgList);




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-07-01 20:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-01 20:14 [gentoo-commits] gentoo-alt r1652 - trunk/toolchain-prefix-wrapper/ld Michael Haubenwallner (haubi)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox