[PATCH] D112595: [IRSymTab] Mark __stack_chk_guard used
Yuanfang Chen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 26 22:34:26 PDT 2021
ychen created this revision.
ychen added reviewers: MaskRay, tejohnson.
Herald added subscribers: ormris, steven_wu, hiraditya.
ychen requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
For the use case where a file defining __stack_chk_guard participate in
LTO.
Fix PR28061.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D112595
Files:
llvm/lib/Object/IRSymtab.cpp
llvm/test/ThinLTO/X86/builtin-nostrip.ll
Index: llvm/test/ThinLTO/X86/builtin-nostrip.ll
===================================================================
--- llvm/test/ThinLTO/X86/builtin-nostrip.ll
+++ 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
}
+ at __stack_chk_guard = dso_local global i64 1, align 8
define void @__stack_chk_fail() {
ret void
Index: llvm/lib/Object/IRSymtab.cpp
===================================================================
--- llvm/lib/Object/IRSymtab.cpp
+++ 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 {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112595.382526.patch
Type: text/x-patch
Size: 2077 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211027/831b4fba/attachment.bin>
More information about the llvm-commits
mailing list