[Lldb-commits] [PATCH] D39315: Correct the start address for exported windows functions in arm

Stephane Sezer via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Oct 26 10:25:32 PDT 2017


sas updated this revision to Diff 120447.
sas added a comment.

Address comments by @clayborg.


https://reviews.llvm.org/D39315

Files:
  source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp


Index: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===================================================================
--- source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -37,6 +37,7 @@
 #define OPT_HEADER_MAGIC_PE32 0x010b
 #define OPT_HEADER_MAGIC_PE32_PLUS 0x020b
 
+#define THUMB_ADDRESS_BIT_MASK 0xfffffffffffffffeull
 using namespace lldb;
 using namespace lldb_private;
 
@@ -633,6 +634,10 @@
 
         std::string symbol_name;
 
+        ArchSpec header_arch;
+        GetArchitecture(header_arch);
+        bool is_arm = header_arch.GetMachine() == llvm::Triple::arm;
+
         // Read each export table entry
         for (size_t i = 0; i < export_table.number_of_names; ++i) {
           uint32_t name_ordinal =
@@ -648,6 +653,12 @@
                                            sizeof(uint32_t) * name_ordinal;
           uint32_t function_rva = symtab_data.GetU32(&function_offset);
 
+          if (is_arm && function_rva & 1) {
+            // For Thumb we need the last bit to be 0 so that the address
+            // points to the right beginning of the symbol.
+            function_rva &= THUMB_ADDRESS_BIT_MASK;
+          }
+
           Address symbol_addr(m_coff_header_opt.image_base + function_rva,
                               sect_list);
           symbols[i].GetMangled().SetValue(ConstString(symbol_name.c_str()));


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39315.120447.patch
Type: text/x-patch
Size: 1422 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20171026/d02812cd/attachment.bin>


More information about the lldb-commits mailing list