Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 31 Dec 2020 16:08:30 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 252307] dlopen (without RTLD_GLOBAL) overrides weak symbols in libc
Message-ID:  <bug-252307-227@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D252307

            Bug ID: 252307
           Summary: dlopen (without RTLD_GLOBAL) overrides weak symbols in
                    libc
           Product: Base System
           Version: 12.2-RELEASE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: iwtcex@gmail.com

See the comment at https://bugs.winehq.org/show_bug.cgi?id=3D50257#c20 for
context.

% cat weak_sym_override_test.c=20
#include <assert.h>
#include <dlfcn.h>
#include <stdlib.h>
#include <stdio.h>

#if SHLIB
void* calloc(size_t number, size_t size) {
  printf("libc called\n");
  exit(1);
}
#else
int main() {
  assert(dlopen("override.so", RTLD_NOW) !=3D NULL);
  setenv("WHATEVER", "1", 0); // uses calloc internally
  return 0;
}
#endif
% cc -shared -fPIC -DSHLIB weak_sym_override_test.c -o override.so && cc
weak_sym_override_test.c -Wl,-rpath,. -o test
% ./test=20
libc called

Doesn't happen with LD_BIND_NOW=3D1. No idea how that works on Linux, glibc
consistently avoids calling weak symbols it exports, preferring internal
versions prefixed with with __ (two underscores) instead, thus there is no
obvious way to test it.

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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-252307-227>