[llvm] f305006 - [X32][CET] Fix size and alignment of .note.gnu.property section

Harald van Dijk via llvm-commits llvm-commits at lists.llvm.org
Sat May 1 14:17:29 PDT 2021


Author: Harald van Dijk
Date: 2021-05-01T22:17:04+01:00
New Revision: f30500632b299a8f8f8a53f06efb1038eb7fa48d

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

LOG: [X32][CET] Fix size and alignment of .note.gnu.property section

X32 uses 32-bit ELF object files with 32-bit alignment, so the
.note.gnu.property section needs to be emitted as it is for X86.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D101689

Added: 
    

Modified: 
    llvm/lib/Target/X86/X86AsmPrinter.cpp
    llvm/test/CodeGen/X86/note-cet-property.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/X86/X86AsmPrinter.cpp b/llvm/lib/Target/X86/X86AsmPrinter.cpp
index 7205d03b41a4..59b4260cf3ce 100644
--- a/llvm/lib/Target/X86/X86AsmPrinter.cpp
+++ b/llvm/lib/Target/X86/X86AsmPrinter.cpp
@@ -643,7 +643,8 @@ void X86AsmPrinter::emitStartOfAsmFile(Module &M) {
       OutStreamer->SwitchSection(Nt);
 
       // Emitting note header.
-      int WordSize = TT.isArch64Bit() ? 8 : 4;
+      const int WordSize =
+          TT.isArch64Bit() && TT.getEnvironment() != Triple::GNUX32 ? 8 : 4;
       emitAlignment(WordSize == 4 ? Align(4) : Align(8));
       OutStreamer->emitIntValue(4, 4 /*size*/); // data size for "GNU\0"
       OutStreamer->emitIntValue(8 + WordSize, 4 /*size*/); // Elf_Prop size

diff  --git a/llvm/test/CodeGen/X86/note-cet-property.ll b/llvm/test/CodeGen/X86/note-cet-property.ll
index f3cc32b65dc3..ea5ec9609d2f 100644
--- a/llvm/test/CodeGen/X86/note-cet-property.ll
+++ b/llvm/test/CodeGen/X86/note-cet-property.ll
@@ -1,5 +1,6 @@
 ; RUN: llc -mtriple i686-pc-linux < %s | FileCheck %s --check-prefix=X86
 ; RUN: llc -mtriple x86_64-pc-linux < %s | FileCheck %s --check-prefix=X86_64
+; RUN: llc -mtriple x86_64-pc-linux-gnux32 < %s | FileCheck %s --check-prefix=X86
 
 ; This test checks that the compiler emits a .note.gnu.property section for
 ; modules with "cf-protection" module flags.


        


More information about the llvm-commits mailing list