Files
swift-mirror/test/IRGen/ELF-remove-autolink-section.swift
Saleem Abdulrasool 837e331f16 IRGen: handle ASAN better with importing on ELF
ELF's lack of linker directives is worked around by a custom section
(`.swift1_autolink_entries`).  This is metadata that is not intended to
be emitted into the linked binary.  A previous change introduced the use
of a module (global) assembly gadget to discard the section.  However,
this interacts poorly with ASAN which would instrument the section,
resulting in a strong reference.  This reference would persist to a
discarded symbol.  lld would object to this.  Blacklist the symbol to
ensure that ASAN + autolinking can co-exist.
2020-01-09 21:48:25 -08:00

28 lines
938 B
Swift

// RUN: %swiftc_driver -emit-ir %s -o - | %FileCheck %s -check-prefix ELF
// Check that the swift auto link section is available in the object file.
// RUN: %swiftc_driver -c %s -o %t
// RUN: llvm-readelf %t -S | %FileCheck %s -check-prefix SECTION
// Checks that the swift auto link section is removed from the final binary.
// RUN: %swiftc_driver -emit-executable %s -o %t
// RUN: llvm-readelf %t -S | %FileCheck %s -check-prefix NOSECTION
// REQUIRES: OS=linux-gnu
print("Hi from Swift!")
// ELF: module asm ".section .swift1_autolink_entries,\220x80000000\22"
// Find the metadata entry for the blacklisting of the metadata symbol
// Ensure that it is in the ASAN metadata
// ELF-DAG: !llvm.asan.globals = !{
// ELF-SAME: [[MD:![0-9]+]]
// ELF-SAME: }
// ELF-DAG: [[MD]] = !{[37 x i8]* @_swift1_autolink_entries, null, null, i1 false, i1 true}
// SECTION: .swift1_autolink_entries
// NOSECTION-NOT: .swift1_autolink_entries