This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[MIPS, committed] Set pointer_equality_needed for more relocations


I noticed while writing some MIPS16 and microMIPS PLT tests that we were
failing to set a symbol value for functions with access patterns like:

	jal    foo
	...
	.word  foo

This is because we weren't setting pointer_equality_needed in cases where
the R_MIPS_32 might become dynamic.  We also weren't setting it for non-call
GOT relocations.  Both types of relocation would therefore resolve locally but
without the PLT acting as the canonical address.

(For lazy-binding stubs we use a MIPS-specific no_fn_stub instead of
pointer_equality_needed, and we were setting that correctly.)

Also, we were leaving symbols in the global GOT even if we'd decided to
set their values locally via PLTs or copy relocs.  That isn't wrong,
but is slightly wasteful.  (The dynamic linker mustn't use the global
GOT as a cache when finding the original definition of a R_MIPS_COPY
symbol, so it's an exception to the usual rule that relocations must be
against symbols in the global GOT.)

Fixed as follows.  Tested against the GCC testsuite on mips64-linux-gnu
and against the binutils testsuite on the usual targets.

Richard


bfd/
	* elfxx-mips.c (mips_use_local_got_p): New function.
	(mips_elf_count_got_symbols, mips_elf_calculate_relocation): Use it.
	(_bfd_mips_elf_check_relocs): Set pointer_equality_needed for
	GOT and absolute references.

ld/testsuite/
	* ld-mips-elf/pic-and-nonpic-6-n32.ad,
	ld-mips-elf/pic-and-nonpic-6-n32.dd,
	ld-mips-elf/pic-and-nonpic-6-n32.gd,
	ld-mips-elf/pic-and-nonpic-6-n32.nd,
	ld-mips-elf/pic-and-nonpic-6-n32.rd,
	ld-mips-elf/pic-and-nonpic-6-n64.ad,
	ld-mips-elf/pic-and-nonpic-6-n64.dd,
	ld-mips-elf/pic-and-nonpic-6-n64.gd,
	ld-mips-elf/pic-and-nonpic-6-n64.nd,
	ld-mips-elf/pic-and-nonpic-6-n64.rd,
	ld-mips-elf/pic-and-nonpic-6-o32.ad,
	ld-mips-elf/pic-and-nonpic-6-o32.dd,
	ld-mips-elf/pic-and-nonpic-6-o32.gd,
	ld-mips-elf/pic-and-nonpic-6-o32.nd,
	ld-mips-elf/pic-and-nonpic-6-o32.rd: Fix symbol value of extf4.
	No longer expect extf3, extf4 and extd2 to be in the global GOT.

Index: bfd/elfxx-mips.c
===================================================================
--- bfd/elfxx-mips.c	2013-10-13 11:00:58.567356191 +0100
+++ bfd/elfxx-mips.c	2013-10-13 11:01:41.669763715 +0100
@@ -4299,6 +4299,36 @@ mips_elf_resolve_final_got_entries (stru
   return TRUE;
 }
 
+/* Return true if a GOT entry for H should live in the local rather than
+   global GOT area.  */
+
+static bfd_boolean
+mips_use_local_got_p (struct bfd_link_info *info,
+		      struct mips_elf_link_hash_entry *h)
+{
+  /* Symbols that aren't in the dynamic symbol table must live in the
+     local GOT.  This includes symbols that are completely undefined
+     and which therefore don't bind locally.  We'll report undefined
+     symbols later if appropriate.  */
+  if (h->root.dynindx == -1)
+    return TRUE;
+
+  /* Symbols that bind locally can (and in the case of forced-local
+     symbols, must) live in the local GOT.  */
+  if (h->got_only_for_calls
+      ? SYMBOL_CALLS_LOCAL (info, &h->root)
+      : SYMBOL_REFERENCES_LOCAL (info, &h->root))
+    return TRUE;
+
+  /* If this is an executable that must provide a definition of the symbol,
+     either though PLTs or copy relocations, then that address should go in
+     the local rather than global GOT.  */
+  if (info->executable && h->has_static_relocs)
+    return TRUE;
+
+  return FALSE;
+}
+
 /* A mips_elf_link_hash_traverse callback for which DATA points to the
    link_info structure.  Decide whether the hash entry needs an entry in
    the global part of the primary GOT, setting global_got_area accordingly.
@@ -4318,18 +4348,8 @@ mips_elf_count_got_symbols (struct mips_
   if (h->global_got_area != GGA_NONE)
     {
       /* Make a final decision about whether the symbol belongs in the
-	 local or global GOT.  Symbols that bind locally can (and in the
-	 case of forced-local symbols, must) live in the local GOT.
-	 Those that are aren't in the dynamic symbol table must also
-	 live in the local GOT.
-
-	 Note that the former condition does not always imply the
-	 latter: symbols do not bind locally if they are completely
-	 undefined.  We'll report undefined symbols later if appropriate.  */
-      if (h->root.dynindx == -1
-	  || (h->got_only_for_calls
-	      ? SYMBOL_CALLS_LOCAL (info, &h->root)
-	      : SYMBOL_REFERENCES_LOCAL (info, &h->root)))
+	 local or global GOT.  */
+      if (mips_use_local_got_p (info, h))
 	/* The symbol belongs in the local GOT.  We no longer need this
 	   entry if it was only used for relocations; those relocations
 	   will be against the null or section symbol instead of H.  */
@@ -5468,10 +5488,7 @@ mips_elf_calculate_relocation (bfd *abfd
 				&& (target_is_16_bit_code_p
 				    || target_is_micromips_code_p))));
 
-  local_p = (h == NULL
-	     || (h->got_only_for_calls
-		 ? SYMBOL_CALLS_LOCAL (info, &h->root)
-		 : SYMBOL_REFERENCES_LOCAL (info, &h->root)));
+  local_p = (h == NULL || mips_use_local_got_p (info, h));
 
   gp0 = _bfd_get_gp_value (input_bfd);
   gp = _bfd_get_gp_value (abfd);
