public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/3] MIPS/BFD: Correct protected symbol relocation processing
@ 2012-08-08 22:49 Maciej W. Rozycki
  2012-08-08 22:50 ` [PATCH 2/3] MIPS/BFD: Correct IRIX 6 DT_MIPS_OPTIONS processing Maciej W. Rozycki
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Maciej W. Rozycki @ 2012-08-08 22:49 UTC (permalink / raw)
  To: binutils; +Cc: Richard Sandiford

Hello,

 The change below fixes a problem where an R_MIPS_CALL16 relocation 
against a protected symbol makes BFD treat the symbol as a global 
(preemptible) one.  This cannot succeed as protected symbols are local 
(non-preemptible) and therefore assigned to the local part of the GOT (as 
long as they are not referred to for a purpose other than making a call; 
strictly speaking this is a divergence from how export classess have been 
originally specified[1] for the MIPS target by SGI).

 Such relocations are produced by GCC when compiling to PIC code where 
calls are made to functions that have not been declared with the 
"protected" visibility attribute (of course handcoded assembly code may 
have them as well).  The problem triggers when the references 
(relocations) are satisfied with a symbol whose export class (visibility) 
has been set to "protected", but not either of "hidden" or "internal".

 An assertion has been placed in code to ensure that references to global 
symbols end up in the global part of the GOT and as a result of the 
mistreatment described the assertion fails:

mips-linux-gnu-ld: BFD (...) 2.23.51.20120807 assertion fail .../bfd/elfxx-mips.c:3321

-- that's:

  BFD_ASSERT (got_index < htab->sgot->size);

in mips_elf_global_got_index.

 The change adjusts the treatment of protected symbols in relocation 
processing to match code that assigns them to the local part of the GOT.  
The difference between SYMBOL_REFERENCES_LOCAL and SYMBOL_CALLS_LOCAL is 
the former treats protected symbols as global and the latter treats them 
as local.  The got_only_for_calls condition has been set to treat 
protected symbols as global or local as appropriate (depending on whether 
they are only used for making a call or not; as noted above).

 The change causes no regressions in binutils testsuites on the 23 MIPS 
targets I've been using for testing recently.  There have been no 
regressions in the glibc test suite on Linux targets either (o32 and n64 
tested).

 OK to apply?

 I have prepared specific test cases to cover this problem and will be 
sending them separately.  Additionally the test cases triggered a 
segmentation fault in LD with the mips-sgi-irix6 target that I have fixed 
with the second patch of this series.

2012-08-08  Maciej W. Rozycki  <macro@codesourcery.com>

	bfd/
	* elfxx-mips.c (mips_elf_calculate_relocation): Fix the handling 
	of protected symbols.

  Maciej

[1] "64-bit ELF Object File Specification Draft Version 2.5", SGI doc 
    #007-4658-001

binutils-bfd-mips-protected-call16.diff
Index: binutils-fsf-trunk-quilt/bfd/elfxx-mips.c
===================================================================
--- binutils-fsf-trunk-quilt.orig/bfd/elfxx-mips.c	2012-08-08 02:12:20.120577868 +0100
+++ binutils-fsf-trunk-quilt/bfd/elfxx-mips.c	2012-08-08 14:03:37.480542340 +0100
@@ -5343,7 +5343,10 @@ mips_elf_calculate_relocation (bfd *abfd
 				&& (target_is_16_bit_code_p
 				    || target_is_micromips_code_p))));
 
-  local_p = h == NULL || SYMBOL_REFERENCES_LOCAL (info, &h->root);
+  local_p = (h == NULL
+	     || (h->got_only_for_calls
+		 ? SYMBOL_CALLS_LOCAL (info, &h->root)
+		 : SYMBOL_REFERENCES_LOCAL (info, &h->root)));
 
   gp0 = _bfd_get_gp_value (input_bfd);
   gp = _bfd_get_gp_value (abfd);

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 2/3] MIPS/BFD: Correct IRIX 6 DT_MIPS_OPTIONS processing
  2012-08-08 22:49 [PATCH 1/3] MIPS/BFD: Correct protected symbol relocation processing Maciej W. Rozycki
@ 2012-08-08 22:50 ` Maciej W. Rozycki
  2012-08-12 18:50   ` Richard Sandiford
  2012-08-09  1:28 ` [PATCH 3/3] MIPS/LD/test: Protected symbol relocation processing Maciej W. Rozycki
  2012-08-12 18:43 ` [PATCH 1/3] MIPS/BFD: Correct protected " Richard Sandiford
  2 siblings, 1 reply; 11+ messages in thread
From: Maciej W. Rozycki @ 2012-08-08 22:50 UTC (permalink / raw)
  To: binutils; +Cc: Richard Sandiford

Hello,

 The change below fixes a segmentation fault in LD triggered when the 
.MIPS.options n64 ABI special section is forcefully removed by a /DISCARD/ 
clause in the linker script used.  In this case a DT_MIPS_OPTIONS dynamic 
tag is nevertheless created and when later on in 
_bfd_mips_elf_finish_dynamic_sections LD tries to retrieve the section's 
address to use as the value of the tag it crashes on a NULL pointer 
dereference.

 For reasons beyond my knowledge the tag is only used for IRIX 6 targets 
and never for Linux, although the special .MIPS.options section is always 
produced; `readelf' is only capable of decoding the contents of the 
section if the dynamic tag has also been created.

 The fix causes the creation of a DT_MIPS_OPTIONS dynamic 
