]> granicus.if.org Git - clang/commit
[Driver] Render target options (e.g. -fuse-init-array) for -fembed-bitcode
authorFangrui Song <maskray@google.com>
Thu, 30 May 2019 02:30:04 +0000 (02:30 +0000)
committerFangrui Song <maskray@google.com>
Thu, 30 May 2019 02:30:04 +0000 (02:30 +0000)
commita59c51ceaf36b891acc3a98fa12e67819d7993df
tree0e5510101b4622078a868d5c1a4d10ac42cf65e2
parent79874a04dd950d17ea375daac7bce76146499bfe
[Driver] Render target options (e.g. -fuse-init-array) for -fembed-bitcode

Modern ELF platforms use -fuse-init-array to emit .init_array instead of
.ctors .  ld.bfd and gold --ctors-in-init-array merge .init_array and
.ctors into .init_array but lld doesn't do that.

If crtbegin*.o crtend*.o don't provide .ctors/.dtors, such .ctors in
user object files can lead to crash (see PR42002. The first and the last
elements in .ctors/.dtors are ignored - they are traditionally provided
by crtbegin*.o crtend*.o).

Call addClangTargetOptions() to ensure -fuse-init-array is rendered on
modern ELF platforms. On Hexagon, this renders -target-feature
+reserved-r19 for -ffixed-r19.

Reviewed By: compnerd

Differential Revision: https://reviews.llvm.org/D62509

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@362052 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Driver/ToolChains/Clang.cpp
test/Driver/fembed-bitcode.c