diff --git a/lld/ELF/Arch/RISCV.cpp b/lld/ELF/Arch/RISCV.cpp index aa67617a5be25..018da8a6e247d 100644 --- a/lld/ELF/Arch/RISCV.cpp +++ b/lld/ELF/Arch/RISCV.cpp @@ -663,7 +663,7 @@ static bool relax(InputSection &sec) { auto &aux = *sec.relaxAux; bool changed = false; ArrayRef sa = ArrayRef(aux.anchors); - uint32_t delta = 0; + uint64_t delta = 0; std::fill_n(aux.relocTypes.get(), sec.relocs().size(), R_RISCV_NONE); aux.writes.clear(); @@ -726,8 +726,8 @@ static bool relax(InputSection &sec) { a.d->value = a.offset - delta; } // Inform assignAddresses that the size has changed. - if (!isUInt<16>(delta)) - fatal("section size decrease is too large"); + if (!isUInt<32>(delta)) + fatal("section size decrease is too large: " + Twine(delta)); sec.bytesDropped = delta; return changed; } diff --git a/lld/ELF/InputSection.h b/lld/ELF/InputSection.h index 356ccda2d7436..143384b3ba7bc 100644 --- a/lld/ELF/InputSection.h +++ b/lld/ELF/InputSection.h @@ -137,7 +137,7 @@ class InputSectionBase : public SectionBase { // Used by --optimize-bb-jumps and RISC-V linker relaxation temporarily to // indicate the number of bytes which is not counted in the size. This should // be reset to zero after uses. - uint16_t bytesDropped = 0; + uint32_t bytesDropped = 0; mutable bool compressed = false; @@ -401,7 +401,7 @@ class InputSection : public InputSectionBase { template void copyShtGroup(uint8_t *buf); }; -static_assert(sizeof(InputSection) <= 152, "InputSection is too big"); +static_assert(sizeof(InputSection) <= 160, "InputSection is too big"); class SyntheticSection : public InputSection { public: