From: jca Date: Wed, 7 Feb 2024 20:54:20 +0000 (+0000) Subject: riscv64 fix: Handle relaxation reductions of more than 65536 bytes X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=6add50f8885e2b12e9d85f7d7e9299c8248e7f85;p=openbsd riscv64 fix: Handle relaxation reductions of more than 65536 bytes Upstream commit: https://github.com/llvm/llvm-project/commit/9d37ea95df1b84cca9b5e954d8964c976a5e303e Already needed at least by ports/math/hdf5, prerequisite if we want to enable linker relaxation (clang upstream defaults). ok kettenis@ --- diff --git a/gnu/llvm/lld/ELF/Arch/RISCV.cpp b/gnu/llvm/lld/ELF/Arch/RISCV.cpp index b0864b51779..4811d50adff 100644 --- a/gnu/llvm/lld/ELF/Arch/RISCV.cpp +++ b/gnu/llvm/lld/ELF/Arch/RISCV.cpp @@ -621,7 +621,7 @@ static bool relax(InputSection &sec) { // iteration. DenseMap valueDelta; ArrayRef sa = ArrayRef(aux.anchors); - uint32_t delta = 0; + uint64_t delta = 0; for (auto [i, r] : llvm::enumerate(sec.relocs())) { for (; sa.size() && sa[0].offset <= r.offset; sa = sa.slice(1)) if (!sa[0].end) @@ -688,8 +688,8 @@ static bool relax(InputSection &sec) { a.d->value -= delta - valueDelta.find(a.d)->second; } // 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/gnu/llvm/lld/ELF/InputSection.h b/gnu/llvm/lld/ELF/InputSection.h index 356ccda2d74..143384b3ba7 100644 --- a/gnu/llvm/lld/ELF/InputSection.h +++ b/gnu/llvm/lld/ELF/InputSection.h @@ -137,7 +137,7 @@ public: // 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 @@ private: 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: