[clang] 4aa1cad - [Driver] Disable -fsanitize=function for ppc64be after D148573

Fangrui Song via cfe-commits cfe-commits at lists.llvm.org
Sun May 21 09:14:45 PDT 2023


Author: Fangrui Song
Date: 2023-05-21T09:14:40-07:00
New Revision: 4aa1cadf3c67c61b394051630896f06f35b562ca

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

LOG: [Driver] Disable -fsanitize=function for ppc64be after D148573

ELFObjectWriter.cpp may report
```
error: Cannot represent a difference across sections
```
on some ppc64be configurations, likely related to some interaction
between the obsoleted ELFv1 and MC.
Unfortunately I cannot reproduce this locally with --target=powerpc64-linux-gnu.

Added: 
    

Modified: 
    clang/lib/Driver/ToolChains/Linux.cpp
    compiler-rt/test/ubsan/TestCases/TypeCheck/Function/function.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp
index d416c287f8a2d..853ff99d9fe59 100644
--- a/clang/lib/Driver/ToolChains/Linux.cpp
+++ b/clang/lib/Driver/ToolChains/Linux.cpp
@@ -806,6 +806,9 @@ SanitizerMask Linux::getSupportedSanitizers() const {
   if (IsX86_64 || IsAArch64) {
     Res |= SanitizerKind::KernelHWAddress;
   }
+  // Work around "Cannot represent a 
diff erence across sections".
+  if (getTriple().getArch() == llvm::Triple::ppc64)
+    Res &= ~SanitizerKind::Function;
   return Res;
 }
 

diff  --git a/compiler-rt/test/ubsan/TestCases/TypeCheck/Function/function.cpp b/compiler-rt/test/ubsan/TestCases/TypeCheck/Function/function.cpp
index 2f7db994364ca..645ec3c8c6d76 100644
--- a/compiler-rt/test/ubsan/TestCases/TypeCheck/Function/function.cpp
+++ b/compiler-rt/test/ubsan/TestCases/TypeCheck/Function/function.cpp
@@ -1,3 +1,6 @@
+// Work around "Cannot represent a 
diff erence across sections"
+// UNSUPPORTED: target=powerpc64-{{.*}}
+
 // RUN: %clangxx -DDETERMINE_UNIQUE %s -o %t-unique
 // RUN: %clangxx -std=c++17 -fsanitize=function %s -O3 -g -DSHARED_LIB -fPIC -shared -o %t-so.so
 // RUN: %clangxx -std=c++17 -fsanitize=function %s -O3 -g -o %t %t-so.so


        


More information about the cfe-commits mailing list