omjavaid created this revision.
omjavaid added reviewers: tberghammer, rengolin, clayborg.
omjavaid added a subscriber: lldb-commits.
Herald added subscribers: danalbert, tberghammer, rengolin, aemerson.

This patch provides a fix for wrong plt entry size generated for binaries built 
with gcc and linked with ld for arm linux targets.

Many tests fail on arm-linux targets for this very issues. Luckily on Android 
arm32 targets we get a zero size for which there is already a fix available in 
the code.

Effect of this patch appears when code jumps into plt code and tries to 
calculate frame for current PC. A wrong calculation of plt entry addresses 
ranges results in failure to calculate frame hence stepping failures when 
dealing with any library functions using procedure linkage table.

LD produces 12 byte plt entries for arm and can also produce 16 byte entries 
but by no means plt entry can be 4 bytes which appears while we decode plt 
header.

No other architecture in my knowledge uses a PLT slot of less than or equal to 
4bytes. I could be wrong but in my knowledge a PLT slot is at least 2 
instructions on a 32bit machine s which is 8 bytes and a lot higher for 64 bit 
machines so I have made the code change to handle all casses below or equal 4 
bytes with manual calculation.

This fixes issues on arm targets. 

LGTM? or comments?

http://reviews.llvm.org/D19252

Files:
  source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp

Index: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===================================================================
--- source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -2510,7 +2510,7 @@
     elf_xword plt_entsize = plt_hdr->sh_addralign ?
         llvm::alignTo (plt_hdr->sh_entsize, plt_hdr->sh_addralign) : 
plt_hdr->sh_entsize;
 
-    if (plt_entsize == 0)
+    if (plt_entsize <= 4)
     {
         // The linker haven't set the plt_hdr->sh_entsize field. Try to guess 
the size of the plt
         // entries based on the number of entries and the size of the plt 
section with the


Index: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===================================================================
--- source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -2510,7 +2510,7 @@
     elf_xword plt_entsize = plt_hdr->sh_addralign ?
         llvm::alignTo (plt_hdr->sh_entsize, plt_hdr->sh_addralign) : plt_hdr->sh_entsize;
 
-    if (plt_entsize == 0)
+    if (plt_entsize <= 4)
     {
         // The linker haven't set the plt_hdr->sh_entsize field. Try to guess the size of the plt
         // entries based on the number of entries and the size of the plt section with the
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to