diff --git a/llvm/lib/Object/IRSymtab.cpp b/llvm/lib/Object/IRSymtab.cpp --- a/llvm/lib/Object/IRSymtab.cpp +++ b/llvm/lib/Object/IRSymtab.cpp @@ -45,6 +45,10 @@ #define HANDLE_LIBCALL(code, name) name, #include "llvm/IR/RuntimeLibcalls.def" #undef HANDLE_LIBCALL + // This is a global variable defined by the user, so put it here instead of + // in RuntimeLibcalls.def. + // TODO: Are there similar such variables? + "__stack_chk_guard" }; namespace { diff --git a/llvm/test/ThinLTO/X86/builtin-nostrip.ll b/llvm/test/ThinLTO/X86/builtin-nostrip.ll --- a/llvm/test/ThinLTO/X86/builtin-nostrip.ll +++ b/llvm/test/ThinLTO/X86/builtin-nostrip.ll @@ -15,6 +15,7 @@ ; Test new lto interface with thinlto. ; RUN: llvm-lto2 run %t1.bc -o %t.out -save-temps \ ; RUN: -r %t1.bc,bar,pl \ +; RUN: -r %t1.bc,__stack_chk_guard,pl \ ; RUN: -r %t1.bc,__stack_chk_fail,pl ; RUN: llvm-nm %t.out.1 | FileCheck %s --check-prefix=CHECK-NM ; @@ -25,7 +26,8 @@ ; Test the new lto interface without thinlto. ; RUN: llvm-lto2 run %t4.bc -o %t5.out -save-temps \ ; RUN: -r %t4.bc,bar,pl \ -; RUN: -r %t4.bc,__stack_chk_fail,pl +; RUN: -r %t4.bc,__stack_chk_guard,pl \ +; RUN: -r %t4.bc,__stack_chk_fail,pl ; RUN: llvm-nm %t5.out.0 | FileCheck %s --check-prefix=CHECK-NM ; Test the old lto interface without thinlto. For now we need to @@ -39,11 +41,13 @@ ; The final binary should not contain any of the dead functions; ; make sure memmove and memcpy are there. ; CHECK-NM-NOT: bar +; CHECK-NM-DAG: D __stack_chk_guard ; CHECK-NM-DAG: T __stack_chk_fail ; CHECK-NM-NOT: bar ; Test case for old lto without thinlto. Hopefully these can be ; eliminated once the old lto interface is fixed. +; CHECK-NM2-DAG: D __stack_chk_guard ; CHECK-NM2-DAG: t __stack_chk_fail target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" @@ -53,6 +57,7 @@ ret void } +@__stack_chk_guard = dso_local global i64 1, align 8 define void @__stack_chk_fail() { ret void