section/segment's entry to be omitted if no output section has been made 
for .MIPS.options, making the crash go away.  The fix is covered by the 
test cases used to verify processing of R_MIPS_CALL16 relocations that end 
up satified by a symbol of the protected export class.  The test cases are 
provided separately.

 No regressions for the other 22 MIPS targets, OK to apply?

2012-08-08  Maciej W. Rozycki  <macro@codesourcery.com>

	bfd/
	* elfxx-mips.c (_bfd_mips_elf_size_dynamic_sections): Only add a 
	DT_MIPS_OPTIONS tag if output options section has been created.

  Maciej

binutils-bfd-mips-irix-options.diff
Index: binutils-fsf-trunk-quilt/bfd/elfxx-mips.c
===================================================================
--- binutils-fsf-trunk-quilt.orig/bfd/elfxx-mips.c	2012-07-26 03:29:00.000000000 +0100
+++ binutils-fsf-trunk-quilt/bfd/elfxx-mips.c	2012-07-26 04:45:31.560520511 +0100
@@ -9268,11 +9268,17 @@ _bfd_mips_elf_size_dynamic_sections (bfd
 	      && ! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_HIPAGENO, 0))
 	    return FALSE;
 
-	  if (IRIX_COMPAT (dynobj) == ict_irix6
-	      && (bfd_get_section_by_name
-		  (dynobj, MIPS_ELF_OPTIONS_SECTION_NAME (dynobj)))
-	      && !MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_OPTIONS, 0))
-	    return FALSE;
+	  if (IRIX_COMPAT (dynobj) == ict_irix6)
+	    {
+	      const char *const name = MIPS_ELF_OPTIONS_SECTION_NAME (dynobj);
+	      asection *opt_sec;
+
+	      opt_sec = bfd_get_section_by_name (dynobj, name);
+	      if (opt_sec != NULL
+		  && opt_sec->output_section != bfd_abs_section_ptr
+		  && !MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_OPTIONS, 0))
+		return FALSE;
+	    }
 	}
       if (htab->splt->size > 0)
 	{

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 3/3] MIPS/LD/test: Protected symbol relocation processing
  2012-08-08 22:49 [PATCH 1/3] MIPS/BFD: Correct protected symbol relocation processing Maciej W. Rozycki
  2012-08-08 22:50 ` [PATCH 2/3] MIPS/BFD: Correct IRIX 6 DT_MIPS_OPTIONS processing Maciej W. Rozycki
@ 2012-08-09  1:28 ` Maciej W. Rozycki
  2012-08-12 18:51   ` Richard Sandiford
  2012-08-12 18:43 ` [PATCH 1/3] MIPS/BFD: Correct protected " Richard Sandiford
  2 siblings, 1 reply; 11+ messages in thread
From: Maciej W. Rozycki @ 2012-08-09  1:28 UTC (permalink / raw)
  To: binutils; +Cc: Richard Sandiford

Hi,

 This set of test cases complements the protected symbol relocation 
processing and IRIX DT_MIPS_OPTIONS processing fixes previously posted.  
No failures with the usual set of 23 MIPS targets.  OK to apply?

2012-08-08  Maciej W. Rozycki  <macro@codesourcery.com>

	ld/testsuite/
	* ld-mips-elf/export-class-call16-o32.dd: New test.
	* ld-mips-elf/export-class-call16-o32-irix.dd: New test.
	* ld-mips-elf/export-class-call16-o32.gd: New test.
	* ld-mips-elf/export-class-call16-n32.dd: New test.
	* ld-mips-elf/export-class-call16-n32.gd: New test.
	* ld-mips-elf/export-class-call16-n64.dd: New test.
	* ld-mips-elf/export-class-call16-n64.gd: New test.
	* ld-mips-elf/export-class-call16-def.s: New test source.
	* ld-mips-elf/export-class-call16-o32.s: New test source.
	* ld-mips-elf/export-class-call16-n32.s: New test source.
	* ld-mips-elf/export-class-call16-n64.s: New test source.
	* ld-mips-elf/export-class-call16.ld: New test linker script.
	* ld-mips-elf/mips-elf.exp: Run the new tests.

  Maciej

