Re: [PATCH v2 06/11] libmultipath: add callback for remove_map()

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

 



On Tue, 2022-03-22 at 09:59 -0500, Benjamin Marzinski wrote:
> 
> So all of the exported symbols from libmultipath are weak? Good to
> know.

No, "weak" has a special meaning. For dynamic linking, it's default
behavior to resolve symbols by name and use the first definition
encountered. This means that a symbol in a shared library will always
be overridden by a symbol of the same name in the main executable.

"When resolving symbolic references, the dynamic linker examines the
symbol tables with a breadth-first search. That is, it first looks at
the symbol table of the executable program itself, then at the symbol
tables of the DT_NEEDED entries (in order), then at the second level
DT_NEEDED entries, and so on." ([1], III, p. 2-12). The "weak"
attribute only matters during static linking ([1], III, p. 1-5). See
also the description of LD_DYNAMIC_WEAK in ld.so(8) [2].

I didn't understand this clearly before. And the documentation, in
particular the explanation of the "weak" attribute in the gcc docs, is
misleading, because it doesn't explain the difference between static
and dynamic linking [3].

Regards
Martin

[1] https://refspecs.linuxfoundation.org/elf/elf.pdf
[2] https://man7.org/linux/man-pages/man8/ld.so.8.html

[3] https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#Common-Function-Attributes


--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://listman.redhat.com/mailman/listinfo/dm-devel




[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux