[committed] Fix long local calls on PA HP-UX SOM target

John David Anglin dave@hiauly1.hia.nrc.ca
Sat Mar 10 04:44:00 GMT 2007


The enclosed problem was reported directly to me.  We were using the
"LONG_PIC_PCREL" sequence for local calls on the HP-UX SOM target.
This sequence uses the special symbol $PIC_pcrel$0 to create a pc-relative
relocation.  However, GAS doesn't handle this correctly on the HP-UX
SOM target and the symbol isn't stripped.  So, linking fails when we
need a long local call.

To fix this, we need to use the "LONG_PIC_SDIFF" sequence which uses
a difference of labels.  GAS does handle this correctly.

Someday the selection of call sequences needs to be consolidated in
a function.

Tested on hppa2.0w-hp-hpux11.11, hppa64-hp-hpux11.11 and
hppa-unknown-linux-gnu.  Committed to trunk, 4.2 and 4.1 branches.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc-cnrc.gc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6602)

2007-03-09  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>

	* pa.c (attr_length_call): Revise condition for long pc-relative branch.
	(output_call): Use "LONG_PIC_SDIFF" instruction sequence for long local
	calls on the SOM target.  Don't use "LONG_PIC_PCREL" call sequence on
	SOM target.

Index: config/pa/pa.c
===================================================================
--- config/pa/pa.c	(revision 122730)
+++ config/pa/pa.c	(working copy)
@@ -7273,9 +7223,10 @@
     length += 12;
 
   /* long pc-relative branch sequence.  */
-  else if ((TARGET_SOM && TARGET_LONG_PIC_SDIFF_CALL)
+  else if ((TARGET_SOM && (TARGET_LONG_PIC_SDIFF_CALL || local_call))
 	   || (TARGET_64BIT && !TARGET_GAS)
-	   || (TARGET_GAS && (TARGET_LONG_PIC_PCREL_CALL || local_call)))
+	   || (TARGET_GAS && !TARGET_SOM
+	       && (TARGET_LONG_PIC_PCREL_CALL || local_call)))
     {
       length += 20;
 
@@ -7385,8 +7336,9 @@
 	     of increasing length and complexity.  In most cases,
              they don't allow an instruction in the delay slot.  */
 	  if (!((TARGET_LONG_ABS_CALL || local_call) && !flag_pic)
-	      && !(TARGET_SOM && TARGET_LONG_PIC_SDIFF_CALL)
-	      && !(TARGET_GAS && (TARGET_LONG_PIC_PCREL_CALL || local_call))
+	      && !(TARGET_SOM && (TARGET_LONG_PIC_SDIFF_CALL || local_call))
+	      && !(TARGET_GAS && !TARGET_SOM
+		   && (TARGET_LONG_PIC_PCREL_CALL || local_call))
 	      && !TARGET_64BIT)
 	    indirect_call = 1;
 
@@ -7432,7 +7384,7 @@
 	    }
 	  else
 	    {
-	      if ((TARGET_SOM && TARGET_LONG_PIC_SDIFF_CALL)
+	      if ((TARGET_SOM && (TARGET_LONG_PIC_SDIFF_CALL || local_call))
 		  || (TARGET_64BIT && !TARGET_GAS))
 		{
 		  /* The HP assembler and linker can handle relocations
@@ -7446,7 +7398,8 @@
 					     CODE_LABEL_NUMBER (xoperands[1]));
 		  output_asm_insn ("ldo R'%0-%l1(%%r1),%%r1", xoperands);
 		}
-	      else if (TARGET_GAS && (TARGET_LONG_PIC_PCREL_CALL || local_call))
+	      else if (TARGET_GAS && !TARGET_SOM
+		       && (TARGET_LONG_PIC_PCREL_CALL || local_call))
 		{
 		  /*  GAS currently can't generate the relocations that
 		      are needed for the SOM linker under HP-UX using this



More information about the Gcc-patches mailing list