[PATCH] D133456: [V2] MC: make section classification a bit more thorough
Saleem Abdulrasool via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 12 09:28:21 PDT 2022
compnerd updated this revision to Diff 459488.
compnerd marked 3 inline comments as done.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D133456/new/
https://reviews.llvm.org/D133456
Files:
llvm/lib/MC/MCContext.cpp
llvm/test/MC/ELF/section-classification.ll
Index: llvm/test/MC/ELF/section-classification.ll
===================================================================
--- /dev/null
+++ llvm/test/MC/ELF/section-classification.ll
@@ -0,0 +1,15 @@
+; We run this test explicitly converting from `.ll` to `.s` to `.o` to test the
+; classification of the section and the incorrect handling for the padding flag.
+
+; RUN: llc -filetype asm -o - %s | llvm-mc -triple x86_64-unknown-linux-gnu -filetype obj -o /dev/null -
+; REQUIRES: asserts
+
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+%struct.C = type { i32 }
+
+$_ZZ6getRefvE8instance = comdat any
+
+ at _ZZ6getRefvE8instance = linkonce_odr dso_local global %struct.C zeroinitializer, comdat, align 4
+ at llvm.compiler.used = appending global [1 x ptr] [ptr @_ZZ6getRefvE8instance], section "llvm.metadata"
Index: llvm/lib/MC/MCContext.cpp
===================================================================
--- llvm/lib/MC/MCContext.cpp
+++ llvm/lib/MC/MCContext.cpp
@@ -564,8 +564,27 @@
Kind = SectionKind::getExecuteOnly();
else if (Flags & ELF::SHF_EXECINSTR)
Kind = SectionKind::getText();
- else
+ else if (!(Flags & ELF::SHF_WRITE))
Kind = SectionKind::getReadOnly();
+ else if (Flags & ELF::SHF_TLS)
+ Kind = (Type & ELF::SHT_NOBITS) ? SectionKind::getThreadBSS()
+ : SectionKind::getThreadData();
+ else
+ Kind = llvm::StringSwitch<SectionKind>(CachedName)
+ .Case(".bss", SectionKind::getBSS())
+ .StartsWith(".bss.", SectionKind::getBSS())
+ .Case(".data", SectionKind::getData())
+ .Case(".data1", SectionKind::getData())
+ .Case(".data.rel.ro", SectionKind::getReadOnlyWithRel())
+ .StartsWith(".data.rel.ro.", SectionKind::getReadOnlyWithRel())
+ .Case(".rodata", SectionKind::getReadOnly())
+ .Case(".rodata1", SectionKind::getReadOnly())
+ .Case(".tbss", SectionKind::getThreadBSS())
+ .StartsWith(".tbss.", SectionKind::getThreadData())
+ .Case(".tdata", SectionKind::getThreadData())
+ .StartsWith(".tdata.", SectionKind::getThreadData())
+ .StartsWith(".debug_", SectionKind::getMetadata())
+ .Default(SectionKind::getText());
MCSectionELF *Result =
createELFSectionImpl(CachedName, Type, Flags, Kind, EntrySize, GroupSym,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133456.459488.patch
Type: text/x-patch
Size: 2506 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220912/641ced4d/attachment.bin>
More information about the llvm-commits
mailing list