-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[lldb] SHT_NOBITS sections type #99044
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write If you have received no comments on your PR for a week, you can request a review If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
@llvm/pr-subscribers-lldb Author: None (dlav-sc) Changes.sbss section was recognized as eSectionTypeOther, but has to be eSectionTypeZeroFill. Fixed tests for RISCV target: TestClassLoadingViaMemberTypedef.TestCase Full diff: https://github.com/llvm/llvm-project/pull/99044.diff 1 Files Affected:
diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
index 51bd34e95c77d..42130e98d5414 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -1696,7 +1696,7 @@ static SectionType GetSectionTypeFromName(llvm::StringRef Name) {
return llvm::StringSwitch<SectionType>(Name)
.Case(".ARM.exidx", eSectionTypeARMexidx)
.Case(".ARM.extab", eSectionTypeARMextab)
- .Cases(".bss", ".tbss", eSectionTypeZeroFill)
+ .Cases(".bss", ".tbss", ".sbss", eSectionTypeZeroFill)
.Case(".ctf", eSectionTypeDebug)
.Cases(".data", ".tdata", eSectionTypeData)
.Case(".eh_frame", eSectionTypeEHFrame)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if there's a more fundamental fix to be made here. Like perhaps treating treating any allocatable SHT_NOBITS section as ZeroFill.
Basically to add case SHT_NOBITS: if (H.sh_flags & SHF_ALLOC) return eSectionTypeZeroFill;
to GetSectionType
(line 1716)
2bca628
to
2b62658
Compare
Sections with SHT_NOBITS type should be recognized as eSectionTypeZeroFill.
Yes, thanks, works fine. |
I have also removed To be honest, I'm not sure about that. .bss and .tbss have SHT_NOBITS type and SHF_ALLOC flag by Linux Specification, but anyway I have doubts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have also removed
.Cases(".bss", ".tbss", eSectionTypeZeroFill)
.To be honest, I'm not sure about that. .bss and .tbss have SHT_NOBITS type and SHF_ALLOC flag by Linux Specification, but anyway I have doubts.
I know what you mean -- you can find very strange elf files out there. However, most elf tools operate on section flags (that's what they're for) and not their names, so I really doubt that e.g. treating a SHT_PROGBITS+SHF_ALLOC section that happens to be called ".bss" as eSectionTypeZeroFill
is the right behavior.
So, until proven otherwise, this looks good to me.
Well, sounds reasonable. |
You're welcome. BTW, are you able to push the merge button, or do you need someone to do that for you? |
No, I don't have permissions. Can you merge it yourself? |
sure thing. |
@dlav-sc Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested Please check whether problems have been caused by your change specifically, as How to do this, and the rest of the post-merge process, is covered in detail here. If your change does cause a problem, it may be reverted, or you can revert it yourself. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! |
Summary: .sbss section was recognized as eSectionTypeOther, but has to be eSectionTypeZeroFill. Fixed tests for RISCV target: TestClassLoadingViaMemberTypedef.TestCase TestClassTemplateNonTypeParameterPack.TestCaseClassTemplateNonTypeParameterPack TestThreadSelectionBug.TestThreadSelectionBug lldbsuite.test.lldbtest.TestOffsetof lldbsuite.test.lldbtest.TestOffsetofCpp TestTargetDumpTypeSystem.TestCase TestCPP11EnumTypes.CPP11EnumTypesTestCase TestCppIsTypeComplete.TestCase TestExprCrash.ExprCrashTestCase TestDebugIndexCache.DebugIndexCacheTestcase Test Plan: Reviewers: Subscribers: Tasks: Tags: Differential Revision: https://phabricator.intern.facebook.com/D60251404
.sbss section was recognized as eSectionTypeOther, but has to be eSectionTypeZeroFill.
Fixed tests for RISCV target:
TestClassLoadingViaMemberTypedef.TestCase
TestClassTemplateNonTypeParameterPack.TestCaseClassTemplateNonTypeParameterPack TestThreadSelectionBug.TestThreadSelectionBug
lldbsuite.test.lldbtest.TestOffsetof
lldbsuite.test.lldbtest.TestOffsetofCpp
TestTargetDumpTypeSystem.TestCase
TestCPP11EnumTypes.CPP11EnumTypesTestCase
TestCppIsTypeComplete.TestCase
TestExprCrash.ExprCrashTestCase
TestDebugIndexCache.DebugIndexCacheTestcase