[PATCH 5/9] covoar/ObjdumpProcessor.cc: Remove jump tables from the end of symbols.

Cillian O'Donnell cpodonnell8 at gmail.com
Fri Aug 25 21:53:28 UTC 2017


Some tests objdumps have jump tables added to the end of them causing the
same symbols to have different sizes when processed. This removes them and
their associated errors.
---
 tester/covoar/ObjdumpProcessor.cc | 37 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 36 insertions(+), 1 deletion(-)

diff --git a/tester/covoar/ObjdumpProcessor.cc b/tester/covoar/ObjdumpProcessor.cc
index 262c0a5..01692b8 100644
--- a/tester/covoar/ObjdumpProcessor.cc
+++ b/tester/covoar/ObjdumpProcessor.cc
@@ -345,6 +345,7 @@ namespace Coverage {
     uint32_t           endAddress;
     uint32_t           instructionOffset;
     int                items;
+    int                found;
     objdumpLine_t      lineInfo;
     FILE*              objdumpFile;
     uint32_t           offset;
@@ -352,8 +353,13 @@ namespace Coverage {
     uint32_t           startAddress = 0;
     char               symbol[ MAX_LINE_LENGTH ];
     char               terminator1;
+    char               terminatorOne;
     char               terminator2;
     objdumpLines_t     theInstructions;
+    char               instruction[ MAX_LINE_LENGTH ];
+    char               ID[ MAX_LINE_LENGTH ];
+    std::string        call = "";
+    std::string        jumpTableID = "";
 
     // Obtain the objdump file.
     if (!executableInformation->hasDynamicLibrary())
@@ -407,6 +413,15 @@ namespace Coverage {
         &offset, symbol, &terminator1
       );
 
+      // See if it is a jump table.
+      found = sscanf(
+        inputBuffer,
+        "%x%c\t%*[^\t]%c%s %*x %*[^+]%s",
+        &instructionOffset, &terminatorOne, &terminator2, instruction, ID
+      );
+      call = instruction;
+      jumpTableID = ID;
+
       // If all items found, we are at the beginning of a symbol's objdump.
       if ((items == 3) && (terminator1 == ':')) {
 
@@ -437,7 +452,27 @@ namespace Coverage {
           theInstructions.push_back( lineInfo );
         }
       }
-
+      // If it looks like a jump table, finalize the symbol.
+      else if ( (found == 5) && (terminatorOne == ':') && (terminator2 == '\t')
+               && (call.find( "call" ) != std::string::npos)
+               && (jumpTableID.find( "+0x" ) != std::string::npos)
+               && processSymbol )
+      {
+
+          endAddress = executableInformation->getLoadAddress() + offset - 1;
+
+          // If we are currently processing a symbol, finalize it.
+          if ( processSymbol ) {
+            finalizeSymbol(
+              executableInformation,
+              currentSymbol,
+              startAddress,
+              endAddress,
+              theInstructions
+            );
+          }
+          processSymbol = false;
+      }
       else if (processSymbol) {
 
         // See if it is the dump of an instruction.
-- 
2.7.4




More information about the devel mailing list