From 5e1a4d20e56ce6d7c97bcfa75bd43f5f67fd015e Mon Sep 17 00:00:00 2001 From: jca Date: Mon, 20 Nov 2023 19:29:18 +0000 Subject: [PATCH] Stop erroring out when .gcc_except_table relocs point at discarded sections lang/gcc on riscv64 has a wart, it creates such relocs which upset ld.lld. The workaround I have used in lang/gcc since Sep 2022 doesn't work any more, so ask ld.lld to be more lenient. This will let the fortran ports and friends build on riscv64. clang has fixed since some time already, but our lang/gcc port will likely keep that wart for some time. Upstream report: https://reviews.llvm.org/D83244 Input and ok kettenis@ --- gnu/llvm/lld/ELF/Relocations.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gnu/llvm/lld/ELF/Relocations.cpp b/gnu/llvm/lld/ELF/Relocations.cpp index 80b3615f1a9..3c9e7e450c1 100644 --- a/gnu/llvm/lld/ELF/Relocations.cpp +++ b/gnu/llvm/lld/ELF/Relocations.cpp @@ -832,6 +832,13 @@ static bool maybeReportUndefined(Undefined &sym, InputSectionBase &sec, if (sym.discardedSecIdx != 0 && (sec.name == ".got2" || sec.name == ".toc")) return false; +#ifdef __OpenBSD__ + // GCC (at least 8 and 11) can produce a ".gcc_except_table" with relocations + // to discarded sections on riscv64 + if (sym.discardedSecIdx != 0 && sec.name == ".gcc_except_table") + return false; +#endif + bool isWarning = (config->unresolvedSymbols == UnresolvedPolicy::Warn && canBeExternal) || config->noinhibitExec; -- 2.20.1