diff --git a/clang/lib/Driver/ToolChains/HIPUtility.cpp b/clang/lib/Driver/ToolChains/HIPUtility.cpp index 04efdcba20ea7..f692458b775de 100644 --- a/clang/lib/Driver/ToolChains/HIPUtility.cpp +++ b/clang/lib/Driver/ToolChains/HIPUtility.cpp @@ -150,6 +150,8 @@ void HIP::constructGenerateObjFileFromHIPFatBinary( ObjStream << " .incbin "; llvm::sys::printArg(ObjStream, BundleFile, /*Quote=*/true); ObjStream << "\n"; + if (HostTriple.isOSLinux() && HostTriple.isOSBinFormatELF()) + ObjStream << " .section .note.GNU-stack, \"\", @progbits\n"; ObjStream.flush(); // Dump the contents of the temp object file gen if the user requested that. diff --git a/clang/test/Driver/hip-toolchain-rdc.hip b/clang/test/Driver/hip-toolchain-rdc.hip index fa30bb8a9f5f5..1827531f9cab7 100644 --- a/clang/test/Driver/hip-toolchain-rdc.hip +++ b/clang/test/Driver/hip-toolchain-rdc.hip @@ -32,6 +32,8 @@ // CHECK: .p2align 12 // CHECK: __hip_fatbin: // CHECK: .incbin "[[BUNDLE:.*hipfb]]" +// LNX: .section .note.GNU-stack, "", @progbits +// MSVC-NOT: .note.GNU-stack // emit objects for host side path // CHECK: [[CLANG:".*clang.*"]] "-cc1" "-triple" [[HOST:"x86_64-[^"]+"]]