binutils-bfd-mips-protected-call16-test.diff
Index: binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/export-class-call16-def.s
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/export-class-call16-def.s	2012-08-08 22:25:08.671785439 +0100
@@ -0,0 +1,22 @@
+	.text
+	.balign		16
+	.xdef		protected_foo
+	.protected	protected_foo
+	.ent		protected_foo
+protected_foo:
+	jr		$31
+	.end		protected_foo
+	.balign		16
+	.xdef		hidden_foo
+	.hidden		hidden_foo
+	.ent		hidden_foo
+hidden_foo:
+	jr		$31
+	.end		hidden_foo
+	.balign		16
+	.xdef		internal_foo
+	.internal	internal_foo
+	.ent		internal_foo
+internal_foo:
+	jr		$31
+	.end		internal_foo
Index: binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/export-class-call16.ld
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/export-class-call16.ld	2012-08-08 22:25:08.671785439 +0100
@@ -0,0 +1,16 @@
+ENTRY (foo);
+SECTIONS
+{
+  .text : { *(.text) }
+  HIDDEN (_gp = ALIGN(16) + 0x7ff0);
+  .got : { *(.got) }
+  .dynamic : { *(.dynamic) }
+  .hash : { *(.hash) }
+  .dynsym : { *(.dynsym) }
+  .dynstr : { *(.dynstr) }
+  .pdr : { *(.pdr) }
+  .shstrtab : { *(.shstrtab) }
+  .symtab : { *(.symtab) }
+  .strtab : { *(.strtab) }
+  /DISCARD/ : { *(*) }
+}
Index: binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/export-class-call16-n32.s
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/export-class-call16-n32.s	2012-08-08 22:25:08.671785439 +0100
@@ -0,0 +1,20 @@
+	.text
+	.balign		16
+	.xdef		foo
+	.ent		foo
+foo:
+	.frame		$29, 16, $31
+	.mask		0x90000000, -8
+	addiu		$29, -16
+	sd		$31, 8($29)
+	.cpsetup	$25, 0, foo
+	jal		protected_foo
+	jal		hidden_foo
+	jal		internal_foo
+	.cpreturn
+	ld		$31, 8($29)
+	addiu		$29, 16
+	jr		$31
+	.end		foo
+	.balign		4
+	.space		8
Index: binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/export-class-call16-n64.s
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/export-class-call16-n64.s	2012-08-08 22:25:08.671785439 +0100
@@ -0,0 +1,20 @@
+	.text
+	.balign		16
+	.xdef		foo
+	.ent		foo
+foo:
+	.frame		$29, 16, $31
+	.mask		0x90000000, -8
+	daddiu		$29, -16
+	sd		$31, 8($29)
+	.cpsetup	$25, 0, foo
+	jal		protected_foo
+	jal		hidden_foo
+	jal		internal_foo
+	.cpreturn
+	ld		$31, 8($29)
+	daddiu		$29, 16
+	jr		$31
+	.end		foo
+	.balign		4
+	.space		8
Index: binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/export-class-call16-o32.s
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/export-class-call16-o32.s	2012-08-08 22:25:08.671785439 +0100
@@ -0,0 +1,22 @@
+	.text
+	.balign		16
+	.xdef		foo
+	.ent		foo
+foo:
+	.frame		$29, 8, $31
+	.mask		0x80000000, -4
+	.set		noreorder
+	.cpload		$25
+	.set		reorder
+	addiu		$29, -8
+	sw		$31, 4($29)
+	.cprestore	0
+	jal		protected_foo
+	jal		hidden_foo
+	jal		internal_foo
+	lw		$31, 4($29)
+	addiu		$29, 8
+	jr		$31
+	.end		foo
+	.balign		4
+	.space		8
Index: binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/mips-elf.exp
===================================================================
--- binutils-fsf-trunk-quilt.orig/ld/testsuite/ld-mips-elf/mips-elf.exp	2012-08-08 22:03:56.000000000 +0100
+++ binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/mips-elf.exp	2012-08-08 22:25:08.671785439 +0100
@@ -648,3 +648,24 @@ if { $linux_gnu } {
 
 # MIPS16 and microMIPS interlinking test.
 run_dump_test "mips16-and-micromips"
+
+# Export class call relocation tests.
+set abis [concat o32 [expr {$has_newabi ? "n32 n64" : ""}]]
+foreach { abi } $abis {
+    set loadaddr [string map \
+	{o32 0x12340000 n32 0x12340000 n64 0x123456789abc0000} $abi]
+    set suff [subst \
+	[expr { [istarget *-*-irix*] \
+		? [string map {o32 o32-irix n32 n32 n64 n64} $abi] \
+		: $abi }]]
+    run_ld_link_tests [list \
+	[list \
+	    "MIPS export class call relocation test ($abi)" \
+	    "$abi_ldflags($abi) -shared -Ttext $loadaddr -T export-class-call16.ld" \
+	    "$abi_asflags($abi) -mips3 -KPIC" \
+	    [list export-class-call16-${abi}.s export-class-call16-def.s] \
+	    [list \
+		"objdump -d export-class-call16-${suff}.dd" \
+		"readelf -A export-class-call16-${abi}.gd"] \
+	    "export-class-call16-${abi}.so"]]
+}
Index: binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/export-class-call16-n32.dd
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/export-class-call16-n32.dd	2012-08-08 22:25:08.671785439 +0100
@@ -0,0 +1,41 @@
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+
+12340000 <foo>:
+12340000:	27bdfff0 	addiu	sp,sp,-16
+12340004:	ffbf0008 	sd	ra,8\(sp\)
+12340008:	ffbc0000 	sd	gp,0\(sp\)
+1234000c:	3c1c0001 	lui	gp,0x1
+12340010:	279c8080 	addiu	gp,gp,-32640
+12340014:	0399e021 	addu	gp,gp,t9
+12340018:	8f998018 	lw	t9,-32744\(gp\)
+1234001c:	04110010 	bal	12340060 <protected_foo>
+12340020:	00000000 	nop
+12340024:	8f99801c 	lw	t9,-32740\(gp\)
+12340028:	04110011 	bal	12340070 <hidden_foo>
+1234002c:	00000000 	nop
+12340030:	8f998020 	lw	t9,-32736\(gp\)
+12340034:	04110012 	bal	12340080 <internal_foo>
+12340038:	00000000 	nop
+1234003c:	dfbc0000 	ld	gp,0\(sp\)
+12340040:	dfbf0008 	ld	ra,8\(sp\)
+12340044:	03e00008 	jr	ra
+12340048:	27bd0010 	addiu	sp,sp,16
+	\.\.\.
+
+12340060 <protected_foo>:
+12340060:	03e00008 	jr	ra
+12340064:	00000000 	nop
+	\.\.\.
+
+12340070 <hidden_foo>:
+12340070:	03e00008 	jr	ra
+12340074:	00000000 	nop
+	\.\.\.
+
+12340080 <internal_foo>:
+12340080:	03e00008 	jr	ra
+12340084:	00000000 	nop
+	\.\.\.
Index: binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/export-class-call16-n32.gd
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/export-class-call16-n32.gd	2012-08-08 22:25:08.671785439 +0100
@@ -0,0 +1,14 @@
+
+Primary GOT:
+ Canonical gp value: 12348080
+
+ Reserved entries:
+   Address     Access  Initial Purpose
+  12340090 -32752\(gp\) 00000000 Lazy resolver
+  12340094 -32748\(gp\) 80000000 Module pointer \(GNU extension\)
+
+ Local entries:
+   Address     Access  Initial
+  12340098 -32744\(gp\) 12340060
+  1234009c -32740\(gp\) 12340070
+  123400a0 -32736\(gp\) 12340080
Index: binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/export-class-call16-n64.dd
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/export-class-call16-n64.dd	2012-08-08 22:25:08.671785439 +0100
@@ -0,0 +1,41 @@
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+
+123456789abc0000 <foo>:
+123456789abc0000:	67bdfff0 	daddiu	sp,sp,-16
+123456789abc0004:	ffbf0008 	sd	ra,8\(sp\)
+123456789abc0008:	ffbc0000 	sd	gp,0\(sp\)
+123456789abc000c:	3c1c0001 	lui	gp,0x1
+123456789abc0010:	279c8080 	addiu	gp,gp,-32640
+123456789abc0014:	0399e02d 	daddu	gp,gp,t9
+123456789abc0018:	df998020 	ld	t9,-32736\(gp\)
+123456789abc001c:	04110010 	bal	123456789abc0060 <protected_foo>
+123456789abc0020:	00000000 	nop
+123456789abc0024:	df998028 	ld	t9,-32728\(gp\)
+123456789abc0028:	04110011 	bal	123456789abc0070 <hidden_foo>
+123456789abc002c:	00000000 	nop
+123456789abc0030:	df998030 	ld	t9,-32720\(gp\)
+123456789abc0034:	04110012 	bal	123456789abc0080 <internal_foo>
+123456789abc0038:	00000000 	nop
+123456789abc003c:	dfbc0000 	ld	gp,0\(sp\)
+123456789abc0040:	dfbf0008 	ld	ra,8\(sp\)
+123456789abc0044:	03e00008 	jr	ra
+123456789abc0048:	67bd0010 	daddiu	sp,sp,16
+	\.\.\.
+
+123456789abc0060 <protected_foo>:
+123456789abc0060:	03e00008 	jr	ra
+123456789abc0064:	00000000 	nop
+	\.\.\.
+
+123456789abc0070 <hidden_foo>:
+123456789abc0070:	03e00008 	jr	ra
+123456789abc0074:	00000000 	nop
+	\.\.\.
+
+123456789abc0080 <internal_foo>:
+123456789abc0080:	03e00008 	jr	ra
+123456789abc0084:	00000000 	nop
+	\.\.\.
Index: binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/export-class-call16-n64.gd
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/export-class-call16-n64.gd	2012-08-08 22:25:08.671785439 +0100
@@ -0,0 +1,14 @@
+
+Primary GOT:
+ Canonical gp value: 123456789abc8080
+
+ Reserved entries:
+           Address     Access          Initial Purpose
+  123456789abc0090 -32752\(gp\) 0000000000000000 Lazy resolver
+  123456789abc0098 -32744\(gp\) 8000000000000000 Module pointer \(GNU extension\)
+
+ Local entries:
+           Address     Access          Initial
+  123456789abc00a0 -32736\(gp\) 123456789abc0060
+  123456789abc00a8 -32728\(gp\) 123456789abc0070
+  123456789abc00b0 -32720\(gp\) 123456789abc0080
Index: binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/export-class-call16-o32-irix.dd
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/export-class-call16-o32-irix.dd	2012-08-08 22:59:01.030570231 +0100
@@ -0,0 +1,43 @@
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+
+12340000 <foo>:
+12340000:	3c1c0001 	lui	gp,0x1
+12340004:	279c8080 	addiu	gp,gp,-32640
+12340008:	0399e021 	addu	gp,gp,t9
+1234000c:	27bdfff8 	addiu	sp,sp,-8
+12340010:	afbf0004 	sw	ra,4\(sp\)
+12340014:	afbc0000 	sw	gp,0\(sp\)
+12340018:	8f998018 	lw	t9,-32744\(gp\)
+1234001c:	0320f809 	jalr	t9
+12340020:	00000000 	nop
+12340024:	8fbc0000 	lw	gp,0\(sp\)
+12340028:	8f99801c 	lw	t9,-32740\(gp\)
+1234002c:	0320f809 	jalr	t9
+12340030:	00000000 	nop
+12340034:	8fbc0000 	lw	gp,0\(sp\)
+12340038:	8f998020 	lw	t9,-32736\(gp\)
+1234003c:	0320f809 	jalr	t9
+12340040:	00000000 	nop
+12340044:	8fbc0000 	lw	gp,0\(sp\)
+12340048:	8fbf0004 	lw	ra,4\(sp\)
+1234004c:	03e00008 	jr	ra
+12340050:	27bd0008 	addiu	sp,sp,8
+	\.\.\.
+
+12340060 <protected_foo>:
+12340060:	03e00008 	jr	ra
+12340064:	00000000 	nop
+	\.\.\.
+
+12340070 <hidden_foo>:
+12340070:	03e00008 	jr	ra
+12340074:	00000000 	nop
+	\.\.\.
+
+12340080 <internal_foo>:
+12340080:	03e00008 	jr	ra
+12340084:	00000000 	nop
+	\.\.\.
Index: binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/export-class-call16-o32.dd
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/export-class-call16-o32.dd	2012-08-08 22:25:08.671785439 +0100
@@ -0,0 +1,43 @@
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+
+12340000 <foo>:
+12340000:	3c1c0001 	lui	gp,0x1
+12340004:	279c8080 	addiu	gp,gp,-32640
+12340008:	0399e021 	addu	gp,gp,t9
+1234000c:	27bdfff8 	addiu	sp,sp,-8
+12340010:	afbf0004 	sw	ra,4\(sp\)
+12340014:	afbc0000 	sw	gp,0\(sp\)
+12340018:	8f998018 	lw	t9,-32744\(gp\)
+1234001c:	04110010 	bal	12340060 <protected_foo>
+12340020:	00000000 	nop
+12340024:	8fbc0000 	lw	gp,0\(sp\)
+12340028:	8f99801c 	lw	t9,-32740\(gp\)
+1234002c:	04110010 	bal	12340070 <hidden_foo>
+12340030:	00000000 	nop
+12340034:	8fbc0000 	lw	gp,0\(sp\)
+12340038:	8f998020 	lw	t9,-32736\(gp\)
+1234003c:	04110010 	bal	12340080 <internal_foo>
+12340040:	00000000 	nop
+12340044:	8fbc0000 	lw	gp,0\(sp\)
+12340048:	8fbf0004 	lw	ra,4\(sp\)
+1234004c:	03e00008 	jr	ra
+12340050:	27bd0008 	addiu	sp,sp,8
+	\.\.\.
+
+12340060 <protected_foo>:
+12340060:	03e00008 	jr	ra
+12340064:	00000000 	nop
+	\.\.\.
+
+12340070 <hidden_foo>:
+12340070:	03e00008 	jr	ra
+12340074:	00000000 	nop
+	\.\.\.
+
+12340080 <internal_foo>:
+12340080:	03e00008 	jr	ra
+12340084:	00000000 	nop
+	\.\.\.
Index: binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/export-class-call16-o32.gd
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ binutils-fsf-trunk-quilt/ld/testsuite/ld-mips-elf/export-class-call16-o32.gd	2012-08-08 22:25:08.671785439 +0100
@@ -0,0 +1,14 @@
+
+Primary GOT:
+ Canonical gp value: 12348080
+
+ Reserved entries:
+   Address     Access  Initial Purpose
+  12340090 -32752\(gp\) 00000000 Lazy resolver
+  12340094 -32748\(gp\) 80000000 Module pointer \(GNU extension\)
+
+ Local entries:
+   Address     Access  Initial
+  12340098 -32744\(gp\) 12340060
+  1234009c -32740\(gp\) 12340070
+  123400a0 -32736\(gp\) 12340080

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/3] MIPS/BFD: Correct protected symbol relocation processing
  2012-08-08 22:49 [PATCH 1/3] MIPS/BFD: Correct protected symbol relocation processing Maciej W. Rozycki
  2012-08-08 22:50 ` [PATCH 2/3] MIPS/BFD: Correct IRIX 6 DT_MIPS_OPTIONS processing Maciej W. Rozycki
  2012-08-09  1:28 ` [PATCH 3/3] MIPS/LD/test: Protected symbol relocation processing Maciej W. Rozycki
