LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 33766 - Implement filter library support (-F / --filter)
Summary: Implement filter library support (-F / --filter)
Status: RESOLVED FIXED
Alias: None
Product: lld
Classification: Unclassified
Component: ELF (show other bugs)
Version: unspecified
Hardware: PC FreeBSD
: P enhancement
Assignee: George Rimar
URL:
Keywords:
Depends on:
Blocks: 23214
  Show dependency tree
 
Reported: 2017-07-12 19:14 PDT by emaste
Modified: 2017-07-19 00:07 PDT (History)
3 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description emaste 2017-07-12 19:14:09 PDT
FreeBSD recently added a dummy libdl as a filter library (https://reviews.freebsd.org/rS320872) to ease porting of software from Linux, which expects -ldl to work, and we'd like to support -F/--filter with lld (and presumably -f/--auxiliary also).

Filter library details are here: https://docs.oracle.com/cd/E19683-01/817-3677/chapter4-31738/index.html

Using the FreeBSD change as an example, to produce a filter library we add `-F,libc.so.7`. The primary effect is that the resulting shared object gains a DT_FILTER entry:

Dynamic section at offset 0xd30 contains 25 entries:
  Tag        Type                         Name/Value
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.7]
 0x000000000000000e (SONAME)             Library soname: [libdl.so.1]
 0x000000007fffffff (FILTER)             Filter library: [libc.so.7]

When the runtime loader encounters this it uses the named filtee library (libc.so.7) to resolve symbols from the filter library.
Comment 1 George Rimar 2017-07-13 04:56:41 PDT
(In reply to emaste from comment #0)
> and we'd like to support -F/--filter with
> lld (and presumably -f/--auxiliary also).

Patch implementing -F/--filter is https://reviews.llvm.org/D35352,
and we already provide support for -f/--auxiliary.
Comment 2 Rafael Ávila de Espíndola 2017-07-13 09:26:04 PDT
BTW, does freebsd support Instruction Set Specific Shared Objects?

https://docs.oracle.com/cd/E19683-01/817-3677/6mj8mbtd5/index.html
Comment 3 emaste 2017-07-16 07:34:38 PDT
> BTW, does freebsd support Instruction Set Specific Shared Objects?

We do not have support today - our rtld does not expand $ISALIST.

Kostik will implement it for completeness if we can find a canonical list of possible values somewhere, but in practice GNU ifunc is much more likely to be the approach taken for this kind of use case.
Comment 4 Rafael Ávila de Espíndola 2017-07-17 09:52:27 PDT
(In reply to emaste from comment #3)
> > BTW, does freebsd support Instruction Set Specific Shared Objects?
> 
> We do not have support today - our rtld does not expand $ISALIST.
> 
> Kostik will implement it for completeness if we can find a canonical list of
> possible values somewhere, but in practice GNU ifunc is much more likely to
> be the approach taken for this kind of use case.

Because of the popularity of linux?

I quite like the ISALIST idea. It is less flexible in theory, but should allow the support of non lazy binding too, which is pretty much impossible with ifunc.
Comment 5 emaste 2017-07-18 10:32:21 PDT
> Because of the popularity of linux?

Primarily because it seems cumbersome to have a half dozen or so individual filter libs, and because AFAICT $ISALIST hasn't been updated in several years, so there's a bunch of additional work that seemingly needs to be done to define appropriate recent microarch entries.

In practice we'd use this for things like a small handful of optimized string routines.
Comment 6 George Rimar 2017-07-19 00:07:59 PDT
r308167