Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2144,6 +2144,11 @@ ModuleAddressSanitizer::CreateMetadataGlobal(Module &M, Constant *Initializer,
M, Initializer->getType(), false, Linkage, Initializer,
Twine("__asan_global_") + GlobalValue::dropLLVMManglingEscape(OriginalName));
Metadata->setSection(getGlobalMetadataSection());
// Move metadata section out of the way for x86-64 ELF binaries to mitigate
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Place metadata in a large section for ... to mitigate ...

// relocation pressure.
if (TargetTriple.getArch() == Triple::x86_64 &&
TargetTriple.getObjectFormat() == Triple::ELF)
Metadata->setCodeModel(CodeModel::Large);
return Metadata;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -passes=asan -S | FileCheck %s --check-prefix=LARGE
; RUN: opt < %s -mtriple=aarch64-unknown-linux-gnu -passes=asan -S | FileCheck %s --check-prefix=NORMAL
; RUN: opt < %s -mtriple=x86_64-pc-windows -passes=asan -S | FileCheck %s --check-prefix=NORMAL

; check that asan globals metadata are emitted to a large section for x86-64 ELF

; LARGE: @__asan_global_global = {{.*}}global {{.*}}, code_model "large"
; NORMAL-NOT: code_model "large"

@global = global i32 0, align 4
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ target triple = "x86_64-unknown-linux-gnu"
;; Don't place the instrumented globals in a comdat when the unique module ID is empty.
; NOMODULEID: @.str = internal constant { [4 x i8], [28 x i8] } { [4 x i8] c"str\00", [28 x i8] zeroinitializer }, align 32
; NOMODULEID: @_ZL3buf = internal global { [4 x i8], [28 x i8] } zeroinitializer, align 32
; NOMODULEID: @__asan_global_.str = private global {{.*}}, section "asan_globals", !associated !0
; NOMODULEID: @__asan_global__ZL3buf = private global {{.*}}, section "asan_globals", !associated !1
; NOMODULEID: @__asan_global_.str = private global {{.*}}, section "asan_globals"{{.*}}, !associated !0
; NOMODULEID: @__asan_global__ZL3buf = private global {{.*}}, section "asan_globals"{{.*}}, !associated !1
; NOMODULEID: @llvm.compiler.used = appending global [4 x ptr] [ptr @.str, ptr @_ZL3buf, ptr @__asan_global_.str, ptr @__asan_global__ZL3buf]

; NOMODULEID: define internal void @asan.module_ctor() #[[#]] comdat {
Expand Down