[PATCH] D81104: [XCOFF][AIX] report_fatal_error when an overflow section is needed
Hubert Tong via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 4 22:01:21 PDT 2020
hubert.reinterpretcast added inline comments.
================
Comment at: llvm/lib/MC/XCOFFObjectWriter.cpp:744
+ for (auto &Csect : *Group) {
+ if (Csect.Relocations.size() >= UINT16_MAX)
+ report_fatal_error(
----------------
Semantically, this is not `UINT16_MAX` but an XCOFF-defined constant. Otherwise, the maximum representable value would be `UINT16_MAX` itself and not one less. `RelocOverflow` is currently defined in `lib/Object/XCOFFObjectFile.cpp`, but it should probably be defined in `include/llvm/BinaryFormat/XCOFF.h`.
================
Comment at: llvm/lib/MC/XCOFFObjectWriter.cpp:750
Section->RelocationCount += Csect.Relocations.size();
+ if (Section->RelocationCount >= UINT16_MAX)
+ report_fatal_error(
----------------
Move the check to before the addition; use: `Section->RelocationCount >= UINT16_MAX - Csect.Relocations.size()`. After said move, the two `if` statements can be merged.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D81104/new/
https://reviews.llvm.org/D81104
More information about the llvm-commits
mailing list