@ 2012-08-12 18:43 ` Richard Sandiford
  2012-08-13 13:24   ` Maciej W. Rozycki
  2 siblings, 1 reply; 11+ messages in thread
From: Richard Sandiford @ 2012-08-12 18:43 UTC (permalink / raw)
  To: Maciej W. Rozycki; +Cc: binutils

"Maciej W. Rozycki" <macro@codesourcery.com> writes:
> 	bfd/
> 	* elfxx-mips.c (mips_elf_calculate_relocation): Fix the handling 
> 	of protected symbols.

OK.

Richard

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/3] MIPS/BFD: Correct IRIX 6 DT_MIPS_OPTIONS processing
  2012-08-08 22:50 ` [PATCH 2/3] MIPS/BFD: Correct IRIX 6 DT_MIPS_OPTIONS processing Maciej W. Rozycki
@ 2012-08-12 18:50   ` Richard Sandiford
  2012-08-13 14:10     ` Maciej W. Rozycki
  0 siblings, 1 reply; 11+ messages in thread
From: Richard Sandiford @ 2012-08-12 18:50 UTC (permalink / raw)
  To: Maciej W. Rozycki; +Cc: binutils

"Maciej W. Rozycki" <macro@codesourcery.com> writes:
> Index: binutils-fsf-trunk-quilt/bfd/elfxx-mips.c
> ===================================================================
> --- binutils-fsf-trunk-quilt.orig/bfd/elfxx-mips.c	2012-07-26 03:29:00.000000000 +0100
> +++ binutils-fsf-trunk-quilt/bfd/elfxx-mips.c	2012-07-26 04:45:31.560520511 +0100
> @@ -9268,11 +9268,17 @@ _bfd_mips_elf_size_dynamic_sections (bfd
>  	      && ! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_HIPAGENO, 0))
>  	    return FALSE;
>  
> -	  if (IRIX_COMPAT (dynobj) == ict_irix6
> -	      && (bfd_get_section_by_name
> -		  (dynobj, MIPS_ELF_OPTIONS_SECTION_NAME (dynobj)))
> -	      && !MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_OPTIONS, 0))
> -	    return FALSE;
> +	  if (IRIX_COMPAT (dynobj) == ict_irix6)
> +	    {
> +	      const char *const name = MIPS_ELF_OPTIONS_SECTION_NAME (dynobj);
> +	      asection *opt_sec;
> +
> +	      opt_sec = bfd_get_section_by_name (dynobj, name);
> +	      if (opt_sec != NULL
> +		  && opt_sec->output_section != bfd_abs_section_ptr
> +		  && !MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_OPTIONS, 0))
> +		return FALSE;
> +	    }
>  	}

Looks to me like the code was simply checking the wrong bfd.
It should be checking output_bfd instead.

Richard

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/3] MIPS/LD/test: Protected symbol relocation processing
  2012-08-09  1:28 ` [PATCH 3/3] MIPS/LD/test: Protected symbol relocation processing Maciej W. Rozycki
