[Lldb-commits] [lldb] [LLDB][ELF] Fix section unification to not just use names. (PR #90099)
via lldb-commits
lldb-commits at lists.llvm.org
Thu Apr 25 11:03:35 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 f5953f46aa0a664461584b78c14cb141a3be2b9d ce54a7fb339a00029da266c9f518e344aac5d19e -- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
``````````
</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 60fc68c96b..80be674f76 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -1855,47 +1855,44 @@ public:
}
namespace {
- // We have to do this because ELF doesn't have section IDs, and also
- // doesn't require section names to be unique. (We use the section index
- // for section IDs, but that isn't guaranteed to be the same in separate
- // debug images.)
- SectionSP FindMatchingSection(const SectionList §ion_list,
- SectionSP section) {
- SectionSP sect_sp;
-
- addr_t vm_addr = section->GetFileAddress();
- ConstString name = section->GetName();
- offset_t file_size = section->GetFileSize();
- offset_t byte_size = section->GetByteSize();
- SectionType type = section->GetType();
- bool thread_specific = section->IsThreadSpecific();
- uint32_t permissions = section->GetPermissions();
- uint32_t alignment = section->GetLog2Align();
-
- for (auto sect_iter = section_list.begin();
- sect_iter != section_list.end();
- ++sect_iter) {
- if ((*sect_iter)->GetName() == name
- && (*sect_iter)->GetType() == type
- && (*sect_iter)->IsThreadSpecific() == thread_specific
- && (*sect_iter)->GetPermissions() == permissions
- && (*sect_iter)->GetFileSize() == file_size
- && (*sect_iter)->GetByteSize() == byte_size
- && (*sect_iter)->GetFileAddress() == vm_addr
- && (*sect_iter)->GetLog2Align() == alignment) {
- sect_sp = *sect_iter;
+// We have to do this because ELF doesn't have section IDs, and also
+// doesn't require section names to be unique. (We use the section index
+// for section IDs, but that isn't guaranteed to be the same in separate
+// debug images.)
+SectionSP FindMatchingSection(const SectionList §ion_list,
+ SectionSP section) {
+ SectionSP sect_sp;
+
+ addr_t vm_addr = section->GetFileAddress();
+ ConstString name = section->GetName();
+ offset_t file_size = section->GetFileSize();
+ offset_t byte_size = section->GetByteSize();
+ SectionType type = section->GetType();
+ bool thread_specific = section->IsThreadSpecific();
+ uint32_t permissions = section->GetPermissions();
+ uint32_t alignment = section->GetLog2Align();
+
+ for (auto sect_iter = section_list.begin(); sect_iter != section_list.end();
+ ++sect_iter) {
+ if ((*sect_iter)->GetName() == name && (*sect_iter)->GetType() == type &&
+ (*sect_iter)->IsThreadSpecific() == thread_specific &&
+ (*sect_iter)->GetPermissions() == permissions &&
+ (*sect_iter)->GetFileSize() == file_size &&
+ (*sect_iter)->GetByteSize() == byte_size &&
+ (*sect_iter)->GetFileAddress() == vm_addr &&
+ (*sect_iter)->GetLog2Align() == alignment) {
+ sect_sp = *sect_iter;
+ break;
+ } else {
+ sect_sp = FindMatchingSection((*sect_iter)->GetChildren(), section);
+ if (sect_sp)
break;
- } else {
- sect_sp = FindMatchingSection((*sect_iter)->GetChildren(),
- section);
- if (sect_sp)
- break;
- }
}
-
- return sect_sp;
}
+
+ return sect_sp;
}
+} // namespace
void ObjectFileELF::CreateSections(SectionList &unified_section_list) {
if (m_sections_up)
@@ -2318,12 +2315,11 @@ unsigned ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t start_id,
module_section_list != section_list) {
auto section_it = section_map.find(symbol_section_sp);
if (section_it == section_map.end()) {
- section_it =
- section_map
- .emplace(symbol_section_sp,
- FindMatchingSection(*module_section_list,
- symbol_section_sp))
- .first;
+ section_it = section_map
+ .emplace(symbol_section_sp,
+ FindMatchingSection(*module_section_list,
+ symbol_section_sp))
+ .first;
}
if (section_it->second)
symbol_section_sp = section_it->second;
``````````
</details>
https://github.com/llvm/llvm-project/pull/90099
More information about the lldb-commits
mailing list