[BOLT] Always move JTs in jump-table=move
authorRafael Auler <rafaelauler@fb.com>
Sat, 29 Oct 2022 01:34:48 +0000 (18:34 -0700)
committerRafael Auler <rafaelauler@fb.com>
Fri, 4 Nov 2022 20:20:11 +0000 (13:20 -0700)
commit369899449226a00f15422a12aacb62dee312c8d5
tree716145911fd898ba11f01def992039a82991fbb2
parent687ce3dec132e0a8d37da910d4dd470b72c70298
[BOLT] Always move JTs in jump-table=move

We should always move jump tables when requested. Previously,
we were not moving jump tables of non-simple functions in relocation
mode. That caused a bug detailed in the attached test case: in PIC
jump tables, we force jump tables to be moved, but if they are not
moved because the function is not simple, we could incorrectly update
original entries in .rodata, corrupting it under special circumstances
(see testcase).

Reviewed By: #bolt, maksfb

Differential Revision: https://reviews.llvm.org/D137357
bolt/lib/Core/BinaryEmitter.cpp
bolt/test/X86/Inputs/jt-pic-linkerscript.ld [new file with mode: 0644]
bolt/test/X86/jump-table-pic-conflict.s [new file with mode: 0644]