[PATCH 1/2] MIPS: Compressed PLT/stubs support

Maciej W. Rozycki macro@codesourcery.com
Fri Mar 8 12:04:00 GMT 2013


On Wed, 20 Feb 2013, Richard Sandiford wrote:

> > @@ -9905,21 +10306,39 @@ _bfd_mips_elf_finish_dynamic_symbol (bfd
> >  	 binary where pointer equality matters.  */
> >        sym->st_shndx = SHN_UNDEF;
> >        if (h->pointer_equality_needed)
> > -	sym->st_other = STO_MIPS_PLT;
> > +	{
> > +	  if (ELF_ST_IS_MIPS16 (sym->st_other))
> > +	    sym->st_other
> > +	      = ELF_ST_SET_MIPS16 (ELF_ST_SET_MIPS_PLT (sym->st_other));
> > +	  else
> > +	    sym->st_other = ELF_ST_SET_MIPS_PLT (sym->st_other);
> > +	}
> 
> Please update the definition of ELF_ST_SET_MIPS_PLT instead, so that
> STO_MIPS16 gets preserved in the same way as STO_MICROMIPS.

 Obviously this is a preexisting problem and also all the four relevant 
macros that handle flags from the STO_MIPS_FLAGS set are affected.  

 Here's my proposed fix.  Following the comment on MIPS_PIC (and common 
sense) I decided ELF_ST_SET_MIPS_PIC should silently ignore the request 
for MIPS16 symbols rather than override the old setting.  PLT symbols are 
of course compatible with the MIPS16 setting.

 I don't know why STO_OPTIONAL is handled differently from the other 
STO_MIPS_FLAGS bits, but the way it is does not conflict with the MIPS16 
setting, so I've left ELF_MIPS_IS_OPTIONAL intact.  Feel free to fiddle 
with it yourself if you feel like.

 OK to apply?

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

	include/elf/
	* mips.h (ELF_ST_IS_MIPS_PLT): Respect STO_MIPS16 setting.
	(ELF_ST_SET_MIPS_PLT): Likewise.
	(ELF_ST_IS_MIPS_PIC, ELF_ST_SET_MIPS_PIC): Likewise.

binutils-include-mips-elf-st-set.diff
Index: binutils-fsf-trunk-quilt/include/elf/mips.h
===================================================================
--- binutils-fsf-trunk-quilt.orig/include/elf/mips.h	2013-03-01 04:56:24.000000000 +0000
+++ binutils-fsf-trunk-quilt/include/elf/mips.h	2013-03-06 23:06:37.914980891 +0000
@@ -803,15 +803,26 @@ extern void bfd_mips_elf32_swap_reginfo_
    PLT entries and traditional MIPS lazy binding stubs.  We mark the former
    with STO_MIPS_PLT to distinguish them from the latter.  */
 #define STO_MIPS_PLT		0x8
-#define ELF_ST_IS_MIPS_PLT(other) (((other) & STO_MIPS_FLAGS) == STO_MIPS_PLT)
-#define ELF_ST_SET_MIPS_PLT(other) (((other) & ~STO_MIPS_FLAGS) | STO_MIPS_PLT)
+#define ELF_ST_IS_MIPS_PLT(other)					\
+  ((ELF_ST_IS_MIPS16 (other)						\
+    ? ((other) & (~STO_MIPS16 & STO_MIPS_FLAGS))			\
+    : ((other) & STO_MIPS_FLAGS)) == STO_MIPS_PLT)
+#define ELF_ST_SET_MIPS_PLT(other)					\
+  ((ELF_ST_IS_MIPS16 (other)						\
+    ? ((other) & (STO_MIPS16 | ~STO_MIPS_FLAGS))			\
+    : ((other) & ~STO_MIPS_FLAGS)) | STO_MIPS_PLT)
 
 /* This value is used to mark PIC functions in an object that mixes
    PIC and non-PIC.  Note that this bit overlaps with STO_MIPS16,
    although MIPS16 symbols are never considered to be MIPS_PIC.  */
 #define STO_MIPS_PIC		0x20
-#define ELF_ST_IS_MIPS_PIC(other) (((other) & STO_MIPS_FLAGS) == STO_MIPS_PIC)
-#define ELF_ST_SET_MIPS_PIC(other) (((other) & ~STO_MIPS_FLAGS) | STO_MIPS_PIC)
+#define ELF_ST_IS_MIPS_PIC(other)					\
+  (!ELF_ST_IS_MIPS16 (other)						\
+   && ((other) & STO_MIPS_FLAGS) == STO_MIPS_PIC)
+#define ELF_ST_SET_MIPS_PIC(other)					\
+  (ELF_ST_IS_MIPS16 (other)						\
+   ? (other)								\
+   : (((other) & ~STO_MIPS_FLAGS) | STO_MIPS_PIC))
 
 /* This value is used for a mips16 .text symbol.  */
 #define STO_MIPS16		0xf0



More information about the Binutils mailing list