OSDN Git Service

[RISCV] Correctly report sizes for builtin fixups
authorAlex Bradbury <asb@lowrisc.org>
Wed, 23 May 2018 10:53:56 +0000 (10:53 +0000)
committerAlex Bradbury <asb@lowrisc.org>
Wed, 23 May 2018 10:53:56 +0000 (10:53 +0000)
commit0baaa616ba4c0050bac66ccd3a315b5399004144
treea622430f5cc56369aea2f91293b44197d952a1bc
parent17c3197f7929fa0d6f4477ed96ed2de97931a263
[RISCV] Correctly report sizes for builtin fixups

This is a different approach to fixing the problem described in D46746.
RISCVAsmBackend currently depends on the getSize helper function returning the
number of bytes a fixup may change (note: some other backends have a similar
helper named getFixupNumKindBytes). As noted in that review, this doesn't
return the correct size for FK_Data_1, FK_Data_2, or FK_Data_8 meaning that
too few bytes will be written in the case of FK_Data_8, and there's the
potential of writing outside the Data array for the smaller fixups.

D46746 extends getSize to recognise some of the builtin fixup types. Rather
than having a function that needs to be kept up to date as new builtin or
target-specific fixups are added, We can calculate an appropriate bound on the
number of bytes that might be touched using Info.TargetSize and
Info.TargetOffset.

Differential Revision: https://reviews.llvm.org/D46965

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333076 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp