[llvm-dev] [llvm-objdump] Bug 40703 - wrong line number info for obj file compiled with -ffunction-sections

Alexey Lapshin via llvm-dev
2019-02-12T15:36:00Z

Folks,

     I would like to ask about  Bug 40703 -  wrong line number info for obj file
compiled with -ffunction-sections. The problem there is that when object file
compiled, it does not have addresses assigned to sections. So it uses offsets
inside section to dump instructions. When these offsets came to
DwarfLineTable(to get line information) - it does not know which section it
relates to. I have a fix for that bug. I believe correct fix would be to pass
additional section information. But it changes interfaces and need to patch many
places. I would like to ask whether these interface changes are OK. The main
change is to pass not only address but corresponding Section Index also:

struct SectionedAddress {
  uint64_t Address;
  uint64_t SectionIndex;
};

include/llvm/DebugInfo/DIContext.h
=====================================================index
a41ab21412d..cea7aedc26a 100644
--- a/llvm/include/llvm/DebugInfo/DIContext.h
+++ b/llvm/include/llvm/DebugInfo/DIContext.h
@@ -203,11 +203,11 @@ public:
     return true;
   }

-  virtual DILineInfo getLineInfoForAddress(uint64_t Address,
+  virtual DILineInfo getLineInfoForAddress(object::SectionedAddress Address,
       DILineInfoSpecifier Specifier = DILineInfoSpecifier()) = 0;
-  virtual DILineInfoTable getLineInfoForAddressRange(uint64_t Address,
+  virtual DILineInfoTable getLineInfoForAddressRange(object::SectionedAddress
Address,
       uint64_t Size, DILineInfoSpecifier Specifier = DILineInfoSpecifier()) =
0;
-  virtual DIInliningInfo getInliningInfoForAddress(uint64_t Address,
+  virtual DIInliningInfo getInliningInfoForAddress(object::SectionedAddress
Address,
       DILineInfoSpecifier Specifier = DILineInfoSpecifier()) = 0;


include/llvm/DebugInfo/DWARF/DWARFDebugLine.h
=====================================================-    uint32_t
lookupAddress(uint64_t Address) const;
+    uint32_t lookupAddress(llvm::SectionedAddress Address) const;

-    bool lookupAddressRange(uint64_t Address, uint64_t Size,
+    bool lookupAddressRange(llvm::SectionedAddress Address, uint64_t Size,
                             std::vector<uint32_t> &Result) const;

     bool hasFileAtIndex(uint64_t FileIndex) const;
@@ -238,7 +247,7 @@ public:

     /// Fills the Result argument with the file and line information
     /// corresponding to Address. Returns true on success.
-    bool getFileLineInfoForAddress(uint64_t Address, const char *CompDir,
+    bool getFileLineInfoForAddress(llvm::SectionedAddress Address, const char
*CompDir,
                                    DILineInfoSpecifier::FileLineInfoKind Kind,
                                    DILineInfo &Result) const;

-    uint32_t lookupAddress(uint64_t Address) const;
+    uint32_t lookupAddress(llvm::SectionedAddress Address) const;

include/llvm/DebugInfo/Symbolize/Symbolize.h
=====================================================@@ -57,13 +57,13 @@ public:
   }

   Expected<DILineInfo> symbolizeCode(const std::string &ModuleName,
-                                     uint64_t ModuleOffset,
+                                     object::SectionedAddress ModuleOffset,
                                      StringRef DWPName = "");
   Expected<DIInliningInfo> symbolizeInlinedCode(const std::string
&ModuleName,
-                                                uint64_t ModuleOffset,
+                                                object::SectionedAddress
ModuleOffset,
                                                 StringRef DWPName =
"");
   Expected<DIGlobal> symbolizeData(const std::string &ModuleName,
-                                   uint64_t ModuleOffset);
+                                   object::SectionedAddress  ModuleOffset);


include/llvm/DebugInfo/Symbolize/SymbolizableModule.h
=====================================================@@ -24,13 +24,13 @@ class
SymbolizableModule {
 public:
   virtual ~SymbolizableModule() = default;

-  virtual DILineInfo symbolizeCode(uint64_t ModuleOffset,
+  virtual DILineInfo symbolizeCode(object::SectionedAddress ModuleOffset,
                                    FunctionNameKind FNKind,
                                    bool UseSymbolTable) const = 0;
-  virtual DIInliningInfo symbolizeInlinedCode(uint64_t ModuleOffset,
+  virtual DIInliningInfo symbolizeInlinedCode(object::SectionedAddress
ModuleOffset,
                                               FunctionNameKind FNKind,
                                               bool UseSymbolTable) const = 0;
-  virtual DIGlobal symbolizeData(uint64_t ModuleOffset) const = 0;
+  virtual DIGlobal symbolizeData(object::SectionedAddress ModuleOffset) const =
0;

If there are no objections for such interface change I would proceed with my fix
in fabricator.


Thank you, Alexey.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20190212/9b1fa97f/attachment-0001.html>