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

From: <bugzilla-noreply_at_freebsd.org>
Date: Mon, 08 Dec 2025 01:55:40 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=291446

--- Comment #5 from Brandon Bergren <freebsd@bdragon.rtk0.net> ---
(In reply to Jessica Clarke from comment #4)

/libexec/ld-elf.so.1 -h does not work.

root@sifive:/usr/src # /libexec/ld-elf.so.1 -h
ELF binary type "0" not known.
-sh: /libexec/ld-elf.so.1: Exec format error

As for the readelf output:

Displaying notes found in: .note.tag
  Owner                Data size        Description
  FreeBSD              0x00000004       NT_FREEBSD_ABI_TAG (ABI version tag)
    ABI tag: 1500068

I'm also pretty sure that the note lives in the first page, which is another
requirement for the tag detection IIRC.

Elf file type is DYN (Shared object file)
Entry point 0x71e0
There are 11 program headers, starting at offset 64

Program Headers:
  Type           Offset   VirtAddr           PhysAddr           FileSiz  MemSiz
  Flg Align
  PHDR           0x000040 0x0000000000000040 0x0000000000000040 0x000268
0x000268 R   0x8
  LOAD           0x000000 0x0000000000000000 0x0000000000000000 0x0061d4
0x0061d4 R   0x1000
  LOAD           0x0061e0 0x00000000000071e0 0x00000000000071e0 0x010548
0x010548 R E 0x1000
  LOAD           0x016728 0x0000000000018728 0x0000000000018728 0x000a20
0x0018d8 RW  0x1000
  LOAD           0x017148 0x000000000001a148 0x000000000001a148 0x000310
0x001108 RW  0x1000
  DYNAMIC        0x016f50 0x0000000000018f50 0x0000000000018f50 0x0000f0
0x0000f0 RW  0x8
  GNU_RELRO      0x016728 0x0000000000018728 0x0000000000018728 0x000a20
0x0018d8 R   0x1
  GNU_EH_FRAME   0x005d24 0x0000000000005d24 0x0000000000005d24 0x000154
0x000154 R   0x4
  GNU_STACK      0x000000 0x0000000000000000 0x0000000000000000 0x000000
0x000000 RW  0x0
  NOTE           0x0002a8 0x00000000000002a8 0x00000000000002a8 0x000018
0x000018 R   0x4
  ATTRIBUTES     0x017458 0x0000000000000000 0x0000000000000000 0x000047
0x000047 R   0x1

 Section to Segment mapping:
  Segment Sections...
   00     
   01     .note.tag .dynsym .gnu.version .gnu.version_d .gnu.hash .hash .dynstr
.rela.dyn .rodata .eh_frame_hdr .eh_frame 
   02     .text 
   03     .data.rel.ro .dynamic .got .relro_padding 
   04     .data .bss 
   05     .dynamic 
   06     .data.rel.ro .dynamic .got .relro_padding 
   07     .eh_frame_hdr 
   08     
   09     .note.tag 
   10     .riscv.attributes 
   None   .comment .gnu.warning.readdir_r .gnu_debuglink .shstrtab 


And for comparison, grep:

root@sifive:/usr/src # readelf -Wn /usr/bin/grep
Displaying notes found in: .note.tag
  Owner                Data size        Description
  FreeBSD              0x00000004       NT_FREEBSD_ABI_TAG (ABI version tag)
    ABI tag: 1500068
  FreeBSD              0x00000004       NT_FREEBSD_FEATURE_CTL (FreeBSD feature
control)
    Feature flags: 0x0
  FreeBSD              0x00000004       NT_FREEBSD_NOINIT_TAG (no .init tag)
   description data: 00 00 00 00


and the headers for grep:

Elf file type is DYN (Shared object file)
Entry point 0x3da0
There are 12 program headers, starting at offset 64

Program Headers:
  Type           Offset   VirtAddr           PhysAddr           FileSiz  MemSiz
  Flg Align
  PHDR           0x000040 0x0000000000000040 0x0000000000000040 0x0002a0
0x0002a0 R   0x8
  INTERP         0x0002e0 0x00000000000002e0 0x0000000000000000 0x000015
0x000015 R   0x1
      [Requesting program interpreter: /libexec/ld-elf.so.1]
  LOAD           0x000000 0x0000000000000000 0x0000000000000000 0x002d78
0x002d78 R   0x1000
  LOAD           0x002d80 0x0000000000003d80 0x0000000000003d80 0x002f40
0x002f40 R E 0x1000
  LOAD           0x005cc0 0x0000000000007cc0 0x0000000000007cc0 0x000920
0x001340 RW  0x1000
  LOAD           0x0065e0 0x00000000000095e0 0x00000000000095e0 0x000250
0x000561 RW  0x1000
  DYNAMIC        0x006290 0x0000000000008290 0x0000000000008290 0x000180
0x000180 RW  0x8
  GNU_RELRO      0x005cc0 0x0000000000007cc0 0x0000000000007cc0 0x000920
0x001340 R   0x1
  GNU_EH_FRAME   0x002920 0x0000000000002920 0x0000000000002920 0x0000d4
0x0000d4 R   0x4
  GNU_STACK      0x000000 0x0000000000000000 0x0000000000000000 0x000000
0x000000 RW  0x0
  NOTE           0x0002f8 0x00000000000002f8 0x00000000000002f8 0x000048
0x000048 R   0x4
  ATTRIBUTES     0x00a014 0x0000000000000000 0x0000000000000000 0x000047
0x000047 R   0x1

 Section to Segment mapping:
  Segment Sections...
   00     
   01     .interp 
   02     .interp .note.tag .dynsym .gnu.version .gnu.version_r .gnu.hash .hash
.dynstr .rela.dyn .rela.plt .rodata .srodata.cst8 .eh_frame_hdr .eh_frame 
   03     .text .init .fini .plt 
   04     .ctors .dtors .data.rel.ro .dynamic .got .relro_padding 
   05     .data .got.plt .sdata .sbss .bss 
   06     .dynamic 
   07     .ctors .dtors .data.rel.ro .dynamic .got .relro_padding 
   08     .eh_frame_hdr 
   09     
   10     .note.tag 
   11     .riscv.attributes 
   None   .comment .gnu_debuglink .shstrtab

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