[Bug 275393] RTLD_DEEPBIND semantics not quite right

From: <bugzilla-noreply_at_freebsd.org>
Date: Mon, 27 Nov 2023 21:42:56 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=275393

            Bug ID: 275393
           Summary: RTLD_DEEPBIND semantics not quite right
           Product: Base System
           Version: Unspecified
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: kevans@freebsd.org

Created attachment 246617
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=246617&action=edit
Minimal reproducer

Consider the attached example, with a build.sh to build it:

libutil provides get_value, set_value -- it's built into both libutil.so and
libutil2.so, two separate libraries with purposefully conflicting symbols

libfoo provides print_value (which calls get_value) and links against libutil2

app links against libutil and dlopens $ORIGIN/libfoo.so with RTLD_DEEPBIND and
calls set_value(5) to get a different value for get_value()

On Linux, this prints:

% ./app
application value 5
library value: 10

On FreeBSD:

$ ./app  
application value 5
library value: 5

So under glibc, symbol_lookup from the dlopened image prefers symbols from the
same chain of objects that were loaded at that dlopen time, not just the same
image.

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