<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
span.EmailStyle18
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal">I’m not sure if I have seen an example of method split into more than one piece. It has been a while since I made this fix.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">A specific test executable that shows the suffixes is testsuites/libtests/block08.exe, but most (if not all) of them should have symbols like this from what I can tell.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I found a good explanation of this directly in the GCC source here:<o:p></o:p></p>
<p class="MsoNormal"><a href="https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/ipa-split.c;h=5e918ee3fbf6a86bd7fbfab6293f90c146b74977;hb=HEAD">https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/ipa-split.c;h=5e918ee3fbf6a86bd7fbfab6293f90c146b74977;hb=HEAD</a><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Alex<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b>From:</b> Joel Sherrill <joel@rtems.org> <br>
<b>Sent:</b> Tuesday, March 16, 2021 9:53 AM<br>
<b>To:</b> Alex White <alex.white@oarcorp.com><br>
<b>Cc:</b> rtems-devel@rtems.org <devel@rtems.org><br>
<b>Subject:</b> Re: [PATCH v3] covoar: Handle periods in symbols from objdump<o:p></o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">On Tue, Mar 16, 2021 at 9:25 AM Alex White <<a href="mailto:alex.white@oarcorp.com">alex.white@oarcorp.com</a>> wrote:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal">Occasionally the compiler will generate symbols that look similar to<br>
symbols defined in RTEMS code except that they contain some suffix.<br>
These symbol suffixes are only found in the ELF symbol table; the<br>
symbols appear to be normal in the DWARF info. This appears to be<br>
happening on all architectures.<br>
<br>
For example, the function _Message_queue_Create from rtems appears as<br>
"_Message_queue_Create.part.0". Other suffixes include ".isra.0",<br>
".constprop.0", and ".0".<br>
<br>
This looks to be related to compiler optimizations. Symbols with<br>
suffixes were being treated as unique. For our purposes, they should be<br>
mapped to the equivalent symbols in the DWARF info. This has been<br>
fixed.<o:p></o:p></p>
</blockquote>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Everything Alex said is correct. It appears to be related to the compiler<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">optimizing and moving a section of a method "out of line". I suspect it could<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">be that it is moving an alternate path ahead of the code generated for the<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">entry point to improve some straight execution path through the method.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Perhaps Alex can point to a BSP and test exe for an example.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">But they definitely were there and looked like GCC had split the method <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">into different pieces and at least one had an address before the method<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">entry point. He never showed me a method split into more than one piece<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">but given they ended with a number, that seems likely.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">--joel<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal">---<br>
tester/covoar/ExecutableInfo.cc | 22 +++++++++++++++++++---<br>
tester/covoar/ObjdumpProcessor.cc | 6 ++++++<br>
tester/covoar/SymbolTable.cc | 12 +++++++++---<br>
3 files changed, 34 insertions(+), 6 deletions(-)<br>
<br>
diff --git a/tester/covoar/ExecutableInfo.cc b/tester/covoar/ExecutableInfo.cc<br>
index c996d75..9384973 100644<br>
--- a/tester/covoar/ExecutableInfo.cc<br>
+++ b/tester/covoar/ExecutableInfo.cc<br>
@@ -118,8 +118,7 @@ namespace Coverage {<br>
// Obtain the coverage map containing the specified address.<br>
itsSymbol = theSymbolTable.getSymbol( address );<br>
if (itsSymbol != "") {<br>
- it = coverageMaps.find( itsSymbol );<br>
- aCoverageMap = (*it).second;<br>
+ aCoverageMap = &findCoverageMap(itsSymbol);<br>
}<br>
<br>
return aCoverageMap;<br>
@@ -150,8 +149,25 @@ namespace Coverage {<br>
)<br>
{<br>
CoverageMaps::iterator cmi = coverageMaps.find( symbolName );<br>
- if ( cmi == coverageMaps.end() )<br>
+ if ( cmi != coverageMaps.end() ) {<br>
+ return *(cmi->second);<br>
+ }<br>
+<br>
+ size_t periodIndex = symbolName.find(".");<br>
+<br>
+ if (periodIndex == std::string::npos) {<br>
+ // Symbol name has no '.', can't do another lookup.<br>
throw CoverageMapNotFoundError(symbolName);<br>
+ }<br>
+<br>
+ cmi = coverageMaps.find(<br>
+ symbolName.substr(0, periodIndex)<br>
+ );<br>
+<br>
+ if ( cmi == coverageMaps.end() ) {<br>
+ throw CoverageMapNotFoundError(symbolName);<br>
+ }<br>
+<br>
return *(cmi->second);<br>
}<br>
<br>
diff --git a/tester/covoar/ObjdumpProcessor.cc b/tester/covoar/ObjdumpProcessor.cc<br>
index fa9894d..544bfa1 100644<br>
--- a/tester/covoar/ObjdumpProcessor.cc<br>
+++ b/tester/covoar/ObjdumpProcessor.cc<br>
@@ -417,6 +417,12 @@ namespace Coverage {<br>
processSymbol = false;<br>
theInstructions.clear();<br>
<br>
+ // Look for a '.' character and strip everything after it.<br>
+ char *periodIndex = strstr(symbol, ".");<br>
+ if (periodIndex != NULL) {<br>
+ *periodIndex = 0;<br>
+ }<br>
+<br>
// See if the new symbol is one that we care about.<br>
if (SymbolsToAnalyze->isDesired( symbol )) {<br>
currentSymbol = symbol;<br>
diff --git a/tester/covoar/SymbolTable.cc b/tester/covoar/SymbolTable.cc<br>
index 53bc8af..00062cc 100644<br>
--- a/tester/covoar/SymbolTable.cc<br>
+++ b/tester/covoar/SymbolTable.cc<br>
@@ -46,12 +46,18 @@ namespace Coverage {<br>
symbolData.startingAddress = start;<br>
symbolData.length = length;<br>
<br>
- if ( info[ symbol ].empty() == false ) {<br>
- if ( info[ symbol ].front().length != length ) {<br>
+ for (auto& symData : info[ symbol ]) {<br>
+ // The starting address could differ since we strip any suffixes beginning<br>
+ // with a '.'<br>
+ if (symData.startingAddress != start) {<br>
+ continue;<br>
+ }<br>
+<br>
+ if (symData.length != length) {<br>
std::ostringstream what;<br>
what << "Different lengths for the symbol "<br>
<< symbol<br>
- << " (" << info[ symbol ].front().length<br>
+ << " (" << symData.length<br>
<< " and " << length<br>
<< ")";<br>
throw rld::error( what, "SymbolTable::addSymbol" );<br>
-- <br>
2.27.0<br>
<br>
_______________________________________________<br>
devel mailing list<br>
<a href="mailto:devel@rtems.org" target="_blank">devel@rtems.org</a><br>
<a href="http://lists.rtems.org/mailman/listinfo/devel" target="_blank">http://lists.rtems.org/mailman/listinfo/devel</a><o:p></o:p></p>
</blockquote>
</div>
</div>
</div>
</body>
</html>