1
1
mirror of https://github.com/rui314/mold.git synced 2024-09-11 21:17:28 +03:00

-r: Do not emit .eh_frame if there's no input .eh_frame

This commit is contained in:
Rui Ueyama 2022-11-26 16:30:24 +08:00
parent 3a4166a066
commit 556a5cabf9
2 changed files with 24 additions and 0 deletions

View File

@ -2020,6 +2020,14 @@ template <typename E>
void EhFrameSection<E>::construct(Context<E> &ctx) {
Timer t(ctx, "eh_frame");
// If .eh_frame is missing in all input files, we don't want to
// create an output .eh_frame section.
if (std::all_of(ctx.objs.begin(), ctx.objs.end(),
[](ObjectFile<E> *file) { return file->cies.empty(); })) {
this->shdr.sh_size = 0;
return;
}
// Remove dead FDEs and assign them offsets within their corresponding
// CIE group.
tbb::parallel_for_each(ctx.objs, [&](ObjectFile<E> *file) {

View File

@ -0,0 +1,16 @@
#!/bin/bash
. $(dirname $0)/common.inc
# OneTBB isn't tsan-clean
nm mold | grep -q '__tsan_init' && skip
cat <<EOF | $CC -c -o $t/a.o -xc -fno-unwind-tables -fno-asynchronous-unwind-tables -
int foo() { return 1; }
EOF
readelf -WS $t/a.o > $t/log1
! grep -Fq .eh_frame $t/log1 || false
./mold --relocatable -o $t/b.o $t/a.o
readelf -WS $t/b.o > $t/log2
! grep -Fq .eh_frame $t/log2 || false