[PATCH] D150229: [bolt] Fix typo in BinaryFunction::parseLSDA

Richard Dzenis via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 9 15:25:16 PDT 2023


RIscRIpt added a comment.

I think it went unnoticed, because AFAICS `lpStartEncoding` is `omit` most of the times, which resulted `MaybeLPStart == std::nullopt`, and `LPStart = 0`.

  LPStart = 0
  LPOffset = LPStart + LandingPad;
  LPAddress = Address + LPOffset; // == Address + 0 + LandingPad == Address + LandingPad
  LPAddress < Address == false // OK, fragment is not skipped

However if `lpStartEncoding` was not `omit`, this should have resulted in skipping the fragment:

  LPStart = *MaybeLPStart - Address
  LPOffset = LPStart + LandingPad;
  LPAddress = Address + LPOffset; // == Address + *MaybeLPStart - Address + LandingPad == *MaybeLPStart + LandingPad
  LPAddress < Address == true // iff *MaybeLPStart is not absolute (i.e. *MaybeLPStart < Address)

This had to work correctly in case of non-PIC binaries (with absolute addresses in *MaybeLPStart), and it had to result in a bug for PIC binaries.

I came across this typo while studying relevant code; my thinking may be wrong.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150229



More information about the llvm-commits mailing list