Patchwork collect2 should accept more AIX linker flags to change shared library search order

login
register
mail settings
Submitter Michael Haubenwallner
Date Feb. 5, 2013, 12:10 p.m.
Message ID <5110F699.1030706@salomon.at>
Download mbox | patch
Permalink /patch/218254/
State New
Headers show

Comments

Michael Haubenwallner - Feb. 5, 2013, 12:10 p.m.
On 02/04/2013 10:33 PM, David Edelsohn wrote:
> 2013-02-04  Michael Haubenwallner <michael.haubenwallner@salomon.at>
> 
> 	Accept all flags that enable aix runtime linking to change the
> 	library search order. Also there is a disabling flag.

> This patch is okay, and I agree that it should use strncmp.

Updated to use strcmp/strncmp. While at it, also check for "-bexport:" instead
of "-bexport", as this (and "-bE:") always needs the filename anyway.

> Do you have SVN write access?

Nope.

Thank you!
/haubi/

Patch

2013-02-05  Michael Haubenwallner <michael.haubenwallner@salomon.at>

	Accept all flags that enable aix runtime linking to change the
	library search order. Also there is a disabling flag.
	* collect2.c (aixrtl_flag): Enabled by -G and -bsvr4 too, disabled
	by -bnortl. Use strcmp,strncmp for all these aix flags too. And
	-bexport always needs the filename, so test for '-bexport:'.
---
 gcc/collect2.c |   28 ++++++++++++++--------------
 1 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/gcc/collect2.c b/gcc/collect2.c
index 0db908f..99dd41d 100644
--- a/gcc/collect2.c
+++ b/gcc/collect2.c
@@ -1022,20 +1022,20 @@  main (int argc, char **argv)
 	  selected_linker = USE_GOLD_LD;
 
 #ifdef COLLECT_EXPORT_LIST
-	/* since -brtl, -bexport, -b64 are not position dependent
-	   also check for them here */
-	if ((argv[i][0] == '-') && (argv[i][1] == 'b'))
-  	  {
-	    arg = argv[i];
-	    /* We want to disable automatic exports on AIX when user
-	       explicitly puts an export list in command line */
-	    if (arg[2] == 'E' || strncmp (&arg[2], "export", 6) == 0)
-	      export_flag = 1;
-	    else if (arg[2] == '6' && arg[3] == '4')
-	      aix64_flag = 1;
-	    else if (arg[2] == 'r' && arg[3] == 't' && arg[4] == 'l')
-	      aixrtl_flag = 1;
-	  }
+	/* These flags are position independent, although their order
+	   is important - subsequent flags override earlier ones. */
+	else if (strcmp (argv[i], "-b64") == 0)
+	    aix64_flag = 1;
+	/* -bexport:filename always needs the :filename */
+	else if (strncmp (argv[i], "-bE:", 4) == 0
+	      || strncmp (argv[i], "-bexport:", 9) == 0)
+	    export_flag = 1;
+	else if (strcmp (argv[i], "-brtl") == 0
+	      || strcmp (argv[i], "-bsvr4") == 0
+	      || strcmp (argv[i], "-G") == 0)
+	    aixrtl_flag = 1;
+	else if (strcmp (argv[i], "-bnortl") == 0)
+	    aixrtl_flag = 0;
 #endif
       }
     vflag = debug;
-- 
1.7.3.4