@ 2012-08-12 18:51   ` Richard Sandiford
  2012-08-13 21:41     ` Maciej W. Rozycki
  0 siblings, 1 reply; 11+ messages in thread
From: Richard Sandiford @ 2012-08-12 18:51 UTC (permalink / raw)
  To: Maciej W. Rozycki; +Cc: binutils

"Maciej W. Rozycki" <macro@codesourcery.com> writes:
> 2012-08-08  Maciej W. Rozycki  <macro@codesourcery.com>
>
> 	ld/testsuite/
> 	* ld-mips-elf/export-class-call16-o32.dd: New test.
> 	* ld-mips-elf/export-class-call16-o32-irix.dd: New test.
> 	* ld-mips-elf/export-class-call16-o32.gd: New test.
> 	* ld-mips-elf/export-class-call16-n32.dd: New test.
> 	* ld-mips-elf/export-class-call16-n32.gd: New test.
> 	* ld-mips-elf/export-class-call16-n64.dd: New test.
> 	* ld-mips-elf/export-class-call16-n64.gd: New test.
> 	* ld-mips-elf/export-class-call16-def.s: New test source.
> 	* ld-mips-elf/export-class-call16-o32.s: New test source.
> 	* ld-mips-elf/export-class-call16-n32.s: New test source.
> 	* ld-mips-elf/export-class-call16-n64.s: New test source.
> 	* ld-mips-elf/export-class-call16.ld: New test linker script.
> 	* ld-mips-elf/mips-elf.exp: Run the new tests.

