Re: util-linux-2.41 breaks static build of btrfs-progs

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

 



On Sun, Apr 20, 2025 at 09:24:43PM +0200, Stanislav Brabec wrote:
> Static build of btrfs-progs fails with util-linux-2.41 with a simple
> problem:
> Symbol parse_range becomes visible in libblkid.a, breaking parse-utils.c in
> btrfs-progs, using the same symbol.
> 
> The question is:
> Should be this fixed by util-linux by prefixing of ul_ to all symbols that
> are not declared as static?

I think the ul_ prefix should be used for all generic names like
parse_range(). I'm not sure if I want to use it strictly for all
functions, as the set of functions is large and such conflicts are
very rare.

ChatGPT has an interesting suggestion: add the prefix to the .a
library using "objcopy --redefine-syms" for all non-API and non-static
functions.

        #!/bin/bash
        PREFIX=foo_

        # Extract all global (non-static) function symbols from the .a file
        nm -g --defined-only libmylib.a | awk '{print $3}' | grep -v "^$PREFIX" | sort -u > tmp.syms

        # Generate rename list: <old> <new>
        awk -v pfx="$PREFIX" '{print $1 " " pfx $1}' tmp.syms > rename.syms

        # Apply symbol renaming
        objcopy --redefine-syms=rename.syms libmylib.a libmylib_prefixed.a


Maybe it's elegant way to go. Not sure, not tested :-)

    Karel

-- 
 Karel Zak  <kzak@xxxxxxxxxx>
 http://karelzak.blogspot.com





[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux