libphobos: Add section support code for OpenBSD (PR99691)
libphobos/ChangeLog: PR d/99691 * configure: Regenerate. * libdruntime/config/common/threadasm.S: Add __OpenBSD__. * libdruntime/gcc/backtrace.d: Import core.sys.openbsd.dlfcn on OpenBSD platforms. * libdruntime/gcc/sections/elf.d (SharedElf): Define on OpenBSD. (linkMapForHandle): Implement for OpenBSD. (exeLinkMap): Remove. (getDependencies): Adjust dlpi_addr on OpenBSD. (handleForName): Implement for OpenBSD. (IterateManually): Define on OpenBSD. * libdruntime/gcc/sections/package.d (SectionsElf): Define on OpenBSD. * m4/druntime/libraries.m4 (DRUNTIME_LIBRARIES_ATOMIC): Test for enable_libatomic. (DRUNTIME_LIBRARIES_BACKTRACE): Test for enable_libbacktrace.
This commit is contained in:
parent
3bffc4b37e
commit
d86e60855f
6 changed files with 48 additions and 21 deletions
4
libphobos/configure
vendored
4
libphobos/configure
vendored
|
@ -14917,7 +14917,7 @@ fi
|
|||
|
||||
DCFG_HAVE_LIBATOMIC=false
|
||||
LIBATOMIC=
|
||||
if test "x$with_libatomic" != "xno"; then :
|
||||
if test "x$enable_libatomic" != "xno" && test "x$with_libatomic" != "xno"; then :
|
||||
|
||||
DCFG_HAVE_LIBATOMIC=true
|
||||
LIBATOMIC=../../libatomic/libatomic_convenience.la
|
||||
|
@ -14953,7 +14953,7 @@ if test "${with_libbacktrace+set}" = set; then :
|
|||
fi
|
||||
|
||||
|
||||
if test "x$with_libbacktrace" != "xno"; then :
|
||||
if test "x$enable_libbacktrace" != "xno" && test "x$with_libbacktrace" != "xno"; then :
|
||||
|
||||
LIBBACKTRACE=../../libbacktrace/libbacktrace.la
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ a copy of the GCC Runtime Library Exception along with this program;
|
|||
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#if (__linux__ || __FreeBSD__ || __NetBSD__ || __DragonFly__) && __ELF__
|
||||
#if (__linux__ || __FreeBSD__ || __NetBSD__ || __OpenBSD__ || __DragonFly__) && __ELF__
|
||||
/*
|
||||
* Mark the resulting object file as not requiring execution permissions on
|
||||
* stack memory. The absence of this section would mark the whole resulting
|
||||
|
|
|
@ -424,8 +424,10 @@ private:
|
|||
import core.sys.freebsd.dlfcn;
|
||||
else version (NetBSD)
|
||||
import core.sys.netbsd.dlfcn;
|
||||
else version (OpenBSD)
|
||||
import core.sys.openbsd.dlfcn;
|
||||
else version (Solaris)
|
||||
import core.sys.netbsd.dlfcn;
|
||||
import core.sys.solaris.dlfcn;
|
||||
else version (Posix)
|
||||
import core.sys.posix.dlfcn;
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ version (CRuntime_Glibc) enum SharedELF = true;
|
|||
else version (CRuntime_Musl) enum SharedELF = true;
|
||||
else version (FreeBSD) enum SharedELF = true;
|
||||
else version (NetBSD) enum SharedELF = true;
|
||||
else version (OpenBSD) enum SharedELF = true;
|
||||
else version (DragonFlyBSD) enum SharedELF = true;
|
||||
else version (CRuntime_UClibc) enum SharedELF = true;
|
||||
else version (Solaris) enum SharedELF = true;
|
||||
|
@ -62,6 +63,12 @@ else version (NetBSD)
|
|||
import core.sys.netbsd.sys.elf;
|
||||
import core.sys.netbsd.sys.link_elf;
|
||||
}
|
||||
else version (OpenBSD)
|
||||
{
|
||||
import core.sys.openbsd.dlfcn;
|
||||
import core.sys.openbsd.sys.elf;
|
||||
import core.sys.openbsd.sys.link_elf;
|
||||
}
|
||||
else version (DragonFlyBSD)
|
||||
{
|
||||
import core.sys.dragonflybsd.dlfcn;
|
||||
|
@ -688,20 +695,22 @@ version (Shared)
|
|||
@nogc nothrow:
|
||||
link_map* linkMapForHandle(void* handle)
|
||||
{
|
||||
link_map* map;
|
||||
const success = dlinfo(handle, RTLD_DI_LINKMAP, &map) == 0;
|
||||
safeAssert(success, "Failed to get DSO info.");
|
||||
return map;
|
||||
static if (__traits(compiles, RTLD_DI_LINKMAP))
|
||||
{
|
||||
link_map* map;
|
||||
const success = dlinfo(handle, RTLD_DI_LINKMAP, &map) == 0;
|
||||
safeAssert(success, "Failed to get DSO info.");
|
||||
return map;
|
||||
}
|
||||
else version (OpenBSD)
|
||||
{
|
||||
safeAssert(handle !is null, "Failed to get DSO info.");
|
||||
return cast(link_map*)handle;
|
||||
}
|
||||
else
|
||||
static assert(0, "unimplemented");
|
||||
}
|
||||
|
||||
link_map* exeLinkMap(link_map* map)
|
||||
{
|
||||
safeAssert(map !is null, "Invalid link_map.");
|
||||
while (map.l_prev !is null)
|
||||
map = map.l_prev;
|
||||
return map;
|
||||
}
|
||||
|
||||
DSO* dsoForHandle(void* handle)
|
||||
{
|
||||
DSO* pdso;
|
||||
|
@ -766,6 +775,8 @@ version (Shared)
|
|||
strtab = cast(const(char)*)(info.dlpi_addr + dyn.d_un.d_ptr); // relocate
|
||||
else version (NetBSD)
|
||||
strtab = cast(const(char)*)(info.dlpi_addr + dyn.d_un.d_ptr); // relocate
|
||||
else version (OpenBSD)
|
||||
strtab = cast(const(char)*)(info.dlpi_addr + dyn.d_un.d_ptr); // relocate
|
||||
else version (DragonFlyBSD)
|
||||
strtab = cast(const(char)*)(info.dlpi_addr + dyn.d_un.d_ptr); // relocate
|
||||
else version (Solaris)
|
||||
|
@ -795,9 +806,21 @@ version (Shared)
|
|||
|
||||
void* handleForName(const char* name)
|
||||
{
|
||||
auto handle = .dlopen(name, RTLD_NOLOAD | RTLD_LAZY);
|
||||
version (Solaris) { }
|
||||
else if (handle !is null) .dlclose(handle); // drop reference count
|
||||
version (Solaris) enum refCounted = false;
|
||||
else version (OpenBSD) enum refCounted = false;
|
||||
else enum refCounted = true;
|
||||
|
||||
static if (__traits(compiles, RTLD_NOLOAD))
|
||||
enum flags = (RTLD_NOLOAD | RTLD_LAZY);
|
||||
else
|
||||
enum flags = RTLD_LAZY;
|
||||
|
||||
auto handle = .dlopen(name, flags);
|
||||
static if (refCounted)
|
||||
{
|
||||
if (handle !is null)
|
||||
.dlclose(handle); // drop reference count
|
||||
}
|
||||
return handle;
|
||||
}
|
||||
}
|
||||
|
@ -891,6 +914,7 @@ bool findDSOInfoForAddr(in void* addr, dl_phdr_info* result=null) nothrow @nogc
|
|||
{
|
||||
version (linux) enum IterateManually = true;
|
||||
else version (NetBSD) enum IterateManually = true;
|
||||
else version (OpenBSD) enum IterateManually = true;
|
||||
else version (Solaris) enum IterateManually = true;
|
||||
else enum IterateManually = false;
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ version (CRuntime_Musl) version = SectionsElf;
|
|||
version (CRuntime_UClibc) version = SectionsElf;
|
||||
version (FreeBSD) version = SectionsElf;
|
||||
version (NetBSD) version = SectionsElf;
|
||||
version (OpenBSD) version = SectionsElf;
|
||||
version (DragonFlyBSD) version = SectionsElf;
|
||||
version (Solaris) version = SectionsElf;
|
||||
version (OSX) version = SectionsMacho;
|
||||
|
|
|
@ -116,7 +116,7 @@ AC_DEFUN([DRUNTIME_LIBRARIES_ATOMIC],
|
|||
|
||||
DCFG_HAVE_LIBATOMIC=false
|
||||
LIBATOMIC=
|
||||
AS_IF([test "x$with_libatomic" != "xno"], [
|
||||
AS_IF([test "x$enable_libatomic" != "xno" && test "x$with_libatomic" != "xno"], [
|
||||
DCFG_HAVE_LIBATOMIC=true
|
||||
LIBATOMIC=../../libatomic/libatomic_convenience.la
|
||||
], [
|
||||
|
@ -145,7 +145,7 @@ AC_DEFUN([DRUNTIME_LIBRARIES_BACKTRACE],
|
|||
AS_HELP_STRING([--without-libbacktrace],
|
||||
[Do not use libbacktrace in core.runtime (default: auto)]))
|
||||
|
||||
AS_IF([test "x$with_libbacktrace" != "xno"], [
|
||||
AS_IF([test "x$enable_libbacktrace" != "xno" && test "x$with_libbacktrace" != "xno"], [
|
||||
LIBBACKTRACE=../../libbacktrace/libbacktrace.la
|
||||
|
||||
gdc_save_CPPFLAGS=$CPPFLAGS
|
||||
|
|
Loading…
Add table
Reference in a new issue