OK.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/3] MIPS/BFD: Correct protected symbol relocation processing
  2012-08-12 18:43 ` [PATCH 1/3] MIPS/BFD: Correct protected " Richard Sandiford
@ 2012-08-13 13:24   ` Maciej W. Rozycki
  0 siblings, 0 replies; 11+ messages in thread
From: Maciej W. Rozycki @ 2012-08-13 13:24 UTC (permalink / raw)
  To: Richard Sandiford; +Cc: binutils

On Sun, 12 Aug 2012, Richard Sandiford wrote:

> > 	* elfxx-mips.c (mips_elf_calculate_relocation): Fix the handling 
> > 	of protected symbols.
> 
> OK.

 Applied now, thanks.

  Maciej

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/3] MIPS/BFD: Correct IRIX 6 DT_MIPS_OPTIONS processing
  2012-08-12 18:50   ` Richard Sandiford
@ 2012-08-13 14:10     ` Maciej W. Rozycki
  2012-08-13 19:44       ` Richard Sandiford
  0 siblings, 1 reply; 11+ messages in thread
From: Maciej W. Rozycki @ 2012-08-13 14:10 UTC (permalink / raw)
  To: Richard Sandiford; +Cc: binutils

On Sun, 12 Aug 2012, Richard Sandiford wrote:

> > Index: binutils-fsf-trunk-quilt/bfd/elfxx-mips.c
> > ===================================================================
> > --- binutils-fsf-trunk-quilt.orig/bfd/elfxx-mips.c	2012-07-26 03:29:00.000000000 +0100
> > +++ binutils-fsf-trunk-quilt/bfd/elfxx-mips.c	2012-07-26 04:45:31.560520511 +0100
> > @@ -9268,11 +9268,17 @@ _bfd_mips_elf_size_dynamic_sections (bfd
> >  	      && ! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_HIPAGENO, 0))
> >  	    return FALSE;
> >  
> > -	  if (IRIX_COMPAT (dynobj) == ict_irix6
> > -	      && (bfd_get_section_by_name
> > -		  (dynobj, MIPS_ELF_OPTIONS_SECTION_NAME (dynobj)))
> > -	      && !MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_OPTIONS, 0))
> > -	    return FALSE;
> > +	  if (IRIX_COMPAT (dynobj) == ict_irix6)
> > +	    {
> > +	      const char *const name = MIPS_ELF_OPTIONS_SECTION_NAME (dynobj);
> > +	      asection *opt_sec;
> > +
> > +	      opt_sec = bfd_get_section_by_name (dynobj, name);
> > +	      if (opt_sec != NULL
> > +		  && opt_sec->output_section != bfd_abs_section_ptr
> > +		  && !MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_OPTIONS, 0))
> > +		return FALSE;
> > +	    }
> >  	}
> 
> Looks to me like the code was simply checking the wrong bfd.
> It should be checking output_bfd instead.

 Doh, this seems to work for me.  No regressions on the 23 MIPS targets.  
OK for this one instead?

2012-08-13  Maciej W. Rozycki  <macro@codesourcery.com>

	bfd/
	* elfxx-mips.c (_bfd_mips_elf_size_dynamic_sections): Look up
	the options section in the output rather than input BFD to
	decide if to add a DT_MIPS_OPTIONS tag.

  Maciej

binutils-bfd-mips-irix-options.diff
Index: binutils-fsf-trunk-quilt/bfd/elfxx-mips.c
===================================================================
--- binutils-fsf-trunk-quilt.orig/bfd/elfxx-mips.c	2012-08-13 12:40:13.090607382 +0100
+++ binutils-fsf-trunk-quilt/bfd/elfxx-mips.c	2012-08-13 12:41:25.821821636 +0100
@@ -9282,7 +9282,7 @@ _bfd_mips_elf_size_dynamic_sections (bfd
 
 	  if (IRIX_COMPAT (dynobj) == ict_irix6
 	      && (bfd_get_section_by_name
-		  (dynobj, MIPS_ELF_OPTIONS_SECTION_NAME (dynobj)))
+		  (output_bfd, MIPS_ELF_OPTIONS_SECTION_NAME (dynobj)))
 	      && !MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_OPTIONS, 0))
 	    return FALSE;
 	}

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/3] MIPS/BFD: Correct IRIX 6 DT_MIPS_OPTIONS processing
  2012-08-13 14:10     ` Maciej W. Rozycki
