[all-commits] [llvm/llvm-project] b151c7: [libc] Add `dlfcn.h` placeholder (#97501)

Izaak Schroeder via All-commits all-commits at lists.llvm.org
Sat Jul 6 16:02:21 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: b151c7e36a26a4168d0384c88295099e4b6470d0
      https://github.com/llvm/llvm-project/commit/b151c7e36a26a4168d0384c88295099e4b6470d0
  Author: Izaak Schroeder <izaak.schroeder at gmail.com>
  Date:   2024-07-06 (Sat, 06 Jul 2024)

  Changed paths:
    M libc/config/linux/aarch64/entrypoints.txt
    M libc/config/linux/x86_64/entrypoints.txt
    M libc/docs/dev/undefined_behavior.rst
    M libc/spec/posix.td
    M libc/src/CMakeLists.txt
    A libc/src/dlfcn/CMakeLists.txt
    A libc/src/dlfcn/dlclose.cpp
    A libc/src/dlfcn/dlclose.h
    A libc/src/dlfcn/dlerror.cpp
    A libc/src/dlfcn/dlerror.h
    A libc/src/dlfcn/dlopen.cpp
    A libc/src/dlfcn/dlopen.h
    A libc/src/dlfcn/dlsym.cpp
    A libc/src/dlfcn/dlsym.h

  Log Message:
  -----------
  [libc] Add `dlfcn.h` placeholder (#97501)

Adds `dlopen` and friends. This is needed as part of the effort to
compile `libunwind` + `libc` without baremetal mode. This is part of
https://github.com/llvm/llvm-project/issues/97191. This should still be
spec compliant, since `dlopen` always returns `NULL` and `dlerror`
always returns an error message.

> If dlopen() fails for any reason, it returns NULL.

> The function dlclose() returns 0 on success, and nonzero on error.

> Since the value of the symbol could actually be NULL (so that a NULL
return from dlsym() need not indicate an error), the correct way to test
for an error is to call dlerror() to clear any old error conditions,
then call dlsym(), and then call dlerror() again, saving its return
value into a variable, and check whether this saved value is not NULL.


See:
- https://linux.die.net/man/3/dlopen



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list