In XCOFF, each section comes with a default symbol with the same name as the section. It doesn't bind to code locations and it may cause incorrect display of symbol names under llvm-objdump -d.
For example, here is a scenario where the text section has three symbols, i.e.
00000000 .text // .text is a default symbol for text section. 00000000 .foo 0000001c .foo2
The symbols in the same section are sorted in ascending order. ie.
00000000 .foo 00000000 .text // .text has higher priority than .foo because we compare them by their names. 0000001c .foo2
llvm-objdump -d will choose the highest priority symbol to display when there are symbols with the same address.
00000000 <.text>: // incorrect here; <.foo> is expected. ... 0000001c <.foo2>: ...
This patch will change the priority of symbols with the same address by symbol type.
Only handle .text is not enough I think. We can explicitly declare the section names in sthe ource code. For example:
Your patch can fix the first function in .text section, but can not fix the first function in explicit_sec2 or explicit_sec?