[lld] [clang] [llvm] Support .note.gnu.property for enable Zicfiss and Zicfilp extension (PR #77414)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 8 22:16:54 PST 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff 2bc93584f5193d78177273c45c82ea69675f44e7 478e5c7c91e7d28448f1e64affcfcc3c28db9106 -- clang/test/Preprocessor/riscv-target-features.c lld/ELF/Config.h lld/ELF/Driver.cpp lld/ELF/InputFiles.cpp lld/ELF/SyntheticSections.cpp llvm/include/llvm/BinaryFormat/ELF.h llvm/lib/Support/RISCVISAInfo.cpp llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.h llvm/lib/Target/RISCV/RISCVFrameLowering.cpp llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp llvm/tools/llvm-readobj/ELFDumper.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index 324e0704f78..3a6513b6aca 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -2653,7 +2653,7 @@ static uint32_t getAndFeatures() {
features |= GNU_PROPERTY_RISCV_FEATURE_1_ZICFILP;
if (config->zZicfilpReport == "none")
warn(toString(f) + ": -z force-zicfilp: file does not have "
- "GNU_PROPERTY_RISCV_FEATURE_1_ZICFILP property");
+ "GNU_PROPERTY_RISCV_FEATURE_1_ZICFILP property");
}
if (config->zForceZicfiss &&
@@ -2661,7 +2661,7 @@ static uint32_t getAndFeatures() {
features |= GNU_PROPERTY_RISCV_FEATURE_1_ZICFISS;
if (config->zZicfissReport == "none")
warn(toString(f) + ": -z force-zicfiss: file does not have "
- "GNU_PROPERTY_RISCV_FEATURE_1_ZICFISS property");
+ "GNU_PROPERTY_RISCV_FEATURE_1_ZICFISS property");
}
if (config->zPacPlt && !(features & GNU_PROPERTY_AARCH64_FEATURE_1_PAC)) {
diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index 93c623919e4..e55810ead5d 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -315,16 +315,16 @@ GnuPropertySection::GnuPropertySection()
void GnuPropertySection::writeTo(uint8_t *buf) {
uint32_t featureAndType = 0;
- switch(config->emachine) {
- default:
- featureAndType = GNU_PROPERTY_X86_FEATURE_1_AND;
- break;
- case EM_AARCH64:
- featureAndType = GNU_PROPERTY_AARCH64_FEATURE_1_AND;
- break;
- case EM_RISCV:
- featureAndType = GNU_PROPERTY_RISCV_FEATURE_1_AND;
- break;
+ switch (config->emachine) {
+ default:
+ featureAndType = GNU_PROPERTY_X86_FEATURE_1_AND;
+ break;
+ case EM_AARCH64:
+ featureAndType = GNU_PROPERTY_AARCH64_FEATURE_1_AND;
+ break;
+ case EM_RISCV:
+ featureAndType = GNU_PROPERTY_RISCV_FEATURE_1_AND;
+ break;
}
write32(buf, 4); // Name size
diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp
index c82b62bbd77..28477aaf240 100644
--- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp
+++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp
@@ -83,7 +83,8 @@ void RISCVTargetELFStreamer::emitNoteSection(unsigned Flags) {
MCStreamer &OutStreamer = getStreamer();
MCContext &Context = OutStreamer.getContext();
- MCSectionELF *Nt = Context.getELFSection(".note.gnu.property", ELF::SHT_NOTE, ELF::SHF_ALLOC);
+ MCSectionELF *Nt = Context.getELFSection(".note.gnu.property", ELF::SHT_NOTE,
+ ELF::SHF_ALLOC);
MCSection *Cur = OutStreamer.getCurrentSectionOnly();
OutStreamer.switchSection(Nt);
@@ -92,10 +93,11 @@ void RISCVTargetELFStreamer::emitNoteSection(unsigned Flags) {
OutStreamer.emitIntValue(4, 4); // data size for note name
OutStreamer.emitIntValue(4 * 4, 4); // data size
OutStreamer.emitIntValue(ELF::NT_GNU_PROPERTY_TYPE_0, 4); // note type
- OutStreamer.emitBytes(StringRef("GNU", 4)); // note name
+ OutStreamer.emitBytes(StringRef("GNU", 4)); // note name
// Emit the CFI(ZICFILP/ZICFISS) properties.
- OutStreamer.emitIntValue(ELF::GNU_PROPERTY_RISCV_FEATURE_1_AND, 4); // and property
+ OutStreamer.emitIntValue(ELF::GNU_PROPERTY_RISCV_FEATURE_1_AND,
+ 4); // and property
OutStreamer.emitIntValue(4, 4); // data size
OutStreamer.emitIntValue(Flags, 4); // data
OutStreamer.emitIntValue(0, 4); // pad
diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp
index a20f836b6ce..212db3b03db 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -5241,7 +5241,8 @@ static std::string getGNUProperty(uint32_t Type, uint32_t DataSize,
}
template <typename ELFT>
-static SmallVector<std::string, 4> getGNUPropertyList(ArrayRef<uint8_t> Arr, uint16_t Target) {
+static SmallVector<std::string, 4> getGNUPropertyList(ArrayRef<uint8_t> Arr,
+ uint16_t Target) {
using Elf_Word = typename ELFT::Word;
SmallVector<std::string, 4> Properties;
@@ -5259,8 +5260,8 @@ static SmallVector<std::string, 4> getGNUPropertyList(ArrayRef<uint8_t> Arr, uin
Properties.push_back(OS.str());
break;
}
- Properties.push_back(
- getGNUProperty<ELFT>(Type, DataSize, Arr.take_front(PaddedSize), Target));
+ Properties.push_back(getGNUProperty<ELFT>(
+ Type, DataSize, Arr.take_front(PaddedSize), Target));
Arr = Arr.drop_front(PaddedSize);
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/77414
More information about the cfe-commits
mailing list