pkgsrc-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

golang shlibs on OpenBSD (was: Seeking status reports on unusual operating systems)



Sijmen J. Mulder wrote:
> Sijmen Mulder wrote:
> > Looks like the symlinks are created here, but I don't know why:
> 
> I see now that it links to where the files will end up. Here's the ldd
> output for the binaries in the work directory:
> 
> [...]
> 
> These libraries exist.

Turns out the problem is with how Go 1.16 and up on OpenBSD links libc
and libpthread for Go binaries. Go binaries are usually completely
static[1], directly doing syscalls, but that changed for OpenBSD:

https://utcc.utoronto.ca/~cks/space/blog/programming/Go116OpenBSDUsesLibc

The issue is that the Go compiler doesn't link in versioned
dependencies like libc.so.96.1, as the C linked would, but just just
'libc.so' which doesn't exist on disk [2]. The loader knows how to fix
that up but check-shlibs-elf.awk does not.

Solutions:
 1. Change check-shlibs-elf.awk to deal with unversioned dependencies
    (that don't exist on disk)
 2. Change how Go links in libc and libpthread
 3. Skip check-shlibs on Go products

Sijmen
 

=== [1] Static go product on Linux & NetBSD ===

debian$ readelf -Wd /var/work/lang/go117/work/go/bin/gofmt
There is no dynamic section in this file.

netbsd9$ readelf -Wd /var/work/lang/go117/work/go/bin/gofmt
There is no dynamic section in this file.


=== [2] go and gofmt linkign on OpenBSD ===

openbsd$ readelf -Wd /var/work/lang/go117/work/go/bin/go{,fmt}

File: /var/work/lang/go117/work/go/bin/go

Dynamic section at offset 0x9d3020 contains 16 entries:
  Tag        Type                         Name/Value
 0x0000000000000004 (HASH)               0xb42340
 0x0000000000000006 (SYMTAB)             0xb42ba0
 0x000000000000000b (SYMENT)             24 (bytes)
 0x0000000000000005 (STRTAB)             0xb42740
 0x000000000000000a (STRSZ)              1115 (bytes)
 0x0000000000000007 (RELA)               0xb417f8
 0x0000000000000008 (RELASZ)             24 (bytes)
 0x0000000000000009 (RELAENT)            24 (bytes)
 0x0000000000000003 (PLTGOT)             0xdd3120
 0x0000000000000015 (DEBUG)              0x0
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.96.1]
 0x0000000000000001 (NEEDED)             Shared library: [libpthread.so.26.1]
 0x0000000000000014 (PLTREL)             RELA
 0x0000000000000002 (PLTRELSZ)           2592 (bytes)
 0x0000000000000017 (JMPREL)             0xb41810
 0x0000000000000000 (NULL)               0x0

File: /var/work/lang/go117/work/go/bin/gofmt

Dynamic section at offset 0x22b020 contains 16 entries:
  Tag        Type                         Name/Value
 0x0000000000000004 (HASH)               0x586a20
 0x0000000000000006 (SYMTAB)             0x586f60
 0x000000000000000b (SYMENT)             24 (bytes)
 0x0000000000000005 (STRTAB)             0x586d40
 0x000000000000000a (STRSZ)              526 (bytes)
 0x0000000000000007 (RELA)               0x586428
 0x0000000000000008 (RELASZ)             0 (bytes)
 0x0000000000000009 (RELAENT)            24 (bytes)
 0x0000000000000003 (PLTGOT)             0x62b120
 0x0000000000000015 (DEBUG)              0x0
 0x0000000000000001 (NEEDED)             Shared library: [libc.so]
 0x0000000000000001 (NEEDED)             Shared library: [libpthread.so]
 0x0000000000000014 (PLTREL)             RELA
 0x0000000000000002 (PLTRELSZ)           1392 (bytes)
 0x0000000000000017 (JMPREL)             0x586428
 0x0000000000000000 (NULL)               0x0

openbsd$ file /usr/lib/libc.so{,.96.1} 
/usr/lib/libc.so:      cannot stat '/usr/lib/libc.so' (No such file or directory)
/usr/lib/libc.so.96.1: ELF 64-bit LSB shared object, x86-64, version 


Home | Main Index | Thread Index | Old Index