From e961aa565e73d453432197330fb0c9611b49c80a Mon Sep 17 00:00:00 2001 From: Vyacheslav Egorov Date: Fri, 11 Dec 2020 08:48:38 +0000 Subject: [PATCH] [vm/build] Workaround for ld 2.19 crash on ARM When producing ARM builds instruct llvm-objcopy to drop .ARM.exidx/extab sections. These sections don't contain any useful information (we don't use exceptions or unwind C++ frames and most of the dart binary is in fact not covered by them), however they have been seen to break dynamic linker in older glibc versions (pre 2.23) because .ARM.exidx ends up being positioned between .rel.dyn and .rel.plt sections while older versions of dynamic linker expect these two sections to appear one after another in the ELF file. Closes https://github.com/dart-lang/sdk/issues/41644. Change-Id: I0ceebb63105591f132f3764180ae041366cbcade Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/175723 Reviewed-by: Alexander Markov Commit-Queue: Vyacheslav Egorov --- build/toolchain/gcc_toolchain.gni | 8 +++++++- build/toolchain/linux/BUILD.gn | 11 +++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/build/toolchain/gcc_toolchain.gni b/build/toolchain/gcc_toolchain.gni index 0d749661bda..96a32d472fa 100644 --- a/build/toolchain/gcc_toolchain.gni +++ b/build/toolchain/gcc_toolchain.gni @@ -204,7 +204,13 @@ template("gcc_toolchain") { command += " && " + strip_command } else if (defined(invoker.llvm_objcopy)) { strip = invoker.llvm_objcopy - strip_command = "${strip} --strip-all $outfile $stripped_outfile" + if (defined(invoker.llvm_objcopy_extra_args)) { + extra_args = invoker.llvm_objcopy_extra_args + } else { + extra_args = "" + } + strip_command = + "${strip} --strip-all ${extra_args} $outfile $stripped_outfile" command += " && " + strip_command } if (defined(invoker.postlink)) { diff --git a/build/toolchain/linux/BUILD.gn b/build/toolchain/linux/BUILD.gn index 46927848071..71038ed2b2c 100644 --- a/build/toolchain/linux/BUILD.gn +++ b/build/toolchain/linux/BUILD.gn @@ -52,6 +52,17 @@ gcc_toolchain("clang_arm") { ld = cxx llvm_objcopy = "${prefix}/llvm-objcopy" + # When producing ARM builds we drop .ARM.exidx/extab sections. These sections + # don't contain any useful information (we don't use exceptions or + # unwind C++ frames and most of the dart binary is in fact not covered by + # them), however they have been seen to break dynamic linker in older glibc + # versions (pre 2.23) because .ARM.exidx ends up being positioned between + # .rel.dyn and .rel.plt sections while older versions of dynamic linker + # expect these two sections to appear one after another in the ELF file. + # See https://github.com/dart-lang/sdk/issues/41644. + llvm_objcopy_extra_args = + "--remove-section .ARM.exidx --remove-section .ARM.extab" + toolchain_cpu = "arm" toolchain_os = "linux" is_clang = true