RFC: mips STV_PROTECTED bug?

Matt Thomas matt@3am-software.com
Wed Feb 29 17:39:00 GMT 2012


In NetBSD, we recently changed __cerror from being .hidden to .protected and the linker started to generate the following assertions:

mipseb--netbsd/bin/ld: BFD (NetBSD Binutils nb1) 2.21.1 assertion fail [...]/bfd/elfxx-mips.c:3157
mipseb--netbsd/bin/ld: BFD (NetBSD Binutils nb1) 2.21.1 assertion fail [...]/bfd/elfxx-mips.c:3161

This generates the 2nd assert:

	.protected __cerror
	.abicalls

	.global	__cerror
        .ent    __cerror, 0
__cerror:
        .frame $29, 0, $31
	jr	$31
	.end	__cerror

	.global	foo
        .ent    foo, 0
foo:
        .frame $29, 0, $31
	.set	push
	.set	noreorder
	.cpload	$25
	.set	pop
	la	$25, __cerror
	jr	$25
	.end	foo

as -o bug.o bug.s
ld -o bug.so -shared bug.o

I came up with the following patch which seems to do the right thing
but I'm not that familiar with the mips backend so I'm not sure if this
is the right fix.  Could someone verify that this is right fix?

Index: elfxx-mips.c
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-mips.c,v
retrieving revision 1.301
diff -u -p -r1.301 elfxx-mips.c
--- elfxx-mips.c	19 Dec 2011 07:58:00 -0000	1.301
+++ elfxx-mips.c	29 Feb 2012 17:18:56 -0000
@@ -5338,7 +5338,11 @@ 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);



More information about the Binutils mailing list