2010-12-16 04:05:53 +01:00
|
|
|
//===-- llvm/MC/MCFixupKindInfo.h - Fixup Descriptors -----------*- C++ -*-===//
|
|
|
|
//
|
2019-01-19 09:50:56 +01:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2010-12-16 04:05:53 +01:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_MC_MCFIXUPKINDINFO_H
|
|
|
|
#define LLVM_MC_MCFIXUPKINDINFO_H
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
2018-05-01 17:54:18 +02:00
|
|
|
/// Target independent information on a fixup kind.
|
2010-12-16 04:05:53 +01:00
|
|
|
struct MCFixupKindInfo {
|
|
|
|
enum FixupKindFlags {
|
|
|
|
/// Is this fixup kind PCrelative? This is used by the assembler backend to
|
|
|
|
/// evaluate fixup values in a target independent manner when possible.
|
|
|
|
FKF_IsPCRel = (1 << 0),
|
2012-05-11 03:39:13 +02:00
|
|
|
|
2010-12-16 04:05:53 +01:00
|
|
|
/// Should this fixup kind force a 4-byte aligned effective PC value?
|
[RISCV] Fix evaluating %pcrel_lo against global and weak symbols
Summary:
Previously, we would erroneously turn %pcrel_lo(label), where label has
a %pcrel_hi against a weak symbol, into %pcrel_lo(label + offset), as
evaluatePCRelLo would believe the target independent logic was going to
fold it. Moreover, even if that were fixed, shouldForceRelocation lacks
an MCAsmLayout and thus cannot evaluate the %pcrel_hi fixup to a value
and check the symbol, so we would then erroneously constant-fold the
%pcrel_lo whilst leaving the %pcrel_hi intact. After D72197, this same
sequence also occurs for symbols with global binding, which is triggered
in real-world code.
Instead, as discussed in D71978, we introduce a new FKF_IsTarget flag to
avoid these kinds of issues. All the resolution logic happens in one
place, with no coordination required between RISCAsmBackend and
RISCVMCExpr to ensure they implement the same logic twice. Although the
implementation of %pcrel_hi can be left as target independent, we make
it target dependent to ensure that they are handled identically to
%pcrel_lo, otherwise we risk one of them being constant folded but the
other being preserved. This also allows us to properly support fixup
pairs where the instructions are in different fragments.
Reviewers: asb, lenary, efriedma
Reviewed By: efriedma
Subscribers: arichardson, hiraditya, rbar, johnrusso, simoncook, sabuasal, niosHD, kito-cheng, shiva0217, MaskRay, zzheng, edward-jones, rogfer01, MartinMosbeck, brucehoult, the_o, rkruppe, PkmX, jocewei, psnobl, benna, Jim, s.egerton, pzheng, sameer.abuasal, apazos, luismarques, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D73211
2020-01-23 03:05:46 +01:00
|
|
|
FKF_IsAlignedDownTo32Bits = (1 << 1),
|
|
|
|
|
|
|
|
/// Should this fixup be evaluated in a target dependent manner?
|
2020-02-27 12:35:10 +01:00
|
|
|
FKF_IsTarget = (1 << 2),
|
|
|
|
|
|
|
|
/// This fixup kind should be resolved if defined.
|
|
|
|
/// FIXME This is a workaround because we don't support certain ARM
|
|
|
|
/// relocation types. This flag should eventually be removed.
|
|
|
|
FKF_Constant = 1 << 3,
|
2010-12-16 04:05:53 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/// A target specific name for the fixup kind. The names will be unique for
|
|
|
|
/// distinct kinds on any given target.
|
|
|
|
const char *Name;
|
|
|
|
|
|
|
|
/// The bit offset to write the relocation into.
|
|
|
|
unsigned TargetOffset;
|
|
|
|
|
|
|
|
/// The number of bits written by this fixup. The bits are assumed to be
|
|
|
|
/// contiguous.
|
|
|
|
unsigned TargetSize;
|
|
|
|
|
|
|
|
/// Flags describing additional information on this fixup kind.
|
|
|
|
unsigned Flags;
|
|
|
|
};
|
|
|
|
|
2015-06-23 11:49:53 +02:00
|
|
|
} // End llvm namespace
|
2010-12-16 04:05:53 +01:00
|
|
|
|
|
|
|
#endif
|