[Bug 291446] /libexec/ld-elf.so.1 not branded properly on riscv, breaks manual activation via ldd

From: <bugzilla-noreply_at_freebsd.org>
Date: Sun, 07 Dec 2025 01:42:59 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=291446

            Bug ID: 291446
           Summary: /libexec/ld-elf.so.1 not branded properly on riscv,
                    breaks manual activation via ldd
           Product: Base System
           Version: 15.0-CURRENT
          Hardware: riscv
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: riscv
          Assignee: riscv@FreeBSD.org
          Reporter: freebsd@bdragon.rtk0.net

After a fresh install of 15.0-RELEASE:

When manually activating rtld on risc-v (for example, when running ldd on
something) the kernel is rejecting image activation, due to
/libexec/ld-elf.so.1 being branded SYSV rather than FreeBSD.

Somewhat surprisingly, this doesn't break running normal dynamic executables,
because normally, rtld is activated via being loaded as the interpreter, and as
such is not actually checked against the brand list.

Normal programs are also being branded SYSV, but this is less of an issue for
dynamically linked programs, as they will still match the branding via the
interpreter path check.

Silly workaround:

cp /libexec/ld-elf.so.1 /libexec/ld-elf.so.1.patched && \
brandelf -t FreeBSD /libexec/ld-elf.so.1.patched && \
cp /libexec/ld-elf.so.1.patched /libexec/ld-elf.so.1.new &&\
chflags noschg /libexec/ld-elf.so.1 && \
/libexec/ld-elf.so.1.patched /bin/mv /libexec/ld-elf.so.1
/libexec/ld-elf.so.1.old && \
/libexec/ld-elf.so.1.patched /bin/mv /libexec/ld-elf.so.1.new
/libexec/ld-elf.so.1 && \
chflags schg /libexec/ld-elf.so.1

I suppose an alternative might be to set the kern.elf64.fallback_brand sysctl,
but I haven't verified that.

Ideally, the linker would be branding the ELF header automatically. This should
theoretically already be happening, but maybe there's a bug in the
triple-to-OSABI detection. It's been a long time since I've looked at that
code.

-- 
You are receiving this mail because:
You are the assignee for the bug.