[llvm] [RISCV] Let -data-sections also work on sbss/sdata sections (PR #87040)
Sam Elliott via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 21 08:52:37 PDT 2024
================
@@ -104,10 +104,34 @@ bool RISCVELFTargetObjectFile::isGlobalInSmallSection(
MCSection *RISCVELFTargetObjectFile::SelectSectionForGlobal(
const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
// Handle Small Section classification here.
- if (Kind.isBSS() && isGlobalInSmallSection(GO, TM))
- return SmallBSSSection;
- if (Kind.isData() && isGlobalInSmallSection(GO, TM))
- return SmallDataSection;
+ if (isGlobalInSmallSection(GO, TM)) {
+ // Emit to an unique sdata/sbss section when -fdata-section is set.
+ // However, if a symbol has an explicit sdata/sbss section, place it in that
+ // section.
+ bool EmitUniquedSection = TM.getDataSections() && !GO->hasSection();
----------------
lenary wrote:
I think this is still wrong, and that the `!GO->hasSection()` check needs to take priority over the `isGlobalInSmallSection` - I noted in the test where I think things will still go wrong.
https://github.com/llvm/llvm-project/pull/87040
More information about the llvm-commits
mailing list