Fix AArch64 "$x" symbols

Andrew Haley <[email protected]>
Newsgroups gmane.linux.oprofile
Message-ID <[email protected]>
There's a bug in Oprofile for AArch64 where "opreport -l" prints out lots
of symbols as "x".  Like this:

21690    604433         1.0010  27.8939    libjvm.so                PhaseChaitin::build_ifg_physical(ResourceArea*)
20856    625289         0.9625  28.8564    libjvm.so                ConnectionGraph::add_fields_to_worklist(FieldNode*, PointsToNode*)
20707    645996         0.9556  29.8120    libjvm.so                $x
19824    665820         0.9149  30.7269    libjvm.so                PhaseIdealLoop::is_dominator(Node*, Node*)
19483    685303         0.8991  31.6260    libjvm.so                $x
17863    703166         0.8244  32.4504    libjvm.so                SymbolTable::lookup_only(char const*, int, unsigned int&)
17530    720696         0.8090  33.2593    libjvm.so                PhaseChaitin::interfere_with_live(unsigned int, IndexSet*)
16381    737077         0.7560  34.0153    libjvm.so                PhaseIdealLoop::Dominators()
16124    753201         0.7441  34.7594    libjvm.so                MachNode::rematerialize() const
15886    769087         0.7331  35.4925    libjvm.so                SpinPause
14797    783884         0.6829  36.1754    libjvm.so                $x


It turns out that these "$x" symbols aren't symbols at all, but
"mapping symbols".  The AArch64 ELF specification requires that
special symbols be inserted into object files to mark certain
features:

$x
    At the start of a region of code containing AArch64 instructions.

$d
    At the start of a region of data.

These symbols should be ignored by tools.  The fix in Oprofile is
trivial:

diff --git a/libpp/profile_container.cpp b/libpp/profile_container.cpp
index e543f51..ec8438c 100644
--- a/libpp/profile_container.cpp
+++ b/libpp/profile_container.cpp
@@ -81,6 +81,9 @@ void profile_container::add(profile_t const & profile,

        for (symbol_index_t i = 0; i < abfd.syms.size(); ++i) {

+               if (abfd.syms[i].name() == "$x")
+                       continue;
+
                unsigned long long start = 0, end = 0;
                symbol_entry symb_entry;

And now the output looks like this:

21690    604433         1.1579  32.2665    libjvm.so                PhaseChaitin::build_ifg_physical(ResourceArea*)
20856    625289         1.1134  33.3798    libjvm.so                ConnectionGraph::add_fields_to_worklist(FieldNode*, PointsToNode*)
19824    645113         1.0583  34.4381    libjvm.so                PhaseIdealLoop::is_dominator(Node*, Node*)
17863    662976         0.9536  35.3917    libjvm.so                SymbolTable::lookup_only(char const*, int, unsigned int&)
17530    680506         0.9358  36.3275    libjvm.so                PhaseChaitin::interfere_with_live(unsigned int, IndexSet*)
16381    696887         0.8745  37.2019    libjvm.so                PhaseIdealLoop::Dominators()
16124    713011         0.8607  38.0627    libjvm.so                MachNode::rematerialize() const
15886    728897         0.8480  38.9107    libjvm.so                SpinPause
14687    743584         0.7840  39.6948    libjvm.so                PhaseLive::add_liveout(Block*, IndexSet*, VectorSet&)

Andrew.

------------------------------------------------------------------------------
Infragistics Professional
Build stunning WinForms apps today!
Reboot your WinForms applications with our WinForms controls. 
Build a bridge from your legacy apps to the future.
http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.