]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
MIPS/BFD: Add microMIPS annotation to LA25 stub symbols
authorMaciej W. Rozycki <macro@imgtec.com>
Wed, 10 Aug 2016 19:03:02 +0000 (20:03 +0100)
committerMaciej W. Rozycki <macro@imgtec.com>
Wed, 10 Aug 2016 21:21:15 +0000 (22:21 +0100)
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.

bfd/ChangeLog
bfd/elfxx-mips.c

index ac8230d05f684aa3b68a3733c43da88ef446a04c..3ddafcb09d4bd53f26bd5d870b1a1f6f50e5054f 100644 (file)
@@ -1,3 +1,8 @@
+2016-08-10  Maciej W. Rozycki  <macro@imgtec.com>
+
+       * elfxx-mips.c (mips_elf_create_stub_symbol): For a microMIPS
+       stub also add STO_MICROMIPS annotation.
+
 2016-08-10  Maciej W. Rozycki  <macro@imgtec.com>
 
        * elfxx-mips.c (mips_elf_calculate_relocation): Set the ISA bit
index cfb9a52af02322eea07c18f3894ccf2b11341e67..6690428c64492a586061e43bc29f9d7cb2bc2f55 100644 (file)
@@ -1578,12 +1578,13 @@ mips_elf_create_stub_symbol (struct bfd_link_info *info,
                             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_link_info *info,
   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;
 }