summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
diff options
context:
space:
mode:
authorDimitar Vlahovski <dvlahovski@google.com>2016-07-29 13:18:09 +0000
committerDimitar Vlahovski <dvlahovski@google.com>2016-07-29 13:18:09 +0000
commit023dd64f256a3762569aca994f0ac0d12dbfeb31 (patch)
treec11671c55b225fba793020d350c946481a8e9a5c /lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
parente768c4b858bd32b814baf142dd2acfeae6022638 (diff)
downloadbcm5719-llvm-023dd64f256a3762569aca994f0ac0d12dbfeb31.tar.gz
bcm5719-llvm-023dd64f256a3762569aca994f0ac0d12dbfeb31.zip
Add/fix support for i386 elf core files
Summary: There were places in the code, assuming(hardcoding) offsets and types that were only valid for the x86_64 elf core file format. The NT_PRSTATUS and NT_PRPSINFO structures are with the 64 bit layout. I have reused them and parse i386 files manually, and fill them in the same struct. Also added some error handling during parsing that checks if the available bytes in the buffer are enough to fill the structures. The i386 core file test case now passes. For reference on the structures layout, I generally used the source of binutils (bfd, readelf) Bug: https://llvm.org/bugs/show_bug.cgi?id=26947 Reviewers: labath Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D22917 llvm-svn: 277140
Diffstat (limited to 'lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp')
-rw-r--r--lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
index fc43c460156..e6af68fdb01 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -1479,7 +1479,7 @@ ObjectFileELF::RefineModuleDetailsFromNote (lldb_private::DataExtractor &data, l
else if (note.n_name == LLDB_NT_OWNER_CORE)
{
// Parse the NT_FILE to look for stuff in paths to shared libraries
- // As the contents look like:
+ // As the contents look like this in a 64 bit ELF core file:
// count = 0x000000000000000a (10)
// page_size = 0x0000000000001000 (4096)
// Index start end file_ofs path
@@ -1494,14 +1494,24 @@ ObjectFileELF::RefineModuleDetailsFromNote (lldb_private::DataExtractor &data, l
// [ 7] 0x00007fa79cdb2000 0x00007fa79cdd5000 0x0000000000000000 /lib/x86_64-linux-gnu/ld-2.19.so
// [ 8] 0x00007fa79cfd4000 0x00007fa79cfd5000 0x0000000000000022 /lib/x86_64-linux-gnu/ld-2.19.so
// [ 9] 0x00007fa79cfd5000 0x00007fa79cfd6000 0x0000000000000023 /lib/x86_64-linux-gnu/ld-2.19.so
+ // In the 32 bit ELFs the count, page_size, start, end, file_ofs are uint32_t
+ // For reference: see readelf source code (in binutils).
if (note.n_type == NT_FILE)
{
- uint64_t count = data.GetU64(&offset);
- offset += 8 + 3*8*count; // Skip page size and all start/end/file_ofs
+ uint64_t count = data.GetAddress(&offset);
+ const char *cstr;
+ data.GetAddress(&offset); // Skip page size
+ offset += count * 3 * data.GetAddressByteSize(); // Skip all start/end/file_ofs
for (size_t i=0; i<count; ++i)
{
- llvm::StringRef path(data.GetCStr(&offset));
- if (path.startswith("/lib/x86_64-linux-gnu"))
+ cstr = data.GetCStr(&offset);
+ if(cstr == nullptr)
+ {
+ error.SetErrorStringWithFormat("ObjectFileELF::%s trying to read at an offset after the end (GetCStr returned nullptr)", __FUNCTION__);
+ return error;
+ }
+ llvm::StringRef path(cstr);
+ if (path.startswith("/lib/x86_64-linux-gnu") || path.startswith("/lib/i386-linux-gnu"))
{
arch_spec.GetTriple().setOS(llvm::Triple::OSType::Linux);
break;
OpenPOWER on IntegriCloud