llvm.org GIT mirror llvm / 76e6710
[JITLink] Fixed a signedness bug when processing X86_64_RELOC_SUBTRACTOR. Subtractor relocation addends are signed, so we need to read them via signed int pointers. Accidentally treating 32-bit addends as unsigned leads to out-of-range errors when we try to add very large (>INT32_MAX) bogus addends. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360392 91177308-0d34-0410-b5e6-96231b3b80d8 Lang Hames 1 year, 6 months ago
2 changed file(s) with 10 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
156156 // Read the current fixup value.
157157 uint64_t FixupValue = 0;
158158 if (SubRI.r_length == 3)
159 FixupValue = *(const ulittle64_t *)FixupContent;
159 FixupValue = *(const little64_t *)FixupContent;
160160 else
161 FixupValue = *(const ulittle32_t *)FixupContent;
161 FixupValue = *(const little32_t *)FixupContent;
162162
163163 // Find 'ToAtom' using symbol number or address, depending on whether the
164164 // paired UNSIGNED relocation is extern.
179179 # Both forms "A: .quad A - B + C" and "A: .quad B - A + C" are tested.
180180 #
181181 # Check "A: .quad B - A + C".
182 # jitlink-check: *{8}subtrahend_quad2 = (named_data - subtrahend_quad2 + 2)
182 # jitlink-check: *{8}subtrahend_quad2 = (named_data - subtrahend_quad2 - 2)
183183 .globl subtrahend_quad2
184184 .p2align 3
185185 subtrahend_quad2:
186 .quad named_data - subtrahend_quad2 + 2
186 .quad named_data - subtrahend_quad2 - 2
187187
188188 # Check "A: .long B - A + C".
189 # jitlink-check: *{4}subtrahend_long2 = (named_data - subtrahend_long2 + 2)[31:0]
189 # jitlink-check: *{4}subtrahend_long2 = (named_data - subtrahend_long2 - 2)[31:0]
190190 .globl subtrahend_long2
191191 .p2align 2
192192 subtrahend_long2:
193 .long named_data - subtrahend_long2 + 2
193 .long named_data - subtrahend_long2 - 2
194194
195195 # Check "A: .quad A - B + C".
196 # jitlink-check: *{8}minuend_quad3 = (minuend_quad3 - named_data + 2)
196 # jitlink-check: *{8}minuend_quad3 = (minuend_quad3 - named_data - 2)
197197 .globl minuend_quad3
198198 .p2align 3
199199 minuend_quad3:
200 .quad minuend_quad3 - named_data + 2
200 .quad minuend_quad3 - named_data - 2
201201
202202 # Check "A: .long B - A + C".
203 # jitlink-check: *{4}minuend_long3 = (minuend_long3 - named_data + 2)[31:0]
203 # jitlink-check: *{4}minuend_long3 = (minuend_long3 - named_data - 2)[31:0]
204204 .globl minuend_long3
205205 .p2align 2
206206 minuend_long3:
207 .long minuend_long3 - named_data + 2
207 .long minuend_long3 - named_data - 2
208208
209209 # Check X86_64_RELOC_SUBTRACTOR handling for exprs of the form
210210 # "A: .quad/long B - C + D", where 'B' or 'C' is at a fixed offset from 'A'