Hi,

Binutils 2.46.0 compiled with tcc (commit cb41cbf, 2025-12-03)
produces an ld that crashes when linking shared libraries:

```
ld: BFD (GNU Binutils) 2.46.0.20260210 internal error, aborting at elf.c:14101
```

I hit this linking musl 1.2.5's libc.so. Haven't tested other shared
libs but I'd expect the same.

The same binutils source compiled with GCC works fine. Setting
`ac_cv_func_mmap_fixed_mapped=no` before configure forces the old
read/lseek fallback in BFD and the crash goes away. So tcc is
generating bad code somewhere in the mmap path.

Binutils 2.42 didn't have this code and worked with tcc. The mmap
support was added around 2.44-2.46.

To reproduce with Nix: build `minimal-bootstrap.binutils` with version
set to 2.46.0, without the `ac_cv_func_mmap_fixed_mapped=no`
workaround, then build `minimal-bootstrap.musl` which links libc.so
using that ld.

Without Nix: compile binutils 2.46.0 with `CC=tcc` (musl-linked tcc,
not mes-tcc) and link a shared ELF binary with the resulting ld.

Build host is x86_64-linux.

I haven't isolated which C pattern tcc chokes on. The new mmap code
lives around `_bfd_mmap_readonly_persistent` /
`_bfd_mmap_readonly_temporary` in `bfd/elf.c`.

Aleksi Hannula found this in the nixpkgs bootstrap chain:
https://github.com/NixOS/nixpkgs/pull/496543

Thanks,
Jamie

_______________________________________________
Tinycc-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to