@ 2012-08-13 19:44       ` Richard Sandiford
  2012-08-13 19:53         ` Maciej W. Rozycki
  0 siblings, 1 reply; 11+ messages in thread
From: Richard Sandiford @ 2012-08-13 19:44 UTC (permalink / raw)
  To: Maciej W. Rozycki; +Cc: binutils

"Maciej W. Rozycki" <macro@codesourcery.com> writes:
> 2012-08-13  Maciej W. Rozycki  <macro@codesourcery.com>
>
> 	bfd/
> 	* elfxx-mips.c (_bfd_mips_elf_size_dynamic_sections): Look up
> 	the options section in the output rather than input BFD to
> 	decide if to add a DT_MIPS_OPTIONS tag.

OK, thanks.

Richard

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/3] MIPS/BFD: Correct IRIX 6 DT_MIPS_OPTIONS processing
  2012-08-13 19:44       ` Richard Sandiford
@ 2012-08-13 19:53         ` Maciej W. Rozycki
  0 siblings, 0 replies; 11+ messages in thread
From: Maciej W. Rozycki @ 2012-08-13 19:53 UTC (permalink / raw)
  To: Richard Sandiford; +Cc: binutils

On Mon, 13 Aug 2012, Richard Sandiford wrote:

> > 	* elfxx-mips.c (_bfd_mips_elf_size_dynamic_sections): Look up
> > 	the options section in the output rather than input BFD to
> > 	decide if to add a DT_MIPS_OPTIONS tag.
> 
> OK, thanks.

 Now applied, thanks.

  Maciej

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/3] MIPS/LD/test: Protected symbol relocation processing
  2012-08-12 18:51   ` Richard Sandiford
@ 2012-08-13 21:41     ` Maciej W. Rozycki
  0 siblings, 0 replies; 11+ messages in thread
