Package: binutils
Version: 2.45-7
Severity: standard
Tags: patch
X-Debbugs-Cc: [email protected]

Dear Maintainer,

The linker (ld.bfd) crashes with a segmentation fault when building shared 
libraries on loongarch64 due to an assertion failure in elfnn-loongarch.c:2716.

* What led up to the situation?

Attempting to build x265 4.1 (and other projects using shared libraries) on 
Debian unstable/loongarch64 with binutils 2.45-7.

* What exactly did you do (or not do) that was effective (or ineffective)?

Built x265 4.1 from source:
  tar xzf x265_4.1.tar.gz
  cd x265_4.1/build/linux
  cmake ../../source
  make

The build proceeds through compilation but fails during the linking stage of 
the shared library (libx265.so) with:

/usr/bin/ld: BFD (GNU Binutils for Debian) 2.45 assertion fail 
../../bfd/elfnn-loongarch.c:2716
collect2: fatal error: ld terminated with signal 11 [Segmentation fault]
compilation terminated.

* What was the outcome of this action?

The linker crashes. The static library builds successfully, but the shared 
library build fails.

* What outcome did you expect instead?

The shared library should link successfully without segfaulting.

Additional context:
- The error occurs specifically with R_LARCH_PCALA_HI20 relocations
- Multiple objects trigger this: search.cpp.o, entropy.cpp.o, quant.cpp.o
- Error message: "relocation R_LARCH_PCALA_HI20 against `<symbol>` can not be 
  used when making a shared object; recompile with -fPIC"
- All code is already compiled with -fPIC (verified in build logs)

Workaround:
Building with -DENABLE_SHARED=OFF (static library only) works.

This bug affects multiple compilation benchmarks and projects that build 
shared libraries on LoongArch64.

Reply via email to