diff options
author | Maksim Panchenko <maks@fb.com> | 2022-10-03 18:50:18 -0700 |
---|---|---|
committer | Maksim Panchenko <maks@fb.com> | 2022-10-07 11:19:51 -0700 |
commit | 0b213c9090369ff43060816aed38cb6c67e228f8 (patch) | |
tree | add038287e97da5f65708369aa0d9913dedc7adc /bolt/test | |
parent | c683e281cdc99b04497d5102c28be0d2e991c9f6 (diff) | |
download | llvm-0b213c9090369ff43060816aed38cb6c67e228f8.zip llvm-0b213c9090369ff43060816aed38cb6c67e228f8.tar.gz llvm-0b213c9090369ff43060816aed38cb6c67e228f8.tar.bz2 |
[BOLT] Fix writing out unmarked .eh_frame section
When BOLT updates .eh_frame section, it concatenates newly-generated
contents (from CFI directives) with the original .eh_frame that has
relocations applied to it. However, if no new content is generated,
the original .eh_frame has to be left intact. In that case, BOLT was
still writing out the relocatable copy of the original .eh_frame section
to the new segment, even though this copy was never used and was not
even marked in the section header table.
Detect the scenario above and skip allocating extra space for .eh_frame.
Reviewed By: rafauler
Differential Revision: https://reviews.llvm.org/D135223
Diffstat (limited to 'bolt/test')
-rw-r--r-- | bolt/test/X86/dummy-eh-frame-bug.s | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/bolt/test/X86/dummy-eh-frame-bug.s b/bolt/test/X86/dummy-eh-frame-bug.s new file mode 100644 index 0000000..2d05cf3 --- /dev/null +++ b/bolt/test/X86/dummy-eh-frame-bug.s @@ -0,0 +1,27 @@ +# REQUIRES: system-linux + +# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-linux %s -o %t.o +# RUN: ld.lld %t.o -o %t.exe -q +# RUN: llvm-bolt %t.exe -o %t.bolt.exe --funcs=nocfi_function +# RUN: llvm-readelf --section-headers %t.bolt.exe | FileCheck %s + +## Check that llvm-bolt does not allocate unmarked space for original .eh_frame +## after .text when no update is needed to .eh_frame. + +# CHECK: {{ .text}} PROGBITS [[#%x,ADDR:]] [[#%x,OFFSET:]] [[#%x,SIZE:]] +# CHECK-NEXT: 0000000000000000 [[#%x, OFFSET + SIZE]] + + .text + .globl nocfi_function + .type nocfi_function,@function +nocfi_function: + ret + .size nocfi_function, .-nocfi_function + + .globl _start + .type _start,@function +_start: + .cfi_startproc + call nocfi_function + .size _start, .-_start + .cfi_endproc |