@@ -7955,6 +7972,8 @@ _bfd_mips_elf_check_relocs (bfd *abfd, s
       unsigned int r_type;
       struct elf_link_hash_entry *h;
       bfd_boolean can_make_dynamic_p;
+      bfd_boolean call_reloc_p;
+      bfd_boolean constrain_symbol_p;
 
       r_symndx = ELF_R_SYM (abfd, rel->r_info);
       r_type = ELF_R_TYPE (abfd, rel->r_info);
@@ -7987,12 +8006,30 @@ _bfd_mips_elf_check_relocs (bfd *abfd, s
       /* Set CAN_MAKE_DYNAMIC_P to true if we can convert this
 	 relocation into a dynamic one.  */
       can_make_dynamic_p = FALSE;
+
+      /* Set CALL_RELOC_P to true if the relocation is for a call,
+	 and if pointer equality therefore doesn't matter.  */
+      call_reloc_p = FALSE;
+
+      /* Set CONSTRAIN_SYMBOL_P if we need to take the relocation
+	 into account when deciding how to define the symbol.
+	 Relocations in nonallocatable sections such as .pdr and
+	 .debug* should have no effect.  */
+      constrain_symbol_p = ((sec->flags & SEC_ALLOC) != 0);
+
       switch (r_type)
 	{
-	case R_MIPS_GOT16:
 	case R_MIPS_CALL16:
 	case R_MIPS_CALL_HI16:
 	case R_MIPS_CALL_LO16:
+	case R_MIPS16_CALL16:
+	case R_MICROMIPS_CALL16:
+	case R_MICROMIPS_CALL_HI16:
+	case R_MICROMIPS_CALL_LO16:
+	  call_reloc_p = TRUE;
+	  /* Fall through.  */
+
+	case R_MIPS_GOT16:
 	case R_MIPS_GOT_HI16:
 	case R_MIPS_GOT_LO16:
 	case R_MIPS_GOT_PAGE:
@@ -8002,14 +8039,10 @@ _bfd_mips_elf_check_relocs (bfd *abfd, s
 	case R_MIPS_TLS_GD:
 	case R_MIPS_TLS_LDM:
 	case R_MIPS16_GOT16:
-	case R_MIPS16_CALL16:
 	case R_MIPS16_TLS_GOTTPREL:
 	case R_MIPS16_TLS_GD:
 	case R_MIPS16_TLS_LDM:
 	case R_MICROMIPS_GOT16:
-	case R_MICROMIPS_CALL16:
-	case R_MICROMIPS_CALL_HI16:
-	case R_MICROMIPS_CALL_LO16:
 	case R_MICROMIPS_GOT_HI16:
 	case R_MICROMIPS_GOT_LO16:
 	case R_MICROMIPS_GOT_PAGE:
@@ -8030,12 +8063,27 @@ _bfd_mips_elf_check_relocs (bfd *abfd, s
 	      bfd_set_error (bfd_error_bad_value);
 	      return FALSE;
 	    }
+	  can_make_dynamic_p = TRUE;
 	  break;
 
-	  /* This is just a hint; it can safely be ignored.  Don't set
-	     has_static_relocs for the corresponding symbol.  */
+	case R_MIPS_NONE:
 	case R_MIPS_JALR:
 	case R_MICROMIPS_JALR:
+	  /* These relocations have empty fields and are purely there to
+	     provide link information.  The symbol value doesn't matter.  */
+	  constrain_symbol_p = FALSE;
+	  break;
+
+	case R_MIPS_GPREL16:
+	case R_MIPS_GPREL32:
+	case R_MIPS16_GPREL:
+	case R_MICROMIPS_GPREL16:
+	  /* GP-relative relocations always resolve to a definition in a
+	     regular input file, ignoring the one-definition rule.  This is
+	     important for the GP setup sequence in NewABI code, which
+	     always resolves to a local function even if other relocations
+	     against the symbol wouldn't.  */
+	  constrain_symbol_p = FALSE;
 	  break;
 
 	case R_MIPS_32:
@@ -8062,35 +8110,8 @@ _bfd_mips_elf_check_relocs (bfd *abfd, s
 	      can_make_dynamic_p = TRUE;
 	      if (dynobj == NULL)
 		elf_hash_table (info)->dynobj = dynobj = abfd;
-	      break;
 	    }
-	  /* For sections that are not SEC_ALLOC a copy reloc would be
-	     output if possible (implying questionable semantics for
-	     read-only data objects) or otherwise the final link would
-	     fail as ld.so will not process them and could not therefore
-	     handle any outstanding dynamic relocations.
-
-	     For such sections that are also SEC_DEBUGGING, we can avoid
-	     these problems by simply ignoring any relocs as these
-	     sections have a predefined use and we know it is safe to do
-	     so.
-
-	     This is needed in cases such as a global symbol definition
-	     in a shared library causing a common symbol from an object
-	     file to be converted to an undefined reference.  If that
-	     happens, then all the relocations against this symbol from
-	     SEC_DEBUGGING sections in the object file will resolve to
-	     nil.  */
-	  if ((sec->flags & SEC_DEBUGGING) != 0)
-	    break;
-	  /* Fall through.  */
-
-	default:
-	  /* Most static relocations require pointer equality, except
-	     for branches.  */
-	  if (h)
-	    h->pointer_equality_needed = TRUE;
-	  /* Fall through.  */
+	  break;
 
 	case R_MIPS_26:
 	case R_MIPS_PC16:
@@ -8100,13 +8121,28 @@ _bfd_mips_elf_check_relocs (bfd *abfd, s
 	case R_MICROMIPS_PC10_S1:
 	case R_MICROMIPS_PC16_S1:
 	case R_MICROMIPS_PC23_S2:
-	  if (h)
-	    ((struct mips_elf_link_hash_entry *) h)->has_static_relocs = TRUE;
+	  call_reloc_p = TRUE;
 	  break;
 	}
 
       if (h)
 	{
+	  if (constrain_symbol_p)
+	    {
+	      if (!can_make_dynamic_p)
+		((struct mips_elf_link_hash_entry *) h)->has_static_relocs = 1;
+
+	      if (!call_reloc_p)
+		h->pointer_equality_needed = 1;
+
+	      /* We must not create a stub for a symbol that has
+		 relocations related to taking the function's address.
+		 This doesn't apply to VxWorks, where CALL relocs refer
+		 to a .got.plt entry instead of a normal .got entry.  */
+	      if (!htab->is_vxworks && (!can_make_dynamic_p || !call_reloc_p))
+		((struct mips_elf_link_hash_entry *) h)->no_fn_stub = TRUE;
+	    }
+
 	  /* Relocations against the special VxWorks __GOTT_BASE__ and
 	     __GOTT_INDEX__ symbols must be left to the loader.  Allocate
 	     room for them in .rela.dyn.  */
@@ -8387,28 +8423,6 @@ _bfd_mips_elf_check_relocs (bfd *abfd, s
 	    h->plt.plist->need_comp = TRUE;
 	}
 
-      /* We must not create a stub for a symbol that has relocations
-	 related to taking the function's address.  This doesn't apply to
-	 VxWorks, where CALL relocs refer to a .got.plt entry instead of
-	 a normal .got entry.  */
-      if (!htab->is_vxworks && h != NULL)
-	switch (r_type)
-	  {
-	  default:
-	    ((struct mips_elf_link_hash_entry *) h)->no_fn_stub = TRUE;
-	    break;
-	  case R_MIPS16_CALL16:
-	  case R_MIPS_CALL16:
-	  case R_MIPS_CALL_HI16:
-	  case R_MIPS_CALL_LO16:
-	  case R_MIPS_JALR:
-	  case R_MICROMIPS_CALL16:
-	  case R_MICROMIPS_CALL_HI16:
-	  case R_MICROMIPS_CALL_LO16:
-	  case R_MICROMIPS_JALR:
-	    break;
-	  }
-
       /* See if this reloc would need to refer to a MIPS16 hard-float stub,
 	 if there is one.  We only need to handle global symbols here;
 	 we decide whether to keep or delete stubs for local symbols
Index: ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n32.ad
===================================================================
--- ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n32.ad	2013-10-13 11:00:58.567356191 +0100
+++ ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n32.ad	2013-10-13 11:01:17.624536739 +0100
@@ -16,10 +16,10 @@ Dynamic section at offset .* contains .*
  0x70000001 \(MIPS_RLD_VERSION\) * 1
  0x70000005 \(MIPS_FLAGS\) * NOTPOT
  0x70000006 \(MIPS_BASE_ADDRESS\) * 0x40000
- 0x7000000a \(MIPS_LOCAL_GOTNO\) * 2
+ 0x7000000a \(MIPS_LOCAL_GOTNO\) * 5
  0x70000011 \(MIPS_SYMTABNO\) * 12
  0x70000012 \(MIPS_UNREFEXTNO\) * .*
- 0x70000013 \(MIPS_GOTSYM\) * 0x5
+ 0x70000013 \(MIPS_GOTSYM\) * 0x8
  0x00000014 \(PLTREL\) * REL
  0x00000017 \(JMPREL\) * 0x43028
  0x00000002 \(PLTRELSZ\) * 24 \(bytes\)
Index: ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n32.dd
===================================================================
--- ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n32.dd	2013-10-13 11:00:58.567356191 +0100
+++ ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n32.dd	2013-10-13 11:01:17.624536739 +0100
@@ -2,13 +2,13 @@
 #
 # -32752: lazy resolution function
 # -32748: reserved for module pointer
-# -32744: extf2's GOT entry (undefined 0)
-# -32740: extf3's GOT entry (PLT entry)
-# -32736: extd2's GOT entry (copy reloc)
-# -32732: extf1's GOT entry (.MIPS.stubs entry)
-# -32728: extd1's GOT entry (undefined 0)
-# -32724: extf4's GOT entry (PLT entry)
-# -32620: extd4's GOT entry (undefined 0, reloc only)
+# -32744: extd2's local GOT entry (copy reloc)
+# -32740: extf3's local GOT entry (PLT entry)
+# -32736: extf4's local GOT entry (PLT entry)
+# -32732: extf2's global GOT entry (undefined 0)
+# -32728: extf1's global GOT entry (.MIPS.stubs entry)
+# -32724: extd1's global GOT entry (undefined 0)
+# -32720: extd4's global GOT entry (undefined 0, reloc only)
 
 .*
 
@@ -61,14 +61,14 @@ Disassembly of section \.text:
    44020:	3c1c0006 	lui	gp,0x6
    44024:	0399e021 	addu	gp,gp,t9
    44028:	279c3fd0 	addiu	gp,gp,16336
-   4402c:	8f998024 	lw	t9,-32732\(gp\)
-   44030:	8f848018 	lw	a0,-32744\(gp\)
-   44034:	8f858028 	lw	a1,-32728\(gp\)
+   4402c:	8f998028 	lw	t9,-32728\(gp\)
+   44030:	8f848024 	lw	a0,-32732\(gp\)
+   44034:	8f85802c 	lw	a1,-32724\(gp\)
    44038:	0320f809 	jalr	t9
-   4403c:	8f868020 	lw	a2,-32736\(gp\)
+   4403c:	8f868018 	lw	a2,-32744\(gp\)
    44040:	8f99801c 	lw	t9,-32740\(gp\)
    44044:	03200008 	jr	t9
-   44048:	8f84802c 	lw	a0,-32724\(gp\)
+   44048:	8f848020 	lw	a0,-32736\(gp\)
 
 0004404c <f3>:
    4404c:	03e00008 	jr	ra
@@ -98,5 +98,5 @@ Disassembly of section \.MIPS\.stubs:
    440a0:	8f998010 	lw	t9,-32752\(gp\)
    440a4:	03e07821 	move	t3,ra
    440a8:	0320f809 	jalr	t9
-   440ac:	24180008 	li	t8,8
+   440ac:	24180009 	li	t8,9
 	\.\.\.
Index: ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n32.gd
===================================================================
--- ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n32.gd	2013-10-13 11:00:58.567356191 +0100
+++ ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n32.gd	2013-10-13 11:01:17.624536739 +0100
@@ -7,14 +7,17 @@ Primary GOT:
   000a0000 -32752\(gp\) 00000000 Lazy resolver
   000a0004 -32748\(gp\) 80000000 Module pointer \(GNU extension\)
 
+ Local entries:
+   Address     Access  Initial
+  000a0008 -32744\(gp\) 000a2000
+  000a000c -32740\(gp\) 00043080
+  000a0010 -32736\(gp\) 00043060
+
  Global entries:
    Address     Access  Initial Sym\.Val\. Type    Ndx Name
-  000a0008 -32744\(gp\) 00000000 00000000 FUNC    UND extf2
-  000a000c -32740\(gp\) 00000000 00000000 FUNC    UND extf3
-  000a0010 -32736\(gp\) 000a2000 000a2000 OBJECT   16 extd2
-  000a0014 -32732\(gp\) 000440a0 000440a0 FUNC    UND extf1
-  000a0018 -32728\(gp\) 00000000 00000000 OBJECT  UND extd1
-  000a001c -32724\(gp\) 00000000 00000000 FUNC    UND extf4
+  000a0014 -32732\(gp\) 00000000 00000000 FUNC    UND extf2
+  000a0018 -32728\(gp\) 000440a0 000440a0 FUNC    UND extf1
+  000a001c -32724\(gp\) 00000000 00000000 OBJECT  UND extd1
   000a0020 -32720\(gp\) 00000000 00000000 OBJECT  UND extd4
 
 
@@ -27,6 +30,6 @@ PLT GOT:
 
  Entries:
    Address  Initial Sym.Val. Type    Ndx Name
-  00081008 00043040 00000000 FUNC    UND extf4
+  00081008 00043040 00043060 FUNC    UND extf4
   0008100c 00043040 00000000 FUNC    UND extf5
   00081010 00043040 00000000 FUNC    UND extf3
Index: ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n32.nd
===================================================================
--- ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n32.nd	2013-10-13 11:00:58.567356191 +0100
+++ ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n32.nd	2013-10-13 11:01:17.624536739 +0100
@@ -1,17 +1,40 @@
 
 Symbol table '\.dynsym' contains .*:
+#
+# extf4 is referenced by a JAL and .word.  The former requires a PLT entry
+# and the latter requires pointer equality, which means a symbol value is
+# needed.
 #...
-.*: 00000000 +0 +FUNC +GLOBAL +DEFAULT +UND +extf5
+.*: 0+43060 +0 +FUNC +GLOBAL +DEFAULT \[MIPS PLT\] +UND +extf4
+#
+# extf5 is called but does not have its address taken.  It needs a PLT
+# but no symbol value should be set.
+#...
+.*: 0+ +0 +FUNC +GLOBAL +DEFAULT +UND +extf5
+#
+# extd2 is referenced by %got, .word and %hi/%lo.  The last pair forces
+# a copy reloc.
+#
+.*: 0+a2000 +24 +OBJECT +GLOBAL +DEFAULT +[0-9]+ +extd2
+#
+# extf3 is referenced by a JAL and a GOT CALL reloc.  The JAL forces a PLT
+# that the GOT CALL reloc will also use, but pointer equality isn't needed
+# and so no symbol value should be set.
+#
+.*: 0+ +0 +FUNC +GLOBAL +DEFAULT +UND +extf3
+#
+# extd3 is referenced by .word and %hi/%lo.  The latter pair forces
+# a copy reloc.
+#...
+.*: 0+a2018 +28 +OBJECT +GLOBAL +DEFAULT +[0-9]+ +extd3
+#
 # The index on the next line should correspond to MIPS_GOTSYM,
 # and the remaining symbols should have the same order as the
 # GOT layout given in the *.dd dump.
-#...
- *5: 0+ +0 +FUNC +GLOBAL +DEFAULT +UND +extf2
- *6: 0+ +0 +FUNC +GLOBAL +DEFAULT +UND +extf3
- *7: 0+a2000 +24 +OBJECT +GLOBAL +DEFAULT +[0-9]+ +extd2
- *8: 0+440a0 +0 +FUNC +GLOBAL +DEFAULT +UND +extf1
- *9: 0+ +0 +OBJECT +GLOBAL +DEFAULT +UND +extd1
- *10: 0+ +0 +FUNC +GLOBAL +DEFAULT +UND +extf4
+#
+ *8: 0+ +0 +FUNC +GLOBAL +DEFAULT +UND +extf2
+ *9: 0+440a0 +0 +FUNC +GLOBAL +DEFAULT +UND +extf1
+ *10: 0+ +0 +OBJECT +GLOBAL +DEFAULT +UND +extd1
  *11: 0+ +0 +OBJECT +GLOBAL +DEFAULT +UND +extd4
 
 #pass
Index: ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n32.rd
===================================================================
--- ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n32.rd	2013-10-13 11:00:58.567356191 +0100
+++ ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n32.rd	2013-10-13 11:01:17.624536739 +0100
@@ -2,13 +2,13 @@
 Relocation section '\.rel\.dyn' at offset .* contains .*:
  * Offset * Info * Type * Sym\.Value * Sym\. Name
 00000000 * 00000000 * R_MIPS_NONE *
-000a2018 * [^ ]*7e * R_MIPS_COPY * 000a2018 * extd3
 000a2000 * [^ ]*7e * R_MIPS_COPY * 000a2000 * extd2
+000a2018 * [^ ]*7e * R_MIPS_COPY * 000a2018 * extd3
 000a1000 * [^ ]*03 * R_MIPS_REL32 * 00000000 * extd1
 000a1014 * [^ ]*03 * R_MIPS_REL32 * 00000000 * extd4
 
 Relocation section '\.rel\.plt' at offset .* contains .*:
  * Offset * Info * Type * Sym\.Value * Sym\. Name
-00081008 * [^ ]*7f * R_MIPS_JUMP_SLOT * 00000000 * extf4
+00081008 * [^ ]*7f * R_MIPS_JUMP_SLOT * 00043060 * extf4
 0008100c * [^ ]*7f * R_MIPS_JUMP_SLOT * 00000000 * extf5
 00081010 * [^ ]*7f * R_MIPS_JUMP_SLOT * 00000000 * extf3
Index: ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n64.ad
===================================================================
--- ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n64.ad	2013-10-13 11:00:58.567356191 +0100
+++ ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n64.ad	2013-10-13 11:01:17.624536739 +0100
@@ -16,10 +16,10 @@ Dynamic section at offset .* contains .*
  0x0+70000001 \(MIPS_RLD_VERSION\) * 1
  0x0+70000005 \(MIPS_FLAGS\) * NOTPOT
  0x0+70000006 \(MIPS_BASE_ADDRESS\) * 0x40000
- 0x0+7000000a \(MIPS_LOCAL_GOTNO\) * 2
+ 0x0+7000000a \(MIPS_LOCAL_GOTNO\) * 5
  0x0+70000011 \(MIPS_SYMTABNO\) * 12
  0x0+70000012 \(MIPS_UNREFEXTNO\) * .*
- 0x0+70000013 \(MIPS_GOTSYM\) * 0x5
+ 0x0+70000013 \(MIPS_GOTSYM\) * 0x8
  0x0+00000014 \(PLTREL\) * REL
  0x0+00000017 \(JMPREL\) * 0x43050
  0x0+00000002 \(PLTRELSZ\) * 48 \(bytes\)
Index: ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n64.dd
===================================================================
--- ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n64.dd	2013-10-13 11:00:58.567356191 +0100
+++ ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n64.dd	2013-10-13 11:01:17.625536748 +0100
@@ -1,14 +1,14 @@
 # GOT layout:
 #
 # -32752: lazy resolution function
-# -32744: reserved for module pointer
-# -32736: extf2's GOT entry (undefined 0)
-# -32728: extf3's GOT entry (PLT entry)
-# -32720: extd2's GOT entry (copy reloc)
-# -32712: extf1's GOT entry (.MIPS.stubs entry)
-# -32704: extd1's GOT entry (undefined 0)
-# -32696: extf4's GOT entry (PLT entry)
-# -32688: extd4's GOT entry (undefined 0, reloc only)
+# -32748: reserved for module pointer
+# -32744: extd2's local GOT entry (copy reloc)
+# -32740: extf3's local GOT entry (PLT entry)
+# -32736: extf4's local GOT entry (PLT entry)
+# -32732: extf2's global GOT entry (undefined 0)
+# -32728: extf1's global GOT entry (.MIPS.stubs entry)
+# -32724: extd1's global GOT entry (undefined 0)
+# -32720: extd4's global GOT entry (undefined 0, reloc only)
 
 .*
 
@@ -61,14 +61,14 @@ Disassembly of section \.text:
    44020:	3c1c0006 	lui	gp,0x6
    44024:	0399e021 	addu	gp,gp,t9
    44028:	279c3fd0 	addiu	gp,gp,16336
-   4402c:	df998038 	ld	t9,-32712\(gp\)
-   44030:	df848020 	ld	a0,-32736\(gp\)
-   44034:	df858040 	ld	a1,-32704\(gp\)
+   4402c:	df998040 	ld	t9,-32704\(gp\)
+   44030:	df848038 	ld	a0,-32712\(gp\)
+   44034:	df858048 	ld	a1,-32696\(gp\)
    44038:	0320f809 	jalr	t9
-   4403c:	df868030 	ld	a2,-32720\(gp\)
+   4403c:	df868020 	ld	a2,-32736\(gp\)
    44040:	df998028 	ld	t9,-32728\(gp\)
    44044:	03200008 	jr	t9
-   44048:	df848048 	ld	a0,-32696\(gp\)
+   44048:	df848030 	ld	a0,-32720\(gp\)
 
 0+4404c <f3>:
    4404c:	03e00008 	jr	ra
@@ -98,5 +98,5 @@ Disassembly of section \.MIPS\.stubs:
    440a0:	df998010 	ld	t9,-32752\(gp\)
    440a4:	03e0782d 	move	t3,ra
    440a8:	0320f809 	jalr	t9
-   440ac:	64180008 	daddiu	t8,zero,8
+   440ac:	64180009 	daddiu	t8,zero,9
 	\.\.\.
Index: ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n64.gd
===================================================================
--- ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n64.gd	2013-10-13 11:00:58.567356191 +0100
+++ ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n64.gd	2013-10-13 11:01:17.625536748 +0100
@@ -1,32 +1,35 @@
 
 Primary GOT:
- Canonical gp value: 00000000000a7ff0
+ Canonical gp value: 0+0a7ff0
 
  Reserved entries:
-           Address     Access          Initial Purpose
-  00000000000a0000 -32752\(gp\) 0000000000000000 Lazy resolver
-  00000000000a0008 -32744\(gp\) 8000000000000000 Module pointer \(GNU extension\)
+ * Address * Access * Initial Purpose
+  0+0a0000 -32752\(gp\) 0+ Lazy resolver
+  0+0a0008 -32744\(gp\) 8000000000000000 Module pointer \(GNU extension\)
+
+ Local entries:
+ * Address * Access * Initial
+  0+0a0010 -32736\(gp\) 0+0a2000
+  0+0a0018 -32728\(gp\) 0+0430c0
+  0+0a0020 -32720\(gp\) 0+0430a0
 
  Global entries:
-           Address     Access          Initial         Sym\.Val\. Type    Ndx Name
-  00000000000a0010 -32736\(gp\) 0000000000000000 0000000000000000 FUNC    UND extf2
-  00000000000a0018 -32728\(gp\) 0000000000000000 0000000000000000 FUNC    UND extf3
-  00000000000a0020 -32720\(gp\) 00000000000a2000 00000000000a2000 OBJECT   16 extd2
-  00000000000a0028 -32712\(gp\) 00000000000440a0 00000000000440a0 FUNC    UND extf1
-  00000000000a0030 -32704\(gp\) 0000000000000000 0000000000000000 OBJECT  UND extd1
-  00000000000a0038 -32696\(gp\) 0000000000000000 0000000000000000 FUNC    UND extf4
-  00000000000a0040 -32688\(gp\) 0000000000000000 0000000000000000 OBJECT  UND extd4
+ * Address * Access * Initial * Sym\.Val\. * Type * Ndx Name
+  0+0a0028 -32712\(gp\) 0+000000 0+000000 FUNC    UND extf2
+  0+0a0030 -32704\(gp\) 0+0440a0 0+0440a0 FUNC    UND extf1
+  0+0a0038 -32696\(gp\) 0+000000 0+000000 OBJECT  UND extd1
+  0+0a0040 -32688\(gp\) 0+000000 0+000000 OBJECT  UND extd4
 
 
 PLT GOT:
 
  Reserved entries:
-           Address          Initial Purpose
-  0000000000081000 0000000000000000 PLT lazy resolver
-  0000000000081008 0000000000000000 Module pointer
+ * Address * Initial * Purpose
+  0+081000 0+ PLT lazy resolver
+  0+081008 0+ Module pointer
 
  Entries:
-           Address          Initial         Sym.Val. Type    Ndx Name
-  0000000000081010 0000000000043080 0000000000000000 FUNC    UND extf4
-  0000000000081018 0000000000043080 0000000000000000 FUNC    UND extf5
-  0000000000081020 0000000000043080 0000000000000000 FUNC    UND extf3
+ * Address * Initial * Sym.Val. * Type * Ndx Name
+  0+081010 0+043080 0+0430a0 FUNC    UND extf4
+  0+081018 0+043080 0+000000 FUNC    UND extf5
+  0+081020 0+043080 0+000000 FUNC    UND extf3
Index: ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n64.nd
===================================================================
--- ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n64.nd	2013-10-13 11:00:58.567356191 +0100
+++ ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n64.nd	2013-10-13 11:01:17.625536748 +0100
@@ -1,17 +1,40 @@
 
 Symbol table '\.dynsym' contains .*:
+#
+# extf4 is referenced by a JAL and .word.  The former requires a PLT entry
+# and the latter requires pointer equality, which means a symbol value is
+# needed.
+#...
+.*: 0+430a0 +0 +FUNC +GLOBAL +DEFAULT \[MIPS PLT\] +UND +extf4
+#
+# extf5 is called but does not have its address taken.  It needs a PLT
+# but no symbol value should be set.
 #...
 .*: 0+ +0 +FUNC +GLOBAL +DEFAULT +UND +extf5
+#
+# extd2 is referenced by %got, .word and %hi/%lo.  The last pair forces
+# a copy reloc.
+#
+.*: 0+a2000 +24 +OBJECT +GLOBAL +DEFAULT +[0-9]+ +extd2
+#
+# extf3 is referenced by a JAL and a GOT CALL reloc.  The JAL forces a PLT
+# that the GOT CALL reloc will also use, but pointer equality isn't needed
+# and so no symbol value should be set.
+#
+.*: 0+ +0 +FUNC +GLOBAL +DEFAULT +UND +extf3
+#
+# extd3 is referenced by .word and %hi/%lo.  The latter pair forces
+# a copy reloc.
+#...
+.*: 0+a2018 +28 +OBJECT +GLOBAL +DEFAULT +[0-9]+ +extd3
+#
 # The index on the next line should correspond to MIPS_GOTSYM,
 # and the remaining symbols should have the same order as the
 # GOT layout given in the *.dd dump.
-#...
- *5: 0+ +0 +FUNC +GLOBAL +DEFAULT +UND +extf2
- *6: 0+ +0 +FUNC +GLOBAL +DEFAULT +UND +extf3
- *7: 0+a2000 +24 +OBJECT +GLOBAL +DEFAULT +[0-9]+ +extd2
- *8: 0+440a0 +0 +FUNC +GLOBAL +DEFAULT +UND +extf1
- *9: 0+ +0 +OBJECT +GLOBAL +DEFAULT +UND +extd1
- *10: 0+ +0 +FUNC +GLOBAL +DEFAULT +UND +extf4
+#
+ *8: 0+ +0 +FUNC +GLOBAL +DEFAULT +UND +extf2
+ *9: 0+440a0 +0 +FUNC +GLOBAL +DEFAULT +UND +extf1
+ *10: 0+ +0 +OBJECT +GLOBAL +DEFAULT +UND +extd1
  *11: 0+ +0 +OBJECT +GLOBAL +DEFAULT +UND +extd4
 
 #pass
Index: ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n64.rd
===================================================================
--- ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n64.rd	2013-10-13 11:00:58.567356191 +0100
+++ ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n64.rd	2013-10-13 11:01:17.625536748 +0100
@@ -4,10 +4,10 @@ Relocation section '\.rel\.dyn' at offse
 0+00000 * 0+ * R_MIPS_NONE *
  *Type2: R_MIPS_NONE *
  *Type3: R_MIPS_NONE *
-0+a2018 * [^ ]*7e * R_MIPS_COPY * 0+a2018 * extd3
+0+a2000 * [^ ]*7e * R_MIPS_COPY * 0+a2000 * extd2
  *Type2: R_MIPS_NONE *
  *Type3: R_MIPS_NONE *
-0+a2000 * [^ ]*7e * R_MIPS_COPY * 0+a2000 * extd2
+0+a2018 * [^ ]*7e * R_MIPS_COPY * 0+a2018 * extd3
  *Type2: R_MIPS_NONE *
  *Type3: R_MIPS_NONE *
 0+a1000 * [^ ]*03 * R_MIPS_REL32 * 0+00000 * extd1
@@ -19,7 +19,7 @@ Relocation section '\.rel\.dyn' at offse
 
 Relocation section '\.rel\.plt' at offset .* contains .*:
  * Offset * Info * Type * Sym\. Value * Sym\. Name
-0+81010 * [^ ]*7f * R_MIPS_JUMP_SLOT * 0+00000 * extf4
+0+81010 * [^ ]*7f * R_MIPS_JUMP_SLOT * 0+430a0 * extf4
  *Type2: R_MIPS_NONE *
  *Type3: R_MIPS_NONE *
 0+81018 * [^ ]*7f * R_MIPS_JUMP_SLOT * 0+00000 * extf5
Index: ld/testsuite/ld-mips-elf/pic-and-nonpic-6-o32.ad
===================================================================
--- ld/testsuite/ld-mips-elf/pic-and-nonpic-6-o32.ad	2013-10-13 11:00:58.567356191 +0100
+++ ld/testsuite/ld-mips-elf/pic-and-nonpic-6-o32.ad	2013-10-13 11:01:17.625536748 +0100
@@ -16,10 +16,10 @@ Dynamic section at offset .* contains .*
  0x70000001 \(MIPS_RLD_VERSION\) * 1
  0x70000005 \(MIPS_FLAGS\) * NOTPOT
  0x70000006 \(MIPS_BASE_ADDRESS\) * 0x40000
- 0x7000000a \(MIPS_LOCAL_GOTNO\) * 2
+ 0x7000000a \(MIPS_LOCAL_GOTNO\) * 5
  0x70000011 \(MIPS_SYMTABNO\) * 12
  0x70000012 \(MIPS_UNREFEXTNO\) * .*
- 0x70000013 \(MIPS_GOTSYM\) * 0x5
+ 0x70000013 \(MIPS_GOTSYM\) * 0x8
  0x00000014 \(PLTREL\) * REL
  0x00000017 \(JMPREL\) * 0x43028
  0x00000002 \(PLTRELSZ\) * 24 \(bytes\)
Index: ld/testsuite/ld-mips-elf/pic-and-nonpic-6-o32.dd
===================================================================
--- ld/testsuite/ld-mips-elf/pic-and-nonpic-6-o32.dd	2013-10-13 11:00:58.567356191 +0100
+++ ld/testsuite/ld-mips-elf/pic-and-nonpic-6-o32.dd	2013-10-13 11:01:17.625536748 +0100
@@ -2,13 +2,13 @@
 #
 # -32752: lazy resolution function
 # -32748: reserved for module pointer
-# -32744: extf2's GOT entry (undefined 0)
-# -32740: extf3's GOT entry (PLT entry)
-# -32736: extd2's GOT entry (copy reloc)
-# -32732: extf1's GOT entry (.MIPS.stubs entry)
-# -32728: extd1's GOT entry (undefined 0)
-# -32724: extf4's GOT entry (PLT entry)
-# -32620: extd4's GOT entry (undefined 0, reloc only)
+# -32744: extd2's local GOT entry (copy reloc)
+# -32740: extf3's local GOT entry (PLT entry)
+# -32736: extf4's local GOT entry (PLT entry)
+# -32732: extf2's global GOT entry (undefined 0)
+# -32728: extf1's global GOT entry (.MIPS.stubs entry)
+# -32724: extd1's global GOT entry (undefined 0)
+# -32720: extd4's global GOT entry (undefined 0, reloc only)
 
 .*
 
@@ -61,14 +61,14 @@ Disassembly of section \.text:
    44020:	3c1c0006 	lui	gp,0x6
    44024:	279c3fd0 	addiu	gp,gp,16336
    44028:	0399e021 	addu	gp,gp,t9
-   4402c:	8f998024 	lw	t9,-32732\(gp\)
-   44030:	8f848018 	lw	a0,-32744\(gp\)
-   44034:	8f858028 	lw	a1,-32728\(gp\)
+   4402c:	8f998028 	lw	t9,-32728\(gp\)
+   44030:	8f848024 	lw	a0,-32732\(gp\)
+   44034:	8f85802c 	lw	a1,-32724\(gp\)
    44038:	0320f809 	jalr	t9
-   4403c:	8f868020 	lw	a2,-32736\(gp\)
+   4403c:	8f868018 	lw	a2,-32744\(gp\)
    44040:	8f99801c 	lw	t9,-32740\(gp\)
    44044:	03200008 	jr	t9
-   44048:	8f84802c 	lw	a0,-32724\(gp\)
+   44048:	8f848020 	lw	a0,-32736\(gp\)
 
 0004404c <f3>:
    4404c:	03e00008 	jr	ra
@@ -98,5 +98,5 @@ Disassembly of section \.MIPS\.stubs:
    440a0:	8f998010 	lw	t9,-32752\(gp\)
    440a4:	03e07821 	move	t7,ra
    440a8:	0320f809 	jalr	t9
-   440ac:	24180008 	li	t8,8
+   440ac:	24180009 	li	t8,9
 	\.\.\.
Index: ld/testsuite/ld-mips-elf/pic-and-nonpic-6-o32.gd
===================================================================
--- ld/testsuite/ld-mips-elf/pic-and-nonpic-6-o32.gd	2013-10-13 11:00:58.567356191 +0100
+++ ld/testsuite/ld-mips-elf/pic-and-nonpic-6-o32.gd	2013-10-13 11:01:17.626536758 +0100
@@ -7,14 +7,17 @@ Primary GOT:
   000a0000 -32752\(gp\) 00000000 Lazy resolver
   000a0004 -32748\(gp\) 80000000 Module pointer \(GNU extension\)
 
+ Local entries:
+   Address     Access  Initial
+  000a0008 -32744\(gp\) 000a2000
+  000a000c -32740\(gp\) 00043080
+  000a0010 -32736\(gp\) 00043060
+
  Global entries:
    Address     Access  Initial Sym\.Val\. Type    Ndx Name
-  000a0008 -32744\(gp\) 00000000 00000000 FUNC    UND extf2
-  000a000c -32740\(gp\) 00000000 00000000 FUNC    UND extf3
-  000a0010 -32736\(gp\) 000a2000 000a2000 OBJECT   16 extd2
-  000a0014 -32732\(gp\) 000440a0 000440a0 FUNC    UND extf1
-  000a0018 -32728\(gp\) 00000000 00000000 OBJECT  UND extd1
-  000a001c -32724\(gp\) 00000000 00000000 FUNC    UND extf4
+  000a0014 -32732\(gp\) 00000000 00000000 FUNC    UND extf2
+  000a0018 -32728\(gp\) 000440a0 000440a0 FUNC    UND extf1
+  000a001c -32724\(gp\) 00000000 00000000 OBJECT  UND extd1
   000a0020 -32720\(gp\) 00000000 00000000 OBJECT  UND extd4
 
 
@@ -27,6 +30,6 @@ PLT GOT:
 
  Entries:
    Address  Initial Sym.Val. Type    Ndx Name
-  00081008 00043040 00000000 FUNC    UND extf4
+  00081008 00043040 00043060 FUNC    UND extf4
   0008100c 00043040 00000000 FUNC    UND extf5
   00081010 00043040 00000000 FUNC    UND extf3
Index: ld/testsuite/ld-mips-elf/pic-and-nonpic-6-o32.nd
===================================================================
--- ld/testsuite/ld-mips-elf/pic-and-nonpic-6-o32.nd	2013-10-13 11:00:58.567356191 +0100
+++ ld/testsuite/ld-mips-elf/pic-and-nonpic-6-o32.nd	2013-10-13 11:01:17.626536758 +0100
@@ -1,17 +1,40 @@
 
 Symbol table '\.dynsym' contains .*:
+#
+# extf4 is referenced by a JAL and .word.  The former requires a PLT entry
+# and the latter requires pointer equality, which means a symbol value is
+# needed.
 #...
-.*: 00000000 +0 +FUNC +GLOBAL +DEFAULT +UND +extf5
+.*: 0+43060 +0 +FUNC +GLOBAL +DEFAULT \[MIPS PLT\] +UND +extf4
+#
+# extf5 is called but does not have its address taken.  It needs a PLT
+# but no symbol value should be set.
+#...
+.*: 0+ +0 +FUNC +GLOBAL +DEFAULT +UND +extf5
+#
+# extd2 is referenced by %got, .word and %hi/%lo.  The last pair forces
+# a copy reloc.
+#
+.*: 0+a2000 +24 +OBJECT +GLOBAL +DEFAULT +[0-9]+ +extd2
+#
+# extf3 is referenced by a JAL and a GOT CALL reloc.  The JAL forces a PLT
+# that the GOT CALL reloc will also use, but pointer equality isn't needed
+# and so no symbol value should be set.
+#
+.*: 0+ +0 +FUNC +GLOBAL +DEFAULT +UND +extf3
+#
+# extd3 is referenced by .word and %hi/%lo.  The latter pair forces
+# a copy reloc.
+#...
+.*: 0+a2018 +28 +OBJECT +GLOBAL +DEFAULT +[0-9]+ +extd3
+#
 # The index on the next line should correspond to MIPS_GOTSYM,
 # and the remaining symbols should have the same order as the
 # GOT layout given in the *.dd dump.
-#...
- *5: 0+ +0 +FUNC +GLOBAL +DEFAULT +UND +extf2
- *6: 0+ +0 +FUNC +GLOBAL +DEFAULT +UND +extf3
- *7: 0+a2000 +24 +OBJECT +GLOBAL +DEFAULT +[0-9]+ +extd2
- *8: 0+440a0 +0 +FUNC +GLOBAL +DEFAULT +UND +extf1
- *9: 0+ +0 +OBJECT +GLOBAL +DEFAULT +UND +extd1
- *10: 0+ +0 +FUNC +GLOBAL +DEFAULT +UND +extf4
+#
+ *8: 0+ +0 +FUNC +GLOBAL +DEFAULT +UND +extf2
+ *9: 0+440a0 +0 +FUNC +GLOBAL +DEFAULT +UND +extf1
+ *10: 0+ +0 +OBJECT +GLOBAL +DEFAULT +UND +extd1
  *11: 0+ +0 +OBJECT +GLOBAL +DEFAULT +UND +extd4
 
 #pass
Index: ld/testsuite/ld-mips-elf/pic-and-nonpic-6-o32.rd
===================================================================
--- ld/testsuite/ld-mips-elf/pic-and-nonpic-6-o32.rd	2013-10-13 11:00:58.567356191 +0100
+++ ld/testsuite/ld-mips-elf/pic-and-nonpic-6-o32.rd	2013-10-13 11:01:17.626536758 +0100
@@ -2,13 +2,13 @@
 Relocation section '\.rel\.dyn' at offset .* contains .*:
  * Offset * Info * Type * Sym\.Value * Sym\. Name
 00000000 * 00000000 * R_MIPS_NONE *
-000a2018 * [^ ]*7e * R_MIPS_COPY * 000a2018 * extd3
 000a2000 * [^ ]*7e * R_MIPS_COPY * 000a2000 * extd2
+000a2018 * [^ ]*7e * R_MIPS_COPY * 000a2018 * extd3
 000a1000 * [^ ]*03 * R_MIPS_REL32 * 00000000 * extd1
 000a1014 * [^ ]*03 * R_MIPS_REL32 * 00000000 * extd4
 
 Relocation section '\.rel\.plt' at offset .* contains .*:
  * Offset * Info * Type * Sym\.Value * Sym\. Name
-00081008 * [^ ]*7f * R_MIPS_JUMP_SLOT * 00000000 * extf4
+00081008 * [^ ]*7f * R_MIPS_JUMP_SLOT * 00043060 * extf4
 0008100c * [^ ]*7f * R_MIPS_JUMP_SLOT * 00000000 * extf5
 00081010 * [^ ]*7f * R_MIPS_JUMP_SLOT * 00000000 * extf3


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]