[PATCH] D109109: [MC] Recursively calculate symbol offset

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 10 14:42:04 PDT 2021


MaskRay added a comment.

Ah, right. I looked at this piece of code and wondered as well last year...

I looked at some `ninja check-llvm-mc` failures if we remove the hack (i.e. make `if (!IsMachO) return true;` uncondtionally return true).

  --- i/llvm/lib/MC/MCExpr.cpp
  +++ w/llvm/lib/MC/MCExpr.cpp
  @@ -812,6 +812,7 @@ bool MCExpr::evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm,
                                                      Kind, Asm->getContext()),
                              Res.getSymB(), Res.getConstant(), Res.getRefKind());
           }
  +        return true;
           if (!IsMachO)  /// a proper fix should remove this block completely
             return true;
   

For

- `diff-with-two-sections.s`
- `variable-exprs.s`

I guess the change may fix bugs?!

For `eh-frame-reloc.s`, there will be a pair of `X86_64_RELOC_SUBTRACTOR __eh_frame` and `X86_64_RELOC_UNSIGNED _bar` which could(?) be cancelled but not by MC. I think this is benign.

@lhames Can you check if the hack can be deleted? If it works, please just push the change:)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D109109/new/

https://reviews.llvm.org/D109109



More information about the llvm-commits mailing list