/// relocations of this general form, but we need to represent this anyway.
///
/// In the general form, SymbolB can only be defined if SymbolA is, and both
-/// must be in the same (non-external) section.
+/// must be in the same (non-external) section. The latter constraint is not
+/// enforced, since a symbol's section may not be known at construction.
///
/// Note that this class must remain a simple POD value class, because we need
/// it to live in unions etc.
static MCValue get(MCSymbol *SymA, MCSymbol *SymB = 0, int64_t Val = 0) {
MCValue R;
- assert((!SymB || (SymA && SymA->getSection() &&
- SymA->getSection() == SymB->getSection())) &&
- "Invalid relocatable MCValue!");
+ assert((!SymB || SymA) && "Invalid relocatable MCValue!");
R.Cst = Val;
R.SymA = SymA;
R.SymB = SymB;
MCSymbol *A = LHS.getSymA() ? LHS.getSymA() : RHS_A;
MCSymbol *B = LHS.getSymB() ? LHS.getSymB() : RHS_B;
if (B) {
- // If we have a negated symbol, then we must have also have a
- // non-negated symbol, and both symbols must be in the same
- // non-external section. We can do this check later to permit
- // expressions which eventually fold to a representable form -- such
+ // If we have a negated symbol, then we must have also have a non-negated
+ // symbol in order to encode the expression. We can do this check later to
+ // permit expressions which eventually fold to a representable form -- such
// as (a + (0 - b)) -- if necessary.
- if (!A || !A->getSection() || A->getSection() != B->getSection())
+ if (!A)
return false;
}
Res = MCValue::get(A, B, LHS.getConstant() + RHS_Cst);