[Lldb-commits] [lldb] r266316 - Find .plt section in object files generated by recent ld

Ulrich Weigand via lldb-commits lldb-commits at lists.llvm.org
Thu Apr 14 07:36:29 PDT 2016

Author: uweigand
Date: Thu Apr 14 09:36:29 2016
New Revision: 266316

URL: http://llvm.org/viewvc/llvm-project?rev=266316&view=rev
Find .plt section in object files generated by recent ld

Code in ObjectFileELF::ParseTrampolineSymbols assumes that the sh_info
field of the .rel(a).plt section identifies the .plt section.

However, with recent GNU ld this is no longer true.  As a result of this:
in object files generated with current linkers the sh_info field of
.rel(a).plt now points to the .got.plt section (or .got on some targets).

This causes LLDB to fail to identify any PLT stubs, causing a number of
test case failures.

This patch changes LLDB to simply always look for the .plt section by
name.  This should be safe across all linkers and targets.

Differential Revision: http://reviews.llvm.org/D18973


Modified: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp?rev=266316&r1=266315&r2=266316&view=diff
--- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp Thu Apr 14 09:36:29 2016
@@ -2611,17 +2611,17 @@ ObjectFileELF::ParseTrampolineSymbols(Sy
     assert(rel_hdr->sh_type == SHT_RELA || rel_hdr->sh_type == SHT_REL);
-    // The link field points to the associated symbol table. The info field
-    // points to the section holding the plt.
+    // The link field points to the associated symbol table.
     user_id_t symtab_id = rel_hdr->sh_link;
-    user_id_t plt_id = rel_hdr->sh_info;
     // If the link field doesn't point to the appropriate symbol name table then
     // try to find it by name as some compiler don't fill in the link fields.
     if (!symtab_id)
         symtab_id = GetSectionIndexByName(".dynsym");
-    if (!plt_id)
-        plt_id = GetSectionIndexByName(".plt");
+    // Get PLT section.  We cannot use rel_hdr->sh_info, since current linkers
+    // point that to the .got.plt or .got section instead of .plt.
+    user_id_t plt_id = GetSectionIndexByName(".plt");
     if (!symtab_id || !plt_id)
         return 0;

More information about the lldb-commits mailing list