[Lldb-commits] [lldb] Add support for reading the dynamic symbol table from PT_DYNAMIC (PR #112596)
via lldb-commits
lldb-commits at lists.llvm.org
Wed Oct 16 11:47:00 PDT 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 6558e5615ae9e6af6168b0a363808854fd66663f 890d2bcf655a2e1e58b025cc0df7b4e42956e4c6 --extensions h,cpp -- 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 7374ac10a1..65d54a9251 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,8 +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: \
@@ -3015,7 +3014,7 @@ void ObjectFileELF::ParseSymtab(Symtab &lldb_symtab) {
if (symtab_data && strtab_data) {
auto [num_symbols_parsed, address_class_map] =
ParseSymbols(&lldb_symtab, symbol_id, section_list, num_symbols,
- symtab_data.value(), strtab_data.value());
+ symtab_data.value(), strtab_data.value());
symbol_id += num_symbols_parsed;
m_address_class_map.merge(address_class_map);
}
@@ -3849,8 +3848,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;
@@ -3925,7 +3923,6 @@ std::optional<lldb_private::DataExtractor> ObjectFileELF::GetDynamicData() {
return std::nullopt;
}
-
std::optional<DataExtractor>
ObjectFileELF::GetDynsymDataFromDynamic(uint32_t &num_symbols) {
// Every ELF file which represents an executable or shared library has
@@ -3988,7 +3985,8 @@ ObjectFileELF::GetDynsymDataFromDynamic(uint32_t &num_symbols) {
const addr_t buckets_offset =
sizeof(DT_GNU_HASH_HEADER) + 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));
@@ -4000,9 +3998,13 @@ ObjectFileELF::GetDynsymDataFromDynamic(uint32_t &num_symbols) {
num_symbols = header.symoffset;
} else {
// Walk the bucket's chain to add the chain length to the total.
- const addr_t chains_base_offset = buckets_offset + header.nbuckets * 4;
+ 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 34d9ae74fb..bc20f1aea9 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
+++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
@@ -447,13 +447,13 @@ private:
///
/// \param[in] length The number of bytes to read.
///
- /// \param[in] offset The number of bytes to skip after the d_ptr value
+ /// \param[in] offset The number of bytes to skip after the d_ptr value
/// before reading data.
///
- /// \return The bytes that represent the dynanic entries data or
+ /// \return The bytes that represent the dynanic entries data or
/// \c std::nullopt if an error occured or the data is not available.
- std::optional<lldb_private::DataExtractor>
- ReadDataFromDynamic(const elf::ELFDynamic *dyn, uint64_t length,
+ std::optional<lldb_private::DataExtractor>
+ ReadDataFromDynamic(const elf::ELFDynamic *dyn, uint64_t length,
uint64_t offset = 0);
/// Get the bytes that represent the dynamic symbol table from the .dynamic
@@ -461,13 +461,13 @@ private:
///
/// This functon uses the DT_SYMTAB value from the .dynamic section to read
/// the symbols table data from process memory. The number of symbols in the
- /// symbol table is calculated by looking at the DT_HASH or DT_GNU_HASH
+ /// symbol table is calculated by looking at the DT_HASH or DT_GNU_HASH
/// values as the symbol count isn't stored in the .dynamic section.
///
/// \return The bytes that represent the symbol table data from the .dynamic
- /// section or section headers or \c std::nullopt if an error
+ /// section or section headers or \c std::nullopt if an error
/// occured or if there is no dynamic symbol data available.
- std::optional<lldb_private::DataExtractor>
+ std::optional<lldb_private::DataExtractor>
GetDynsymDataFromDynamic(uint32_t &num_symbols);
};
``````````
</details>
https://github.com/llvm/llvm-project/pull/112596
More information about the lldb-commits
mailing list