[Lldb-commits] [PATCH] D19252: Handle invalid values of PLT entry size generated by ld + gcc on arm linux targets.

Muhammad Omair Javaid via lldb-commits lldb-commits at lists.llvm.org
Mon Apr 18 18:30:25 PDT 2016


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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19252.54146.patch
Type: text/x-patch
Size: 647 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20160419/9555358c/attachment.bin>


More information about the lldb-commits mailing list