From c6ec352a6bde1995794c523adc2ebab802ccdf0a Mon Sep 17 00:00:00 2001 From: Marco Elver Date: Mon, 8 Jun 2020 10:30:50 +0200 Subject: Revert "[KernelAddressSanitizer] Make globals constructors compatible with kernel" This reverts commit 866ee2353f7d0224644799d0d1faed53c7f3a06d. Building the kernel results in modpost failures due to modpost relying on debug info and inspecting kernel modules' globals: https://github.com/ClangBuiltLinux/linux/issues/1045#issuecomment-640381783 --- llvm/lib/Transforms/Utils/ModuleUtils.cpp | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'llvm/lib/Transforms/Utils/ModuleUtils.cpp') diff --git a/llvm/lib/Transforms/Utils/ModuleUtils.cpp b/llvm/lib/Transforms/Utils/ModuleUtils.cpp index ef9f18a..b2e6d98 100644 --- a/llvm/lib/Transforms/Utils/ModuleUtils.cpp +++ b/llvm/lib/Transforms/Utils/ModuleUtils.cpp @@ -119,15 +119,6 @@ llvm::declareSanitizerInitFunction(Module &M, StringRef InitName, AttributeList()); } -Function *llvm::createSanitizerCtor(Module &M, StringRef CtorName) { - Function *Ctor = Function::Create( - FunctionType::get(Type::getVoidTy(M.getContext()), false), - GlobalValue::InternalLinkage, CtorName, &M); - BasicBlock *CtorBB = BasicBlock::Create(M.getContext(), "", Ctor); - ReturnInst::Create(M.getContext(), CtorBB); - return Ctor; -} - std::pair llvm::createSanitizerCtorAndInitFunctions( Module &M, StringRef CtorName, StringRef InitName, ArrayRef InitArgTypes, ArrayRef InitArgs, @@ -137,8 +128,11 @@ std::pair llvm::createSanitizerCtorAndInitFunctions( "Sanitizer's init function expects different number of arguments"); FunctionCallee InitFunction = declareSanitizerInitFunction(M, InitName, InitArgTypes); - Function *Ctor = createSanitizerCtor(M, CtorName); - IRBuilder<> IRB(Ctor->getEntryBlock().getTerminator()); + Function *Ctor = Function::Create( + FunctionType::get(Type::getVoidTy(M.getContext()), false), + GlobalValue::InternalLinkage, CtorName, &M); + BasicBlock *CtorBB = BasicBlock::Create(M.getContext(), "", Ctor); + IRBuilder<> IRB(ReturnInst::Create(M.getContext(), CtorBB)); IRB.CreateCall(InitFunction, InitArgs); if (!VersionCheckName.empty()) { FunctionCallee VersionCheckFunction = M.getOrInsertFunction( -- cgit v1.1