[llvm] [llvm-symbolizer] Make symbolizer parse section relative syntax (PR #168524)
Hubert Tong via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 8 14:05:38 PDT 2026
================
@@ -807,20 +810,30 @@ Expected<DataRefImpl> XCOFFObjectFile::getSectionByNum(int16_t Num) const {
return DRI;
}
-DataRefImpl
-XCOFFObjectFile::getSectionByType(XCOFF::SectionTypeFlags SectType) const {
- DataRefImpl DRI;
- auto GetSectionAddr = [&](const auto &Sections) -> uintptr_t {
- for (const auto &Sec : Sections)
- if (Sec.getSectionType() == SectType)
- return reinterpret_cast<uintptr_t>(&Sec);
- return uintptr_t(0);
+Expected<DataRefImpl>
+XCOFFObjectFile::getSectionByType(XCOFF::SectionTypeFlags SectType,
+ StringRef SectionTypeName) const {
+ DataRefImpl Result;
+ Result.p = 0;
+ auto FindSection = [&](const auto &Sections) -> Error {
+ for (const auto &Sec : Sections) {
+ if (Sec.getSectionType() == SectType) {
+ if (Result.p != 0) {
+ if (!SectionTypeName.empty())
+ return createStringError("multiple '" + SectionTypeName.str() +
----------------
hubert-reinterpretcast wrote:
> Why is it a problem to have multiple matching sections now, when it wasn't for the original usage of this function?
In the original usage, the section types involved could not be present more than once in a well-formed XCOFF file. In the new usage, we should be uniquely identifying a section using the type; however, the section types involved may be present more than once in a well-formed XCOFF file, albeit not in a loadable one.
https://github.com/llvm/llvm-project/pull/168524
More information about the llvm-commits
mailing list