From: Maciej W. Rozycki @ 2012-08-13 21:41 UTC (permalink / raw)
  To: Richard Sandiford; +Cc: binutils

On Sun, 12 Aug 2012, Richard Sandiford wrote:

> > 	* ld-mips-elf/export-class-call16-o32.dd: New test.
> > 	* ld-mips-elf/export-class-call16-o32-irix.dd: New test.
> > 	* ld-mips-elf/export-class-call16-o32.gd: New test.
> > 	* ld-mips-elf/export-class-call16-n32.dd: New test.
> > 	* ld-mips-elf/export-class-call16-n32.gd: New test.
> > 	* ld-mips-elf/export-class-call16-n64.dd: New test.
> > 	* ld-mips-elf/export-class-call16-n64.gd: New test.
> > 	* ld-mips-elf/export-class-call16-def.s: New test source.
> > 	* ld-mips-elf/export-class-call16-o32.s: New test source.
> > 	* ld-mips-elf/export-class-call16-n32.s: New test source.
> > 	* ld-mips-elf/export-class-call16-n64.s: New test source.
> > 	* ld-mips-elf/export-class-call16.ld: New test linker script.
> > 	* ld-mips-elf/mips-elf.exp: Run the new tests.
> 
> OK.

 Now in as well, thanks.

  Maciej

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2012-08-13 19:53 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-08 22:49 [PATCH 1/3] MIPS/BFD: Correct protected symbol relocation processing Maciej W. Rozycki
2012-08-08 22:50 ` [PATCH 2/3] MIPS/BFD: Correct IRIX 6 DT_MIPS_OPTIONS processing Maciej W. Rozycki
2012-08-12 18:50   ` Richard Sandiford
2012-08-13 14:10     ` Maciej W. Rozycki
2012-08-13 19:44       ` Richard Sandiford
2012-08-13 19:53         ` Maciej W. Rozycki
2012-08-09  1:28 ` [PATCH 3/3] MIPS/LD/test: Protected symbol relocation processing Maciej W. Rozycki
2012-08-12 18:51   ` Richard Sandiford
2012-08-13 21:41     ` Maciej W. Rozycki
2012-08-12 18:43 ` [PATCH 1/3] MIPS/BFD: Correct protected " Richard Sandiford
2012-08-13 13:24   ` Maciej W. Rozycki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).