[llvm] e83e8e2 - [MC] Restore default section classification to SectionKind::getReadOnly()

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 9 13:28:54 PDT 2023


Author: Fangrui Song
Date: 2023-08-09T13:28:49-07:00
New Revision: e83e8e271169f06e78cd1b6c2bab5e2926f29ff1

URL: https://github.com/llvm/llvm-project/commit/e83e8e271169f06e78cd1b6c2bab5e2926f29ff1
DIFF: https://github.com/llvm/llvm-project/commit/e83e8e271169f06e78cd1b6c2bab5e2926f29ff1.diff

LOG: [MC] Restore default section classification to SectionKind::getReadOnly()

D133456 changed the default `Kind = SectionKind::getReadOnly();` to
`SectionKind::getText()` to work around a longstanding issue in producing
R_RISCV_{ADD,SUB}* relocations.

D155357 properly fixed the issue and the workaround is no longer needed.
getReadonly() actually matches BFD better as BFD doesn't set SEC_CODE to
a not-well-known section.

To the best of my knowledge, this change is un-testable after D155357
removed a `getKind().isText()` use.

Added: 
    

Modified: 
    llvm/lib/MC/MCContext.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp
index c443f46e024287..a1dde3e1fecbdc 100644
--- a/llvm/lib/MC/MCContext.cpp
+++ b/llvm/lib/MC/MCContext.cpp
@@ -592,7 +592,7 @@ MCSectionELF *MCContext::getELFSection(const Twine &Section, unsigned Type,
                .StartsWith(".gnu.linkonce.td.", SectionKind::getThreadData())
                .StartsWith(".llvm.linkonce.td.", SectionKind::getThreadData())
                .StartsWith(".debug_", SectionKind::getMetadata())
-               .Default(SectionKind::getText());
+               .Default(SectionKind::getReadOnly());
 
   MCSectionELF *Result =
       createELFSectionImpl(CachedName, Type, Flags, Kind, EntrySize, GroupSym,


        


More information about the llvm-commits mailing list