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.