[llvm] [RISCV] Let -data-sections also work on sbss/sdata sections (PR #87040)
Petr Hosek via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 18 17:36:17 PDT 2024
================
@@ -104,10 +104,36 @@ 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 a unique section for sdata/sbss when -fdata-section.
+ bool EmitUniquedSection = TM.getDataSections();
+
+ if (Kind.isBSS()) {
+ if (EmitUniquedSection) {
+ StringRef Prefix(".sbss");
+ SmallString<128> Name(Prefix);
+ Name.append(".");
----------------
petrhosek wrote:
```suggestion
SmallString<128> Name(".sbss.");
```
https://github.com/llvm/llvm-project/pull/87040
More information about the llvm-commits
mailing list