Skip to content

[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

Merged
merged 1 commit into from
Jul 19, 2024

Conversation

dlav-sc
Copy link
Contributor

@dlav-sc dlav-sc commented Jul 16, 2024

.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

@dlav-sc dlav-sc requested a review from JDevlieghere as a code owner July 16, 2024 13:39
Copy link

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be
notified.

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
permissions for the repository. In which case you can instead tag reviewers by
name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review
by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate
is once a week. Please remember that you are asking for valuable time from other developers.

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.

@llvmbot llvmbot added the lldb label Jul 16, 2024
@llvmbot
Copy link
Member

llvmbot commented Jul 16, 2024

@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
TestClassTemplateNonTypeParameterPack.TestCaseClassTemplateNonTypeParameterPack TestThreadSelectionBug.TestThreadSelectionBug
lldbsuite.test.lldbtest.TestOffsetof
lldbsuite.test.lldbtest.TestOffsetofCpp
TestTargetDumpTypeSystem.TestCase
TestCPP11EnumTypes.CPP11EnumTypesTestCase
TestCppIsTypeComplete.TestCase
TestExprCrash.ExprCrashTestCase
TestDebugIndexCache.DebugIndexCacheTestcase


Full diff: https://github.com/llvm/llvm-project/pull/99044.diff

1 Files Affected:

  • (modified) lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (+1-1)
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)

Copy link
Collaborator

@labath labath left a 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)

@dlav-sc dlav-sc force-pushed the origin/dlav-sc/sbss-section-type branch 2 times, most recently from 2bca628 to 2b62658 Compare July 18, 2024 01:30
Sections with SHT_NOBITS type should be recognized as eSectionTypeZeroFill.
@dlav-sc
Copy link
Contributor Author

dlav-sc commented Jul 18, 2024

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)

Yes, thanks, works fine.

@dlav-sc dlav-sc changed the title [lldb] change .sbss section type to eSectionTypeZeroFill [lldb] SHT_NOBITS sections type Jul 18, 2024
@dlav-sc
Copy link
Contributor Author

dlav-sc commented Jul 18, 2024

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.

Copy link
Collaborator

@labath labath left a 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.

@dlav-sc
Copy link
Contributor Author

dlav-sc commented Jul 19, 2024

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.
Thanks for the review.

@labath
Copy link
Collaborator

labath commented Jul 19, 2024

You're welcome. BTW, are you able to push the merge button, or do you need someone to do that for you?

@dlav-sc
Copy link
Contributor Author

dlav-sc commented Jul 19, 2024

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?

@labath
Copy link
Collaborator

labath commented Jul 19, 2024

sure thing.

@labath labath merged commit fdfc491 into llvm:main Jul 19, 2024
6 checks passed
Copy link

@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
by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR.

Please check whether problems have been caused by your change specifically, as
the builds can include changes from many authors. It is not uncommon for your
change to be included in a build that fails due to someone else's changes, or
infrastructure issues.

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.
This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again.

If you don't get any reports, no action is required from you. Your changes are working as expected, well done!

yuxuanchen1997 pushed a commit that referenced this pull request Jul 25, 2024
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants