[Lldb-commits] [lldb] Add support for reading the dynamic symbol table from PT_DYNAMIC (PR #116689)
via lldb-commits
lldb-commits at lists.llvm.org
Mon Nov 18 12:20:10 PST 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff 7b525495e8574285c19188be11e7ef8a51382ff3 192cc7ba08aed0d2fe0b306be96dca50f8bd21f1 --extensions cpp,h -- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
index 6fb30e3c9d..eac9ab4577 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -22,6 +22,7 @@
#include "lldb/Host/LZMA.h"
#include "lldb/Symbol/DWARFCallFrameInfo.h"
#include "lldb/Symbol/SymbolContext.h"
+#include "lldb/Target/Process.h"
#include "lldb/Target/SectionLoadList.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/ArchSpec.h"
@@ -44,7 +45,6 @@
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/MipsABIFlags.h"
-#include "lldb/Target/Process.h"
#define CASE_AND_STREAM(s, def, width) \
case def: \
@@ -3025,10 +3025,9 @@ void ObjectFileELF::ParseSymtab(Symtab &lldb_symtab) {
GetDynsymDataFromDynamic(dynamic_num_symbols);
std::optional<DataExtractor> strtab_data = GetDynstrData();
if (symtab_data && strtab_data) {
- auto [num_symbols_parsed, address_class_map] =
- ParseSymbols(&lldb_symtab, symbol_id, section_list,
- dynamic_num_symbols, symtab_data.value(),
- strtab_data.value());
+ auto [num_symbols_parsed, address_class_map] = ParseSymbols(
+ &lldb_symtab, symbol_id, section_list, dynamic_num_symbols,
+ symtab_data.value(), strtab_data.value());
symbol_id += num_symbols_parsed;
m_address_class_map.merge(address_class_map);
}
@@ -3863,8 +3862,7 @@ ObjectFileELF::ReadDataFromDynamic(const ELFDynamic *dyn, uint64_t length,
return std::nullopt;
DataExtractor data;
addr.GetSection()->GetSectionData(data);
- return DataExtractor(data,
- d_ptr_addr - addr.GetSection()->GetFileAddress(),
+ return DataExtractor(data, d_ptr_addr - addr.GetSection()->GetFileAddress(),
length);
}
return std::nullopt;
@@ -3985,7 +3983,8 @@ std::optional<uint32_t> ObjectFileELF::GetNumSymbolsFromDynamicGnuHash() {
const addr_t buckets_offset =
sizeof(DtGnuHashHeader) + addr_size * header.bloom_size;
std::vector<uint32_t> buckets;
- if (auto bucket_data = ReadDataFromDynamic(gnu_hash, header.nbuckets * 4, buckets_offset)) {
+ if (auto bucket_data = ReadDataFromDynamic(gnu_hash, header.nbuckets * 4,
+ buckets_offset)) {
offset = 0;
for (uint32_t i = 0; i < header.nbuckets; ++i)
buckets.push_back(bucket_data->GetU32(&offset));
@@ -3999,7 +3998,9 @@ std::optional<uint32_t> ObjectFileELF::GetNumSymbolsFromDynamicGnuHash() {
// Walk the bucket's chain to add the chain length to the total.
const addr_t chains_base_offset = buckets_offset + header.nbuckets * 4;
for (;;) {
- if (auto chain_entry_data = ReadDataFromDynamic(gnu_hash, 4, chains_base_offset + (last_symbol - header.symoffset) * 4)) {
+ if (auto chain_entry_data = ReadDataFromDynamic(
+ gnu_hash, 4,
+ chains_base_offset + (last_symbol - header.symoffset) * 4)) {
offset = 0;
uint32_t chain_entry = chain_entry_data->GetU32(&offset);
++last_symbol;
diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
index 16c216eb81..41b8ce189e 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
+++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
@@ -475,7 +475,6 @@ private:
/// Get the number of symbols from the DT_GNU_HASH dynamic entry.
std::optional<uint32_t> GetNumSymbolsFromDynamicGnuHash();
-
};
#endif // LLDB_SOURCE_PLUGINS_OBJECTFILE_ELF_OBJECTFILEELF_H
``````````
</details>
https://github.com/llvm/llvm-project/pull/116689
More information about the lldb-commits
mailing list