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]

[committed 2/4] MIPS/BFD: Add microMIPS annotation to LA25 stub symbols


Fix a problem with missing microMIPS symbol annotation with microMIPS 
LA25 stub symbols.  The consequence of the issue is these symbols appear 
in the symbol table as regular MIPS symbols with the ISA bit set, as 
shown with the example below:

$ cat la25a.s
	.abicalls

	.global	f1
	.ent	f1
f1:
	.set	noreorder
	.cpload	$25
	.set	reorder
	.option	pic0
	jal	f2
	.option	pic2
	jr	$31
	.end	f1

	.global	f2
	.ent	f2
f2:
	jr	$31
	.end	f2
$ cat la25b.s
	.abicalls
	.option	pic0

	.global	__start
	.ent	__start
__start:
	jal	f1
	jal	f2
	.end	__start
$ as -mmicromips -32 -EB -o la25a.o la25a.s
$ as -mmicromips -32 -EB -o la25b.o la25b.s
$ ld -melf32btsmip -o la25 la25a.o la25b.o
$ readelf -s la25

Symbol table '.symtab' contains 18 entries:
   Num:    Value  Size Type    Bind   Vis      Ndx Name
     0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND 
     1: 00400098     0 SECTION LOCAL  DEFAULT    1 
     2: 004000b0     0 SECTION LOCAL  DEFAULT    2 
     3: 004000d0     0 SECTION LOCAL  DEFAULT    3 
     4: 00000000     0 SECTION LOCAL  DEFAULT    4 
     5: 00000000     0 SECTION LOCAL  DEFAULT    5 
     6: 00418110     0 NOTYPE  LOCAL  DEFAULT    3 _gp
     7: 004000e1    16 FUNC    LOCAL  DEFAULT    3 .pic.f1
     8: 004000d1    16 FUNC    LOCAL  DEFAULT    3 .pic.f2
     9: 00410120     0 NOTYPE  GLOBAL DEFAULT    3 _fdata
    10: 00400110    16 FUNC    GLOBAL DEFAULT [MICROMIPS]     3 __start
    11: 00400106     2 FUNC    GLOBAL DEFAULT [MICROMIPS]     3 f2
    12: 004000d0     0 NOTYPE  GLOBAL DEFAULT    3 _ftext
    13: 00410120     0 NOTYPE  GLOBAL DEFAULT    3 __bss_start
    14: 004000f0    22 FUNC    GLOBAL DEFAULT [MICROMIPS]     3 f1
    15: 00410120     0 NOTYPE  GLOBAL DEFAULT    3 _edata
    16: 00410120     0 NOTYPE  GLOBAL DEFAULT    3 _end
    17: 00410120     0 NOTYPE  GLOBAL DEFAULT    3 _fbss
$ 

where microMIPS annotation is missing for `.pic.f1' and `.pic.f2' even 
though these stubs are associated with microMIPS functions `f1' and `f2' 
respectively.

Add the missing annotation then, by copying it from the function symbol 
an LA25 stub is associated with, correcting the example above:

$ readelf -s la25

Symbol table '.symtab' contains 18 entries:
   Num:    Value  Size Type    Bind   Vis      Ndx Name
     0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND 
     1: 00400098     0 SECTION LOCAL  DEFAULT    1 
     2: 004000b0     0 SECTION LOCAL  DEFAULT    2 
     3: 004000d0     0 SECTION LOCAL  DEFAULT    3 
     4: 00000000     0 SECTION LOCAL  DEFAULT    4 
     5: 00000000     0 SECTION LOCAL  DEFAULT    5 
     6: 00418110     0 NOTYPE  LOCAL  DEFAULT    3 _gp
     7: 004000e0    16 FUNC    LOCAL  DEFAULT [MICROMIPS]     3 .pic.f1
     8: 004000d0    16 FUNC    LOCAL  DEFAULT [MICROMIPS]     3 .pic.f2
     9: 00410120     0 NOTYPE  GLOBAL DEFAULT    3 _fdata
    10: 00400110    16 FUNC    GLOBAL DEFAULT [MICROMIPS]     3 __start
    11: 00400106     2 FUNC    GLOBAL DEFAULT [MICROMIPS]     3 f2
    12: 004000d0     0 NOTYPE  GLOBAL DEFAULT    3 _ftext
    13: 00410120     0 NOTYPE  GLOBAL DEFAULT    3 __bss_start
    14: 004000f0    22 FUNC    GLOBAL DEFAULT [MICROMIPS]     3 f1
    15: 00410120     0 NOTYPE  GLOBAL DEFAULT    3 _edata
    16: 00410120     0 NOTYPE  GLOBAL DEFAULT    3 _end
    17: 00410120     0 NOTYPE  GLOBAL DEFAULT    3 _fbss
$ 

This problem has been there since the beginning of microMIPS support:

commit df58fc944dbc6d5efd8d3826241b64b6af22f447
Author: Richard Sandiford <rdsandiford@googlemail.com>
Date:   Sun Jul 24 14:20:15 2011 +0000

<https://sourceware.org/ml/binutils/2011-07/msg00198.html>, ("MIPS: 
microMIPS ASE support").

	bfd/
	* elfxx-mips.c (mips_elf_create_stub_symbol): For a microMIPS 
	stub also add STO_MICROMIPS annotation.
---
binutils-umips-bfd-la25-st-other.diff
Index: binutils/bfd/elfxx-mips.c
===================================================================
--- binutils.orig/bfd/elfxx-mips.c	2016-08-08 16:50:32.668787260 +0100
+++ binutils/bfd/elfxx-mips.c	2016-08-08 17:31:58.912513411 +0100
@@ -1578,12 +1578,13 @@ mips_elf_create_stub_symbol (struct bfd_
 			     const char *prefix, asection *s, bfd_vma value,
 			     bfd_vma size)
 {
+  bfd_boolean micromips_p = ELF_ST_IS_MICROMIPS (h->root.other);
   struct bfd_link_hash_entry *bh;
   struct elf_link_hash_entry *elfh;
   char *name;
   bfd_boolean res;
 
-  if (ELF_ST_IS_MICROMIPS (h->root.other))
+  if (micromips_p)
     value |= 1;
 
   /* Create a new symbol.  */
@@ -1601,6 +1602,8 @@ mips_elf_create_stub_symbol (struct bfd_
   elfh->type = ELF_ST_INFO (STB_LOCAL, STT_FUNC);
   elfh->size = size;
   elfh->forced_local = 1;
+  if (micromips_p)
+    elfh->other = ELF_ST_SET_MICROMIPS (elfh->other);
   return TRUE;
 }
 


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