From 7d77bbc5cd41020a0121f7ccb0d7b4e354ed3216 Mon Sep 17 00:00:00 2001 From: Dadoum Date: Tue, 23 May 2023 18:48:50 +0200 Subject: [PATCH 01/19] Begin the work on Windows support --- .gitignore | 1 + anisette_server/app.d | 14 +- dub.sdl | 1 + dub.selections.json | 10 - lib/provision/adi.d | 48 +- lib/provision/androidlibrary.d | 54 +- lib/provision/compat/general.d | 50 + lib/provision/compat/linux.d | 36 + lib/provision/compat/windows.d | 282 ++++ lib/provision/symbols.d | 27 +- lib/std_edit/README | 10 + lib/std_edit/elf.d | 2532 ++++++++++++++++++++++++++++++++ lib/std_edit/link.d | 185 +++ mkcassette/app.d | 13 +- retrieve_headers/app.d | 28 +- 15 files changed, 3218 insertions(+), 73 deletions(-) delete mode 100644 dub.selections.json create mode 100644 lib/provision/compat/general.d create mode 100644 lib/provision/compat/linux.d create mode 100644 lib/provision/compat/windows.d create mode 100644 lib/std_edit/README create mode 100644 lib/std_edit/elf.d create mode 100644 lib/std_edit/link.d diff --git a/.gitignore b/.gitignore index e4e9e26..6f0531e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ bin/ .dub/ +dub.selections.json diff --git a/anisette_server/app.d b/anisette_server/app.d index 2deb6fa..053be52 100644 --- a/anisette_server/app.d +++ b/anisette_server/app.d @@ -9,6 +9,7 @@ import std.getopt; import std.math; import std.net.curl; import std.parallelism; +import process = std.process; import std.path; import std.zip; @@ -49,9 +50,20 @@ void main(string[] args) { serverConfig.port = 6969; bool rememberMachine = true; - string configurationPath = expandTilde("~/.config/Provision"); bool onlyInit = false; bool apkDownloadAllowed = true; + version (Windows) { + string configurationPath = process.environment["LocalAppData"].buildPath("Provision"); + } else { + string configurationPath; + string xdgConfigPath = process.environment.get("XDG_CONFIG_HOME"); + if (xdgConfigPath) { + configurationPath = xdgConfigPath.buildPath("Provision"); + } else { + configurationPath = expandTilde("~/.config/Provision/"); + } + } + auto helpInformation = getopt( args, "n|host", format!"The hostname to bind to (default: %s)"(serverConfig.hostname), &serverConfig.hostname, diff --git a/dub.sdl b/dub.sdl index e24c3dc..dd2a496 100644 --- a/dub.sdl +++ b/dub.sdl @@ -29,6 +29,7 @@ subPackage { sourcePaths "retrieve_headers" dependency "provision" version="*" + lflags "/usr/x86_64-w64-mingw32ucrt/sys-root/mingw/lib/libws2_32.a" "/usr/x86_64-w64-mingw32ucrt/sys-root/mingw/lib/libmincore.a" "/usr/x86_64-w64-mingw32ucrt/sys-root/mingw/lib/libwsock32.a" platform="gdc" } subPackage { diff --git a/dub.selections.json b/dub.selections.json deleted file mode 100644 index 271c2e1..0000000 --- a/dub.selections.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "fileVersion": 1, - "versions": { - "dxml": "0.4.3", - "handy-httpd": "5.2.1", - "httparsed": "1.2.1", - "plist": "~master", - "slf4d": "2.1.1" - } -} diff --git a/lib/provision/adi.d b/lib/provision/adi.d index 5daff04..ba13ee1 100644 --- a/lib/provision/adi.d +++ b/lib/provision/adi.d @@ -13,6 +13,8 @@ import std.string; import slf4d; +import provision.compat.general; + version (LibPlist) { import provision.plist; } else { @@ -33,18 +35,18 @@ alias ADIDispose_t = extern(C) int function(void*); alias ADIOTPRequest_t = extern(C) int function(ulong, ubyte**, uint*, ubyte**, uint*); public class ADI { - private ADILoadLibraryWithPath_t pADILoadLibraryWithPath; - private ADISetAndroidID_t pADISetAndroidID; - private ADISetProvisioningPath_t pADISetProvisioningPath; - - private ADIProvisioningErase_t pADIProvisioningErase; - private ADISynchronize_t pADISynchronize; - private ADIProvisioningDestroy_t pADIProvisioningDestroy; - private ADIProvisioningEnd_t pADIProvisioningEnd; - private ADIProvisioningStart_t pADIProvisioningStart; - private ADIGetLoginCode_t pADIGetLoginCode; - private ADIDispose_t pADIDispose; - private ADIOTPRequest_t pADIOTPRequest; + package ADILoadLibraryWithPath_t pADILoadLibraryWithPath; + package ADISetAndroidID_t pADISetAndroidID; + package ADISetProvisioningPath_t pADISetProvisioningPath; + + package ADIProvisioningErase_t pADIProvisioningErase; + package ADISynchronize_t pADISynchronize; + package ADIProvisioningDestroy_t pADIProvisioningDestroy; + package ADIProvisioningEnd_t pADIProvisioningEnd; + package ADIProvisioningStart_t pADIProvisioningStart; + package ADIGetLoginCode_t pADIGetLoginCode; + package ADIDispose_t pADIDispose; + package ADIOTPRequest_t pADIOTPRequest; private AndroidLibrary storeServicesCore; private Logger logger; @@ -56,7 +58,7 @@ public class ADI { public void provisioningPath(string path) { __provisioningPath = path; - pADISetProvisioningPath(path.toStringz).unwrapADIError(); + pADISetProvisioningPath.androidInvoke(path.toStringz).unwrapADIError(); } private string __identifier; @@ -66,7 +68,7 @@ public class ADI { public void identifier(string identifier) { __identifier = identifier; - pADISetAndroidID(identifier.ptr, cast(uint) identifier.length).unwrapADIError(); + pADISetAndroidID.androidInvoke(identifier.ptr, cast(uint) identifier.length).unwrapADIError(); } public this(string libraryPath) { @@ -119,11 +121,11 @@ public class ADI { } public void loadLibrary(string libraryPath) { - pADILoadLibraryWithPath(libraryPath.toStringz).unwrapADIError(); + pADILoadLibraryWithPath.androidInvoke(cast(const(char*)) libraryPath.toStringz).unwrapADIError(); } public void eraseProvisioning(ulong dsId) { - pADIProvisioningErase(dsId).unwrapADIError(); + pADIProvisioningErase.androidInvoke(dsId).unwrapADIError(); } struct SynchronizationResumeMetadata { @@ -152,7 +154,7 @@ public class ADI { ubyte* mid; uint midLength; - pADISynchronize( + pADISynchronize.androidInvoke( dsId, serverIntermediateMetadata.ptr, cast(uint) serverIntermediateMetadata.length, @@ -166,11 +168,11 @@ public class ADI { } public void destroyProvisioning(uint session) { - pADIProvisioningDestroy(session).unwrapADIError(); + pADIProvisioningDestroy.androidInvoke(session).unwrapADIError(); } public void endProvisioning(uint session, ubyte[] persistentTokenMetadata, ubyte[] trustKey) { - pADIProvisioningEnd( + pADIProvisioningEnd.androidInvoke( session, persistentTokenMetadata.ptr, cast(uint) persistentTokenMetadata.length, @@ -203,7 +205,7 @@ public class ADI { uint cpimLength; uint session; - pADIProvisioningStart( + pADIProvisioningStart.androidInvoke( dsId, serverProvisioningIntermediateMetadata.ptr, cast(uint) serverProvisioningIntermediateMetadata.length, @@ -216,7 +218,7 @@ public class ADI { } public bool isMachineProvisioned(ulong dsId) { - int errorCode = pADIGetLoginCode(dsId); + int errorCode = pADIGetLoginCode.androidInvoke(dsId); if (errorCode == 0) { return true; @@ -228,7 +230,7 @@ public class ADI { } public void dispose(void* ptr) { - pADIDispose(ptr).unwrapADIError(); + pADIDispose.androidInvoke(ptr).unwrapADIError(); } struct OneTimePassword { @@ -257,7 +259,7 @@ public class ADI { ubyte* mid; uint midLength; - pADIOTPRequest( + pADIOTPRequest.androidInvoke( dsId, &mid, &midLength, diff --git a/lib/provision/androidlibrary.d b/lib/provision/androidlibrary.d index 3262ff1..256f117 100644 --- a/lib/provision/androidlibrary.d +++ b/lib/provision/androidlibrary.d @@ -5,8 +5,6 @@ import core.memory; import core.stdc.errno; import core.stdc.stdint; import core.stdc.stdlib; -import core.sys.linux.elf; -import core.sys.linux.link; import core.sys.posix.sys.mman; import std.algorithm; import std.conv; @@ -23,6 +21,10 @@ import std.traits; import slf4d; +import std_edit.elf; +import std_edit.link; +import provision.compat.windows; + public class AndroidLibrary { package MmFile elfFile; package void[] allocation; @@ -74,14 +76,9 @@ public class AndroidLibrary { auto alignedMaximumMemory = pageCeil(maximumMemory); auto allocSize = alignedMaximumMemory - alignedMinimum; - auto mmapped_alloc = mmap(null, allocSize, PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_ANON, -1, 0); - if (mmapped_alloc == MAP_FAILED) { - throw new LoaderException("Cannot allocate the memory: " ~ to!string(errno)); - } - memoryTable[MemoryBlock(cast(size_t) mmapped_alloc, cast(size_t) mmapped_alloc + allocSize)] = this; - getLogger().traceF!"Allocating %x - %x for %s"(cast(size_t) mmapped_alloc, cast(size_t) mmapped_alloc + allocSize, libraryName); - allocation = mmapped_alloc[0..allocSize]; + allocation = MmapAllocator.instance.allocate(allocSize); + memoryTable[MemoryBlock(cast(size_t) allocation.ptr, cast(size_t) allocation.ptr + allocSize)] = this; + getLogger().traceF!"Allocating %x - %x for %s"(cast(size_t) allocation.ptr, cast(size_t) allocation.ptr + allocSize, libraryName); size_t fileStart; size_t fileEnd; @@ -144,7 +141,7 @@ public class AndroidLibrary { } if (allocation) { - munmap(allocation.ptr, allocation.length); + MmapAllocator.instance.deallocate(allocation); } } @@ -255,12 +252,35 @@ AndroidLibrary memoryOwner(size_t address) { return null; } -import core.sys.linux.execinfo; -pragma(inline, true) AndroidLibrary rootLibrary() { - enum MAXFRAMES = 4; - void*[MAXFRAMES] callstack; - auto numframes = backtrace(callstack.ptr, MAXFRAMES); - return memoryOwner(cast(size_t) callstack[numframes - 1]); +version (linux) { + import core.sys.linux.execinfo; + pragma(inline, true) AndroidLibrary rootLibrary() { + enum MAXFRAMES = 4; + void*[MAXFRAMES] callstack; + auto numframes = backtrace(callstack.ptr, MAXFRAMES); + return memoryOwner(cast(size_t) callstack[numframes - 1]); + } +} else version (Windows) { + version (LDC) { // Seems to work consistently, but LLVM only. + pragma(LDC_intrinsic, "llvm.returnaddress") + ubyte* return_address(int); + + import core.sys.windows.stacktrace; + pragma(inline, true) AndroidLibrary rootLibrary(ubyte* address = return_address(0)) { + assert(address != null); + return memoryOwner(cast(size_t) address); + } + } else { // Works on a real Windows machine, but not Wine + import core.sys.windows.stacktrace; + pragma(inline, true) AndroidLibrary rootLibrary() { + auto callstack = StackTrace.trace(); + auto address = cast(size_t) callstack[$ - 1]; + assert(address != 0); + return memoryOwner(address); + } + } +} else { + static assert("Unsupported platform."); } interface SymbolHashTable { diff --git a/lib/provision/compat/general.d b/lib/provision/compat/general.d new file mode 100644 index 0000000..be64dba --- /dev/null +++ b/lib/provision/compat/general.d @@ -0,0 +1,50 @@ +module provision.compat.general; + +version (linux) { + import std.meta; + alias sysv = AliasSeq!(); +} else { + version (LDC) { + import ldc.attributes; + enum sysv = callingConvention("sysv_abi"); + } else version (GNU) { + import gcc.attributes; + // enum sysv = attribute("sysv_abi"); + import std.meta; + alias sysv = AliasSeq!(); + } else { + static assert(false, "Your compiler is not supported on your platform, please use LDC2 or GDC."); + } +} + +version (Windows) { + version (X86) { + version = WindowsHacks; + } + version (X86_64) { + version = WindowsHacks; + } +} + +version (WindowsHacks) { + import std.traits; + pragma(inline, false) auto androidInvoke(T, G...)(T delegate_, G params) { + void* del = cast(void*) delegate_; + + pragma(inline, false) extern(C) ReturnType!T internal(Parameters!T params, void* del) @naked @sysv { // HACK + asm { + "jmp *%0" :: "r" (del); + } + } + + import slf4d; + getLogger().traceF!"Calling ? %x%s"(del, G.stringof); + import std.stdio; + stdout.flush(); + return internal(params, del); + } +} else { + pragma(inline, true) auto androidInvoke(T, G...)(T delegate_, G params) { + return delegate_(params); + } +} diff --git a/lib/provision/compat/linux.d b/lib/provision/compat/linux.d new file mode 100644 index 0000000..a837cba --- /dev/null +++ b/lib/provision/compat/linux.d @@ -0,0 +1,36 @@ +module provision.compat.linux; + +version (linux): + +import core.stdc.errno; +import core.stdc.stdlib; +import core.stdc.string; +import core.sys.posix.fcntl; +import core.sys.posix.sys.stat; +import core.sys.posix.sys.time; +import core.sys.posix.unistd; + +template traceCall(alias U) { + import std.traits; + import slf4d; + auto ref traceCall(Parameters!U params) { + getLogger().traceF!"CALL // %s"(__traits(identifier, U)); + return U(params); + } +} + +alias __errno_location = traceCall!(errno); +alias strncpy = traceCall!(core.stdc.string.strncpy); +alias lstat = traceCall!(core.sys.posix.sys.stat.lstat); +alias fstat = traceCall!(core.sys.posix.sys.stat.fstat); +alias malloc = core.stdc.stdlib.malloc; +alias free = core.stdc.stdlib.free; +alias gettimeofday = traceCall!(core.sys.posix.sys.time.gettimeofday); +alias open = traceCall!(core.sys.posix.fcntl.open); +alias close = traceCall!(core.sys.posix.unistd.close); +alias read = traceCall!(core.sys.posix.unistd.read); +alias write = traceCall!(core.sys.posix.unistd.write); +alias mkdir = traceCall!(core.sys.posix.fcntl.mkdir); +alias chmod = traceCall!(core.sys.posix.fcntl.chmod); +alias ftruncate = traceCall!(core.sys.posix.unistd.ftruncate); +alias umask = traceCall!(core.sys.posix.sys.stat.umask); diff --git a/lib/provision/compat/windows.d b/lib/provision/compat/windows.d new file mode 100644 index 0000000..ac4e18b --- /dev/null +++ b/lib/provision/compat/windows.d @@ -0,0 +1,282 @@ +module provision.compat.windows; + +version (Windows): + +import core.stdc.stdio; +import core.sys.windows.stat; +import core.sys.windows.stdc.time; +import core.sys.windows.winbase; +import core.sys.windows.winnt; + +import std.conv; +import std.datetime; +import std.string; + +import slf4d; + +import provision.compat.general; + +private extern (C) { + alias mode_t = uint; + + struct timespec { + time_t tv_sec; + long tv_nsec; + } + + struct timeval { + size_t tv_sec; + size_t tv_usec; + } + + struct linux_stat { + ulong st_dev; + ulong st_ino; + ulong st_nlink; + uint st_mode; + uint st_uid; + uint st_gid; + uint __pad0; + ulong st_rdev; + long st_size; + long st_blksize; + long st_blocks; + long st_atime; + long st_atimensec; + long st_mtime; + long st_mtimensec; + long st_ctime; + long st_ctimensec; + long[3] __unused; + } + + size_t _chsize(ulong handle, ulong length); + pragma(mangle, "mkdir") int _mkdir(const scope char*, mode_t); + pragma(mangle, "chmod") int _chmod(const scope char*, mode_t); + int _read(int fd, void* buf, uint count); + int _write(int fd, void* buf, uint count); +} + +public import core.stdc.errno; +public import core.stdc.stdlib; +public import core.stdc.string; + +enum PROT_NONE = 0x0; +enum PROT_READ = 0x1; +enum PROT_WRITE = 0x2; +enum PROT_EXEC = 0x4; + +@sysv: + +pragma(inline, true) uint protectionToWindows(int x) pure { + final switch (x) { + case PROT_NONE: + return PAGE_NOACCESS; + case PROT_READ: + return PAGE_READONLY; + case PROT_WRITE: + return PAGE_READWRITE; + case PROT_EXEC: + return PAGE_EXECUTE; + case PROT_READ | PROT_WRITE: + return PAGE_READWRITE; + case PROT_WRITE | PROT_EXEC: + return PAGE_EXECUTE_READWRITE; + case PROT_EXEC | PROT_READ: + return PAGE_EXECUTE_READ; + case PROT_READ | PROT_WRITE | PROT_EXEC: + return PAGE_EXECUTE_READWRITE; + } +} + +void* malloc(size_t size) { + return core.stdc.stdlib.malloc(size); +} + +void free(void* ptr) { + return core.stdc.stdlib.free(ptr); +} + +ref int __errno_location2() { + getLogger().debugF!"CALL // errno: %d"(errno()); + errno = 0; + return errno(); +} + +alias __errno_location = __errno_location2; + +char* strncpy(return scope char* s1, scope const char* s2, size_t n) { + getLogger().debugF!"CALL // strncpy 0x%x -(%d)-> 0x%x"(s1, /+ s1[0..n],+/ n, s2); + return core.stdc.string.strncpy(s1, s2, n); +} + +size_t umask(size_t s) { + getLogger().debug_("CALL // umask"); + return s; +} + +size_t ftruncate(ulong handle, ulong length) { + getLogger().debug_("CALL // ftruncate"); + return _chsize(handle, length); +} + +int gettimeofday(timeval* tv, void* tz) { + getLogger().debug_("CALL // gettimeofday"); + auto time = Clock.currTime(); + *tv = timeval(time.toUnixTime(), time.fracSecs.total!"usecs"); + getLogger().debugF!" -> gettimeofday %s"(*tv); + + return 0; +} + +int chmod(const(char)* path, int mode) { + getLogger().debug_("CALL // chmod"); + return _chmod(path.toWindowsPath(), mode); +} + +int mkdir(const(char)* path, int mode) { + getLogger().debug_("CALL // mkdir"); + return _mkdir(path.toWindowsPath(), mode); +} + +const(char)* toWindowsPath(const(char)* c) { + import std.algorithm.iteration; + import std.array; + import std.string; + import std.conv; + + return c.fromStringz() + .chompPrefix("//?/") + .map!((c) => (c == '/') ? '\\' : c) + .array() + .to!string() + .toStringz(); +} + +int lstat(const(char)* path, linux_stat* out_) { + struct_stat stat_windows; + getLogger().traceF!"CALL // lstat: %s"(path.toWindowsPath.fromStringz); + int ret = stat(path.toWindowsPath(), &stat_windows); + + uint mode = octal!555; + + if (stat_windows.st_mode & octal!11) { + mode |= octal!200; + } + + if (stat_windows.st_mode & octal!4000) { + mode |= octal!40000; + } + + auto atime = stat_windows.st_atime / 10000000; + auto mtime = stat_windows.st_mtime / 10000000; + auto ctime = stat_windows.st_ctime / 10000000; + + *out_ = linux_stat( + stat_windows.st_dev, + stat_windows.st_ino, + stat_windows.st_nlink, + mode, + stat_windows.st_uid, + stat_windows.st_gid, + 0, + stat_windows.st_rdev, + stat_windows.st_size, + 0, + 0, + atime, + 0, + mtime, + 0, + ctime, + 0, + [0, 0, 0] + ); + getLogger().traceF!"-> lstat %s"(*out_); + + return ret; +} + +int open(const(char)* path, int oflag) { + getLogger().debug_("CALL // open"); + + int convertedOflag = 0x8000; // Binary mode + + if (oflag & octal!100) { + convertedOflag |= O_CREAT; + } + + if (oflag & octal!1) { + convertedOflag |= O_WRONLY; + } else if (oflag & octal!2) { + convertedOflag |= O_RDWR; + } else { + convertedOflag |= O_RDONLY; + } + + return _open(path, convertedOflag); +} + +int close(int fd) { + getLogger().debug_("CALL // close"); + return _close(fd); +} + +int read(int fd, void* buf, uint count) { + getLogger().debug_("CALL // read"); + return _read(fd, buf, count); +} + +int write(int fd, void* buf, uint count) { + getLogger().debug_("CALL // write"); + return _write(fd, buf, count); +} + +int fstat(int fd, linux_stat* out_) { + struct_stat stat_windows; + getLogger().trace("CALL // fstat"); + int ret = core.sys.windows.stat.fstat(fd, &stat_windows); + + uint mode = octal!555; + + if (stat_windows.st_mode & octal!11) { + mode |= octal!200; + } + + if (stat_windows.st_mode & octal!4000) { + mode |= octal!40000; + } + + auto atime = stat_windows.st_atime / 10000000; + auto mtime = stat_windows.st_mtime / 10000000; + auto ctime = stat_windows.st_ctime / 10000000; + + *out_ = linux_stat( + stat_windows.st_dev, + stat_windows.st_ino, + stat_windows.st_nlink, + mode, + stat_windows.st_uid, + stat_windows.st_gid, + 0, + stat_windows.st_rdev, + stat_windows.st_size, + 0, + 0, + atime, + 0, + mtime, + 0, + ctime, + 0, + [0, 0, 0] + ); + getLogger().traceF!"-> fstat %s"(*out_); + + return ret; +} + +int mprotect(void* ptr, size_t size, int newProtection) { + uint oldProtection = void; + return !VirtualProtect(ptr, size, newProtection.protectionToWindows(), &oldProtection); +} diff --git a/lib/provision/symbols.d b/lib/provision/symbols.d index 766457e..d24c603 100644 --- a/lib/provision/symbols.d +++ b/lib/provision/symbols.d @@ -1,13 +1,6 @@ module provision.symbols; import core.memory; -import core.stdc.errno; -import core.stdc.stdlib; -import core.stdc.string; -import core.sys.posix.fcntl; -import core.sys.posix.sys.stat; -import core.sys.posix.sys.time; -import core.sys.posix.unistd; import provision.androidlibrary; import std.algorithm.mutation; import std.experimental.allocator; @@ -18,9 +11,13 @@ import std.traits : Parameters, ReturnType; import slf4d; +import provision.compat.general; +import provision.compat.windows; +import provision.compat.linux; + __gshared: -private extern (C) int __system_property_get_impl(const char* n, char* value) { +private @sysv extern (C) int __system_property_get_impl(const char* n, char* value) { auto name = n.fromStringz; enum str = "no s/n number"; @@ -29,19 +26,19 @@ private extern (C) int __system_property_get_impl(const char* n, char* value) { return cast(int) str.length; } -private extern (C) uint arc4random_impl() { +private @sysv extern (C) uint arc4random_impl() { return Random(unpredictableSeed()).front; } -private extern (C) int emptyStub() { +private @sysv extern (C) int emptyStub() { return 0; } -private extern (C) noreturn undefinedSymbol() { +private @sysv extern (C) noreturn undefinedSymbol() { throw new UndefinedSymbolException(); } -private extern (C) AndroidLibrary dlopenWrapper(const char* name) { +private @sysv extern (C) AndroidLibrary dlopenWrapper(const char* name) { debug { getLogger().traceF!"Attempting to load %s"(name.fromStringz()); } @@ -55,14 +52,14 @@ private extern (C) AndroidLibrary dlopenWrapper(const char* name) { } } -private extern (C) void* dlsymWrapper(AndroidLibrary library, const char* symbolName) { +private @sysv extern (C) void* dlsymWrapper(AndroidLibrary library, const char* symbolName) { debug { getLogger().traceF!"Attempting to load symbol %s"(symbolName.fromStringz()); } return library.load(cast(string) symbolName.fromStringz()); } -private extern (C) void dlcloseWrapper(AndroidLibrary library) { +private @sysv extern (C) void dlcloseWrapper(AndroidLibrary library) { if (library) { rootLibrary().loadedLibraries.remove!((lib) => lib == library); destroy(library); @@ -143,7 +140,7 @@ package void* lookupSymbol(string str) { {"pthread_rwlock_unlock", &emptyStub}, {"pthread_rwlock_destroy", &emptyStub}, {""}, {"free", &free}, {"fstat", &fstat}, {"pthread_rwlock_wrlock", &emptyStub}, - {"__errno", &errno}, {""}, {"pthread_rwlock_init", &emptyStub}, + {"__errno", &__errno_location}, {""}, {"pthread_rwlock_init", &emptyStub}, {"pthread_mutex_unlock", &emptyStub}, {"pthread_rwlock_rdlock", &emptyStub}, { "gettimeofday", diff --git a/lib/std_edit/README b/lib/std_edit/README new file mode 100644 index 0000000..4b257f2 --- /dev/null +++ b/lib/std_edit/README @@ -0,0 +1,10 @@ +the files in this folder has been taken from LDC2 import folder and have been modified to be small and cross-platform. + +compiler information : + +LDC - the LLVM D compiler (1.30.0): + based on DMD v2.100.1 and LLVM 14.0.5 + built with LDC - the LLVM D compiler (1.30.0) + Default target: x86_64-redhat-linux-gnu + Host CPU: skylake + http://dlang.org - http://wiki.dlang.org/LDC diff --git a/lib/std_edit/elf.d b/lib/std_edit/elf.d new file mode 100644 index 0000000..d14df3c --- /dev/null +++ b/lib/std_edit/elf.d @@ -0,0 +1,2532 @@ +/** + * D header file for GNU/Linux + * + * $(LINK2 http://sourceware.org/git/?p=glibc.git;a=blob;f=elf/elf.h, glibc elf/elf.h) + */ +module std_edit.elf; + +extern (C): +pure: +nothrow: +@system: + +import core.stdc.stdint; + +alias uint16_t Elf32_Half; +alias uint16_t Elf64_Half; + +alias uint32_t Elf32_Word; +alias int32_t Elf32_Sword; +alias uint32_t Elf64_Word; +alias int32_t Elf64_Sword; + +alias uint64_t Elf32_Xword; +alias int64_t Elf32_Sxword; +alias uint64_t Elf64_Xword; +alias int64_t Elf64_Sxword; + +alias uint32_t Elf32_Addr; +alias uint64_t Elf64_Addr; + +alias uint32_t Elf32_Off; +alias uint64_t Elf64_Off; + +alias uint16_t Elf32_Section; +alias uint16_t Elf64_Section; + +alias Elf32_Half Elf32_Versym; +alias Elf64_Half Elf64_Versym; + + +enum EI_NIDENT = 16; + +struct Elf32_Ehdr +{ + char[EI_NIDENT] e_ident = 0; + Elf32_Half e_type; + Elf32_Half e_machine; + Elf32_Word e_version; + Elf32_Addr e_entry; + Elf32_Off e_phoff; + Elf32_Off e_shoff; + Elf32_Word e_flags; + Elf32_Half e_ehsize; + Elf32_Half e_phentsize; + Elf32_Half e_phnum; + Elf32_Half e_shentsize; + Elf32_Half e_shnum; + Elf32_Half e_shstrndx; +} + +struct Elf64_Ehdr +{ + char[EI_NIDENT] e_ident = 0; + Elf64_Half e_type; + Elf64_Half e_machine; + Elf64_Word e_version; + Elf64_Addr e_entry; + Elf64_Off e_phoff; + Elf64_Off e_shoff; + Elf64_Word e_flags; + Elf64_Half e_ehsize; + Elf64_Half e_phentsize; + Elf64_Half e_phnum; + Elf64_Half e_shentsize; + Elf64_Half e_shnum; + Elf64_Half e_shstrndx; +} + +enum EI_MAG0 = 0; +enum ELFMAG0 = 0x7f; + +enum EI_MAG1 = 1; +enum ELFMAG1 = 'E'; + +enum EI_MAG2 = 2; +enum ELFMAG2 = 'L'; + +enum EI_MAG3 = 3; +enum ELFMAG3 = 'F'; +enum ELFMAG = "\177ELF"; +enum SELFMAG = 4; + +enum EI_CLASS = 4; +enum ELFCLASSNONE = 0; +enum ELFCLASS32 = 1; +enum ELFCLASS64 = 2; +enum ELFCLASSNUM = 3; + +enum EI_DATA = 5; +enum ELFDATANONE = 0; +enum ELFDATA2LSB = 1; +enum ELFDATA2MSB = 2; +enum ELFDATANUM = 3; + +enum EI_VERSION = 6; + +enum EI_OSABI = 7; +enum ELFOSABI_NONE = 0; +enum ELFOSABI_SYSV = 0; +enum ELFOSABI_HPUX = 1; +enum ELFOSABI_NETBSD = 2; +enum ELFOSABI_GNU = 3; +enum ELFOSABI_LINUX = ELFOSABI_GNU; +enum ELFOSABI_SOLARIS = 6; +enum ELFOSABI_AIX = 7; +enum ELFOSABI_IRIX = 8; +enum ELFOSABI_FREEBSD = 9; +enum ELFOSABI_TRU64 = 10; +enum ELFOSABI_MODESTO = 11; +enum ELFOSABI_OPENBSD = 12; +enum ELFOSABI_ARM_AEABI = 64; +enum ELFOSABI_ARM = 97; +enum ELFOSABI_STANDALONE = 255; +enum ELFOSABI_DRAGONFLYBSD = ELFOSABI_NONE; + +enum EI_ABIVERSION = 8; + +enum EI_PAD = 9; + +enum ET_NONE = 0; +enum ET_REL = 1; +enum ET_EXEC = 2; +enum ET_DYN = 3; +enum ET_CORE = 4; +enum ET_NUM = 5; +enum ET_LOOS = 0xfe00; +enum ET_HIOS = 0xfeff; +enum ET_LOPROC = 0xff00; +enum ET_HIPROC = 0xffff; + +enum EM_NONE = 0; +enum EM_M32 = 1; +enum EM_SPARC = 2; +enum EM_386 = 3; +enum EM_68K = 4; +enum EM_88K = 5; +enum EM_860 = 7; +enum EM_MIPS = 8; +enum EM_S370 = 9; +enum EM_MIPS_RS3_LE = 10; + +enum EM_PARISC = 15; +enum EM_VPP500 = 17; +enum EM_SPARC32PLUS = 18; +enum EM_960 = 19; +enum EM_PPC = 20; +enum EM_PPC64 = 21; +enum EM_S390 = 22; + +enum EM_V800 = 36; +enum EM_FR20 = 37; +enum EM_RH32 = 38; +enum EM_RCE = 39; +enum EM_ARM = 40; +enum EM_FAKE_ALPHA = 41; +enum EM_SH = 42; +enum EM_SPARCV9 = 43; +enum EM_TRICORE = 44; +enum EM_ARC = 45; +enum EM_H8_300 = 46; +enum EM_H8_300H = 47; +enum EM_H8S = 48; +enum EM_H8_500 = 49; +enum EM_IA_64 = 50; +enum EM_MIPS_X = 51; +enum EM_COLDFIRE = 52; +enum EM_68HC12 = 53; +enum EM_MMA = 54; +enum EM_PCP = 55; +enum EM_NCPU = 56; +enum EM_NDR1 = 57; +enum EM_STARCORE = 58; +enum EM_ME16 = 59; +enum EM_ST100 = 60; +enum EM_TINYJ = 61; +enum EM_X86_64 = 62; +enum EM_PDSP = 63; + +enum EM_FX66 = 66; +enum EM_ST9PLUS = 67; +enum EM_ST7 = 68; +enum EM_68HC16 = 69; +enum EM_68HC11 = 70; +enum EM_68HC08 = 71; +enum EM_68HC05 = 72; +enum EM_SVX = 73; +enum EM_ST19 = 74; +enum EM_VAX = 75; +enum EM_CRIS = 76; +enum EM_JAVELIN = 77; +enum EM_FIREPATH = 78; +enum EM_ZSP = 79; +enum EM_MMIX = 80; +enum EM_HUANY = 81; +enum EM_PRISM = 82; +enum EM_AVR = 83; +enum EM_FR30 = 84; +enum EM_D10V = 85; +enum EM_D30V = 86; +enum EM_V850 = 87; +enum EM_M32R = 88; +enum EM_MN10300 = 89; +enum EM_MN10200 = 90; +enum EM_PJ = 91; +enum EM_OPENRISC = 92; +enum EM_ARC_A5 = 93; +enum EM_XTENSA = 94; +enum EM_AARCH64 = 183; +enum EM_TILEPRO = 188; +enum EM_TILEGX = 191; +enum EM_NUM = 192; + +enum EM_ALPHA = 0x9026; + +enum EV_NONE = 0; +enum EV_CURRENT = 1; +enum EV_NUM = 2; + +struct Elf32_Shdr +{ + Elf32_Word sh_name; + Elf32_Word sh_type; + Elf32_Word sh_flags; + Elf32_Addr sh_addr; + Elf32_Off sh_offset; + Elf32_Word sh_size; + Elf32_Word sh_link; + Elf32_Word sh_info; + Elf32_Word sh_addralign; + Elf32_Word sh_entsize; +} + +struct Elf64_Shdr +{ + Elf64_Word sh_name; + Elf64_Word sh_type; + Elf64_Xword sh_flags; + Elf64_Addr sh_addr; + Elf64_Off sh_offset; + Elf64_Xword sh_size; + Elf64_Word sh_link; + Elf64_Word sh_info; + Elf64_Xword sh_addralign; + Elf64_Xword sh_entsize; +} + +enum SHN_UNDEF = 0; +enum SHN_LORESERVE = 0xff00; +enum SHN_LOPROC = 0xff00; +enum SHN_BEFORE = 0xff00; +enum SHN_AFTER = 0xff01; +enum SHN_HIPROC = 0xff1f; +enum SHN_LOOS = 0xff20; +enum SHN_HIOS = 0xff3f; +enum SHN_ABS = 0xfff1; +enum SHN_COMMON = 0xfff2; +enum SHN_XINDEX = 0xffff; +enum SHN_HIRESERVE = 0xffff; + +enum SHT_NULL = 0; +enum SHT_PROGBITS = 1; +enum SHT_SYMTAB = 2; +enum SHT_STRTAB = 3; +enum SHT_RELA = 4; +enum SHT_HASH = 5; +enum SHT_DYNAMIC = 6; +enum SHT_NOTE = 7; +enum SHT_NOBITS = 8; +enum SHT_REL = 9; +enum SHT_SHLIB = 10; +enum SHT_DYNSYM = 11; +enum SHT_INIT_ARRAY = 14; +enum SHT_FINI_ARRAY = 15; +enum SHT_PREINIT_ARRAY = 16; +enum SHT_GROUP = 17; +enum SHT_SYMTAB_SHNDX = 18; +enum SHT_NUM = 19; +enum SHT_LOOS = 0x60000000; +enum SHT_GNU_ATTRIBUTES = 0x6ffffff5; +enum SHT_GNU_HASH = 0x6ffffff6; +enum SHT_GNU_LIBLIST = 0x6ffffff7; +enum SHT_CHECKSUM = 0x6ffffff8; +enum SHT_LOSUNW = 0x6ffffffa; +enum SHT_SUNW_move = 0x6ffffffa; +enum SHT_SUNW_COMDAT = 0x6ffffffb; +enum SHT_SUNW_syminfo = 0x6ffffffc; +enum SHT_GNU_verdef = 0x6ffffffd; +enum SHT_GNU_verneed = 0x6ffffffe; +enum SHT_GNU_versym = 0x6fffffff; +enum SHT_HISUNW = 0x6fffffff; +enum SHT_HIOS = 0x6fffffff; +enum SHT_LOPROC = 0x70000000; +enum SHT_HIPROC = 0x7fffffff; +enum SHT_LOUSER = 0x80000000; +enum SHT_HIUSER = 0x8fffffff; + +enum SHF_WRITE = (1 << 0); +enum SHF_ALLOC = (1 << 1); +enum SHF_EXECINSTR = (1 << 2); +enum SHF_MERGE = (1 << 4); +enum SHF_STRINGS = (1 << 5); +enum SHF_INFO_LINK = (1 << 6); +enum SHF_LINK_ORDER = (1 << 7); +enum SHF_OS_NONCONFORMING = (1 << 8); +enum SHF_GROUP = (1 << 9); +enum SHF_TLS = (1 << 10); +enum SHF_COMPRESSED = (1 << 11); +enum SHF_MASKOS = 0x0ff00000; +enum SHF_MASKPROC = 0xf0000000; +enum SHF_ORDERED = (1 << 30); +enum SHF_EXCLUDE = (1 << 31); +enum GRP_COMDAT = 0x1; + +struct Elf32_Sym +{ + Elf32_Word st_name; + Elf32_Addr st_value; + Elf32_Word st_size; + ubyte st_info; + ubyte st_other; + Elf32_Section st_shndx; +} + +struct Elf64_Sym +{ + Elf64_Word st_name; + ubyte st_info; + ubyte st_other; + Elf64_Section st_shndx; + Elf64_Addr st_value; + Elf64_Xword st_size; +} + +struct Elf32_Syminfo +{ + Elf32_Half si_boundto; + Elf32_Half si_flags; +} + +struct Elf64_Syminfo +{ + Elf64_Half si_boundto; + Elf64_Half si_flags; +} +enum SYMINFO_BT_SELF = 0xffff; +enum SYMINFO_BT_PARENT = 0xfffe; +enum SYMINFO_BT_LOWRESERVE = 0xff00; +enum SYMINFO_FLG_DIRECT = 0x0001; +enum SYMINFO_FLG_PASSTHRU = 0x0002; +enum SYMINFO_FLG_COPY = 0x0004; +enum SYMINFO_FLG_LAZYLOAD = 0x0008; +enum SYMINFO_NONE = 0; +enum SYMINFO_CURRENT = 1; +enum SYMINFO_NUM = 2; + +extern (D) +{ + auto ELF32_ST_BIND(T)(T val) { return cast(ubyte)val >> 4; } + auto ELF32_ST_TYPE(T)(T val) { return val & 0xf; } + auto ELF32_ST_INFO(B, T)(B bind, T type) { return (bind << 4) + (type & 0xf); } + alias ELF32_ST_BIND ELF64_ST_BIND; + alias ELF32_ST_TYPE ELF64_ST_TYPE; + alias ELF32_ST_INFO ELF64_ST_INFO; +} + +enum STB_LOCAL = 0; +enum STB_GLOBAL = 1; +enum STB_WEAK = 2; +enum STB_NUM = 3; +enum STB_LOOS = 10; +enum STB_GNU_UNIQUE = 10; +enum STB_HIOS = 12; +enum STB_LOPROC = 13; +enum STB_HIPROC = 15; + +enum STT_NOTYPE = 0; +enum STT_OBJECT = 1; +enum STT_FUNC = 2; +enum STT_SECTION = 3; +enum STT_FILE = 4; +enum STT_COMMON = 5; +enum STT_TLS = 6; +enum STT_NUM = 7; +enum STT_LOOS = 10; +enum STT_GNU_IFUNC = 10; +enum STT_HIOS = 12; +enum STT_LOPROC = 13; +enum STT_HIPROC = 15; + +enum STN_UNDEF = 0; + +extern (D) +{ + auto ELF32_ST_VISIBILITY(O)(O o) { return o & 0x03; } + alias ELF32_ST_VISIBILITY ELF64_ST_VISIBILITY; +} +enum STV_DEFAULT = 0; +enum STV_INTERNAL = 1; +enum STV_HIDDEN = 2; +enum STV_PROTECTED = 3; + +struct Elf32_Rel +{ + Elf32_Addr r_offset; + Elf32_Word r_info; +} + +struct Elf64_Rel +{ + Elf64_Addr r_offset; + Elf64_Xword r_info; +} + +struct Elf32_Rela +{ + Elf32_Addr r_offset; + Elf32_Word r_info; + Elf32_Sword r_addend; +} + +struct Elf64_Rela +{ + Elf64_Addr r_offset; + Elf64_Xword r_info; + Elf64_Sxword r_addend; +} + +extern (D) +{ + auto ELF32_R_SYM(V)(V val) { return val >> 8; } + auto ELF32_R_TYPE(V)(V val) { return val & 0xff; } + auto ELF32_R_INFO(S, T)(S sym, T type) { return (sym << 8) + (type & 0xff); } + + auto ELF64_R_SYM(I)(I i) { return i >> 32; } + auto ELF64_R_TYPE(I)(I i) { return i & 0xffffffff; } + auto ELF64_R_INFO(S, T)(S sym, T type) { return (sym << 32) + (type); } +} + +struct Elf32_Phdr +{ + Elf32_Word p_type; + Elf32_Off p_offset; + Elf32_Addr p_vaddr; + Elf32_Addr p_paddr; + Elf32_Word p_filesz; + Elf32_Word p_memsz; + Elf32_Word p_flags; + Elf32_Word p_align; +} + +struct Elf64_Phdr +{ + Elf64_Word p_type; + Elf64_Word p_flags; + Elf64_Off p_offset; + Elf64_Addr p_vaddr; + Elf64_Addr p_paddr; + Elf64_Xword p_filesz; + Elf64_Xword p_memsz; + Elf64_Xword p_align; +} + +enum PN_XNUM = 0xffff; + +enum PT_NULL = 0; +enum PT_LOAD = 1; +enum PT_DYNAMIC = 2; +enum PT_INTERP = 3; +enum PT_NOTE = 4; +enum PT_SHLIB = 5; +enum PT_PHDR = 6; +enum PT_TLS = 7; +enum PT_NUM = 8; +enum PT_LOOS = 0x60000000; +enum PT_GNU_EH_FRAME = 0x6474e550; +enum PT_GNU_STACK = 0x6474e551; +enum PT_GNU_RELRO = 0x6474e552; +enum PT_LOSUNW = 0x6ffffffa; +enum PT_SUNWBSS = 0x6ffffffa; +enum PT_SUNWSTACK = 0x6ffffffb; +enum PT_HISUNW = 0x6fffffff; +enum PT_HIOS = 0x6fffffff; +enum PT_LOPROC = 0x70000000; +enum PT_HIPROC = 0x7fffffff; + +enum PF_X = (1 << 0); +enum PF_W = (1 << 1); +enum PF_R = (1 << 2); +enum PF_MASKOS = 0x0ff00000; +enum PF_MASKPROC = 0xf0000000; + +enum NT_PRSTATUS = 1; +enum NT_FPREGSET = 2; +enum NT_PRPSINFO = 3; +enum NT_PRXREG = 4; +enum NT_TASKSTRUCT = 4; +enum NT_PLATFORM = 5; +enum NT_AUXV = 6; +enum NT_GWINDOWS = 7; +enum NT_ASRS = 8; +enum NT_PSTATUS = 10; +enum NT_PSINFO = 13; +enum NT_PRCRED = 14; +enum NT_UTSNAME = 15; +enum NT_LWPSTATUS = 16; +enum NT_LWPSINFO = 17; +enum NT_PRFPXREG = 20; +enum NT_SIGINFO = 0x53494749; +enum NT_FILE = 0x46494c45; +enum NT_PRXFPREG = 0x46e62b7f; +enum NT_PPC_VMX = 0x100; +enum NT_PPC_SPE = 0x101; +enum NT_PPC_VSX = 0x102; +enum NT_386_TLS = 0x200; +enum NT_386_IOPERM = 0x201; +enum NT_X86_XSTATE = 0x202; +enum NT_S390_HIGH_GPRS = 0x300; +enum NT_S390_TIMER = 0x301; +enum NT_S390_TODCMP = 0x302; +enum NT_S390_TODPREG = 0x303; +enum NT_S390_CTRS = 0x304; +enum NT_S390_PREFIX = 0x305; +enum NT_S390_LAST_BREAK = 0x306; +enum NT_S390_SYSTEM_CALL = 0x307; +enum NT_S390_TDB = 0x308; +enum NT_ARM_VFP = 0x400; +enum NT_ARM_TLS = 0x401; +enum NT_ARM_HW_BREAK = 0x402; +enum NT_ARM_HW_WATCH = 0x403; + +enum NT_VERSION = 1; + +struct Elf32_Dyn +{ + Elf32_Sword d_tag; + union _d_un + { + Elf32_Word d_val; + Elf32_Addr d_ptr; + } _d_un d_un; +} + +struct Elf64_Dyn +{ + Elf64_Sxword d_tag; + union _d_un + { + Elf64_Xword d_val; + Elf64_Addr d_ptr; + } _d_un d_un; +} + +enum DT_NULL = 0; +enum DT_NEEDED = 1; +enum DT_PLTRELSZ = 2; +enum DT_PLTGOT = 3; +enum DT_HASH = 4; +enum DT_STRTAB = 5; +enum DT_SYMTAB = 6; +enum DT_RELA = 7; +enum DT_RELASZ = 8; +enum DT_RELAENT = 9; +enum DT_STRSZ = 10; +enum DT_SYMENT = 11; +enum DT_INIT = 12; +enum DT_FINI = 13; +enum DT_SONAME = 14; +enum DT_RPATH = 15; +enum DT_SYMBOLIC = 16; +enum DT_REL = 17; +enum DT_RELSZ = 18; +enum DT_RELENT = 19; +enum DT_PLTREL = 20; +enum DT_DEBUG = 21; +enum DT_TEXTREL = 22; +enum DT_JMPREL = 23; +enum DT_BIND_NOW = 24; +enum DT_INIT_ARRAY = 25; +enum DT_FINI_ARRAY = 26; +enum DT_INIT_ARRAYSZ = 27; +enum DT_FINI_ARRAYSZ = 28; +enum DT_RUNPATH = 29; +enum DT_FLAGS = 30; +enum DT_ENCODING = 32; +enum DT_PREINIT_ARRAY = 32; +enum DT_PREINIT_ARRAYSZ = 33; +enum DT_NUM = 34; +enum DT_LOOS = 0x6000000d; +enum DT_HIOS = 0x6ffff000; +enum DT_LOPROC = 0x70000000; +enum DT_HIPROC = 0x7fffffff; +enum DT_PROCNUM = DT_MIPS_NUM; +enum DT_VALRNGLO = 0x6ffffd00; +enum DT_GNU_PRELINKED = 0x6ffffdf5; +enum DT_GNU_CONFLICTSZ = 0x6ffffdf6; +enum DT_GNU_LIBLISTSZ = 0x6ffffdf7; +enum DT_CHECKSUM = 0x6ffffdf8; +enum DT_PLTPADSZ = 0x6ffffdf9; +enum DT_MOVEENT = 0x6ffffdfa; +enum DT_MOVESZ = 0x6ffffdfb; +enum DT_FEATURE_1 = 0x6ffffdfc; +enum DT_POSFLAG_1 = 0x6ffffdfd; +enum DT_SYMINSZ = 0x6ffffdfe; +enum DT_SYMINENT = 0x6ffffdff; +enum DT_VALRNGHI = 0x6ffffdff; +extern (D) auto DT_VALTAGIDX(T)(T tag) +{ + return DT_VALRNGHI - tag; +} +enum DT_VALNUM = 12; +enum DT_ADDRRNGLO = 0x6ffffe00; +enum DT_GNU_HASH = 0x6ffffef5; +enum DT_TLSDESC_PLT = 0x6ffffef6; +enum DT_TLSDESC_GOT = 0x6ffffef7; +enum DT_GNU_CONFLICT = 0x6ffffef8; +enum DT_GNU_LIBLIST = 0x6ffffef9; +enum DT_CONFIG = 0x6ffffefa; +enum DT_DEPAUDIT = 0x6ffffefb; +enum DT_AUDIT = 0x6ffffefc; +enum DT_PLTPAD = 0x6ffffefd; +enum DT_MOVETAB = 0x6ffffefe; +enum DT_SYMINFO = 0x6ffffeff; +enum DT_ADDRRNGHI = 0x6ffffeff; +extern (D) auto DT_ADDRTAGIDX(T)(T tag) +{ + return DT_ADDRRNGHI - tag; +} +enum DT_ADDRNUM = 11; +enum DT_VERSYM = 0x6ffffff0; + +enum DT_RELACOUNT = 0x6ffffff9; +enum DT_RELCOUNT = 0x6ffffffa; +enum DT_FLAGS_1 = 0x6ffffffb; +enum DT_VERDEF = 0x6ffffffc; +enum DT_VERDEFNUM = 0x6ffffffd; +enum DT_VERNEED = 0x6ffffffe; +enum DT_VERNEEDNUM = 0x6fffffff; +extern (D) auto DT_VERSIONTAGIDX(T)(T tag) +{ + return DT_VERNEEDNUM - tag; +} +enum DT_VERSIONTAGNUM = 16; +enum DT_AUXILIARY = 0x7ffffffd; +enum DT_FILTER = 0x7fffffff; +extern (D) auto DT_EXTRATAGIDX(T)(T tag) +{ + return cast(Elf32_Word)(-(cast(Elf32_Sword)(tag) <<1>>1)-1); +} +enum DT_EXTRANUM = 3; +enum DF_ORIGIN = 0x00000001; +enum DF_SYMBOLIC = 0x00000002; +enum DF_TEXTREL = 0x00000004; +enum DF_BIND_NOW = 0x00000008; +enum DF_STATIC_TLS = 0x00000010; +enum DF_1_NOW = 0x00000001; +enum DF_1_GLOBAL = 0x00000002; +enum DF_1_GROUP = 0x00000004; +enum DF_1_NODELETE = 0x00000008; +enum DF_1_LOADFLTR = 0x00000010; +enum DF_1_INITFIRST = 0x00000020; +enum DF_1_NOOPEN = 0x00000040; +enum DF_1_ORIGIN = 0x00000080; +enum DF_1_DIRECT = 0x00000100; +enum DF_1_TRANS = 0x00000200; +enum DF_1_INTERPOSE = 0x00000400; +enum DF_1_NODEFLIB = 0x00000800; +enum DF_1_NODUMP = 0x00001000; +enum DF_1_CONFALT = 0x00002000; +enum DF_1_ENDFILTEE = 0x00004000; +enum DF_1_DISPRELDNE = 0x00008000; +enum DF_1_DISPRELPND = 0x00010000; +enum DF_1_NODIRECT = 0x00020000; +enum DF_1_IGNMULDEF = 0x00040000; +enum DF_1_NOKSYMS = 0x00080000; +enum DF_1_NOHDR = 0x00100000; +enum DF_1_EDITED = 0x00200000; +enum DF_1_NORELOC = 0x00400000; +enum DF_1_SYMINTPOSE = 0x00800000; +enum DF_1_GLOBAUDIT = 0x01000000; +enum DF_1_SINGLETON = 0x02000000; +enum DTF_1_PARINIT = 0x00000001; +enum DTF_1_CONFEXP = 0x00000002; +enum DF_P1_LAZYLOAD = 0x00000001; +enum DF_P1_GROUPPERM = 0x00000002; + +struct Elf32_Verdef +{ + Elf32_Half vd_version; + Elf32_Half vd_flags; + Elf32_Half vd_ndx; + Elf32_Half vd_cnt; + Elf32_Word vd_hash; + Elf32_Word vd_aux; + Elf32_Word vd_next; +} + +struct Elf64_Verdef +{ + Elf64_Half vd_version; + Elf64_Half vd_flags; + Elf64_Half vd_ndx; + Elf64_Half vd_cnt; + Elf64_Word vd_hash; + Elf64_Word vd_aux; + Elf64_Word vd_next; +} +enum VER_DEF_NONE = 0; +enum VER_DEF_CURRENT = 1; +enum VER_DEF_NUM = 2; +enum VER_FLG_BASE = 0x1; +enum VER_FLG_WEAK = 0x2; +enum VER_NDX_LOCAL = 0; +enum VER_NDX_GLOBAL = 1; +enum VER_NDX_LORESERVE = 0xff00; +enum VER_NDX_ELIMINATE = 0xff01; + +struct Elf32_Verdaux +{ + Elf32_Word vda_name; + Elf32_Word vda_next; +} + +struct Elf64_Verdaux +{ + Elf64_Word vda_name; + Elf64_Word vda_next; +} + +struct Elf32_Verneed +{ + Elf32_Half vn_version; + Elf32_Half vn_cnt; + Elf32_Word vn_file; + Elf32_Word vn_aux; + Elf32_Word vn_next; +} + +struct Elf64_Verneed +{ + Elf64_Half vn_version; + Elf64_Half vn_cnt; + Elf64_Word vn_file; + Elf64_Word vn_aux; + Elf64_Word vn_next; +} +enum VER_NEED_NONE = 0; +enum VER_NEED_CURRENT = 1; +enum VER_NEED_NUM = 2; + +struct Elf32_Vernaux +{ + Elf32_Word vna_hash; + Elf32_Half vna_flags; + Elf32_Half vna_other; + Elf32_Word vna_name; + Elf32_Word vna_next; +} + +struct Elf64_Vernaux +{ + Elf64_Word vna_hash; + Elf64_Half vna_flags; + Elf64_Half vna_other; + Elf64_Word vna_name; + Elf64_Word vna_next; +} +// duplicate +// enum VER_FLG_WEAK = 0x2; + +struct Elf32_auxv_t +{ + uint32_t a_type; + union _a_un + { + uint32_t a_val; + } _a_un a_un; +} + +struct Elf64_auxv_t +{ + uint64_t a_type; + union _a_un + { + uint64_t a_val; + } _a_un a_un; +} + +enum AT_NULL = 0; +enum AT_IGNORE = 1; +enum AT_EXECFD = 2; +enum AT_PHDR = 3; +enum AT_PHENT = 4; +enum AT_PHNUM = 5; +enum AT_PAGESZ = 6; +enum AT_BASE = 7; +enum AT_FLAGS = 8; +enum AT_ENTRY = 9; +enum AT_NOTELF = 10; +enum AT_UID = 11; +enum AT_EUID = 12; +enum AT_GID = 13; +enum AT_EGID = 14; +enum AT_CLKTCK = 17; +enum AT_PLATFORM = 15; +enum AT_HWCAP = 16; +enum AT_FPUCW = 18; +enum AT_DCACHEBSIZE = 19; +enum AT_ICACHEBSIZE = 20; +enum AT_UCACHEBSIZE = 21; +enum AT_IGNOREPPC = 22; + +enum AT_SECURE = 23; + +enum AT_BASE_PLATFORM = 24; + +enum AT_RANDOM = 25; + +enum AT_HWCAP2 = 26; + +enum AT_EXECFN = 31; +enum AT_SYSINFO = 32; +enum AT_SYSINFO_EHDR = 33; + +enum AT_L1I_CACHESHAPE = 34; +enum AT_L1D_CACHESHAPE = 35; +enum AT_L2_CACHESHAPE = 36; +enum AT_L3_CACHESHAPE = 37; + +struct Elf32_Nhdr +{ + Elf32_Word n_namesz; + Elf32_Word n_descsz; + Elf32_Word n_type; +} + +struct Elf64_Nhdr +{ + Elf64_Word n_namesz; + Elf64_Word n_descsz; + Elf64_Word n_type; +} +enum ELF_NOTE_SOLARIS = "SUNW Solaris"; +enum ELF_NOTE_GNU = "GNU"; +enum ELF_NOTE_PAGESIZE_HINT = 1; +enum NT_GNU_ABI_TAG = 1; +enum ELF_NOTE_ABI = NT_GNU_ABI_TAG; +enum ELF_NOTE_OS_LINUX = 0; +enum ELF_NOTE_OS_GNU = 1; +enum ELF_NOTE_OS_SOLARIS2 = 2; +enum ELF_NOTE_OS_FREEBSD = 3; +enum NT_GNU_HWCAP = 2; +enum NT_GNU_BUILD_ID = 3; +enum NT_GNU_GOLD_VERSION = 4; +struct Elf32_Move +{ + Elf32_Xword m_value; + Elf32_Word m_info; + Elf32_Word m_poffset; + Elf32_Half m_repeat; + Elf32_Half m_stride; +} + +struct Elf64_Move +{ + Elf64_Xword m_value; + Elf64_Xword m_info; + Elf64_Xword m_poffset; + Elf64_Half m_repeat; + Elf64_Half m_stride; +} +extern (D) +{ + auto ELF32_M_SYM(I)(I info) { return info >> 8; } + auto ELF32_M_SIZE(I)(I info) { return cast(ubyte)info; } + auto ELF32_M_INFO(S, SZ)(S sym, SZ size) { return (sym << 8) + cast(ubyte)size; } +} + +alias ELF32_M_SYM ELF64_M_SYM; +alias ELF32_M_SIZE ELF64_M_SIZE; +alias ELF32_M_INFO ELF64_M_INFO; +enum EF_CPU32 = 0x00810000; + +enum R_68K_NONE = 0; +enum R_68K_32 = 1; +enum R_68K_16 = 2; +enum R_68K_8 = 3; +enum R_68K_PC32 = 4; +enum R_68K_PC16 = 5; +enum R_68K_PC8 = 6; +enum R_68K_GOT32 = 7; +enum R_68K_GOT16 = 8; +enum R_68K_GOT8 = 9; +enum R_68K_GOT32O = 10; +enum R_68K_GOT16O = 11; +enum R_68K_GOT8O = 12; +enum R_68K_PLT32 = 13; +enum R_68K_PLT16 = 14; +enum R_68K_PLT8 = 15; +enum R_68K_PLT32O = 16; +enum R_68K_PLT16O = 17; +enum R_68K_PLT8O = 18; +enum R_68K_COPY = 19; +enum R_68K_GLOB_DAT = 20; +enum R_68K_JMP_SLOT = 21; +enum R_68K_RELATIVE = 22; +enum R_68K_TLS_GD32 = 25; +enum R_68K_TLS_GD16 = 26; +enum R_68K_TLS_GD8 = 27; +enum R_68K_TLS_LDM32 = 28; +enum R_68K_TLS_LDM16 = 29; +enum R_68K_TLS_LDM8 = 30; +enum R_68K_TLS_LDO32 = 31; +enum R_68K_TLS_LDO16 = 32; +enum R_68K_TLS_LDO8 = 33; +enum R_68K_TLS_IE32 = 34; +enum R_68K_TLS_IE16 = 35; +enum R_68K_TLS_IE8 = 36; +enum R_68K_TLS_LE32 = 37; +enum R_68K_TLS_LE16 = 38; +enum R_68K_TLS_LE8 = 39; +enum R_68K_TLS_DTPMOD32 = 40; +enum R_68K_TLS_DTPREL32 = 41; +enum R_68K_TLS_TPREL32 = 42; +enum R_68K_NUM = 43; + +enum R_386_NONE = 0; +enum R_386_32 = 1; +enum R_386_PC32 = 2; +enum R_386_GOT32 = 3; +enum R_386_PLT32 = 4; +enum R_386_COPY = 5; +enum R_386_GLOB_DAT = 6; +enum R_386_JMP_SLOT = 7; +enum R_386_RELATIVE = 8; +enum R_386_GOTOFF = 9; +enum R_386_GOTPC = 10; +enum R_386_32PLT = 11; +enum R_386_TLS_TPOFF = 14; +enum R_386_TLS_IE = 15; +enum R_386_TLS_GOTIE = 16; +enum R_386_TLS_LE = 17; +enum R_386_TLS_GD = 18; +enum R_386_TLS_LDM = 19; +enum R_386_16 = 20; +enum R_386_PC16 = 21; +enum R_386_8 = 22; +enum R_386_PC8 = 23; +enum R_386_TLS_GD_32 = 24; +enum R_386_TLS_GD_PUSH = 25; +enum R_386_TLS_GD_CALL = 26; +enum R_386_TLS_GD_POP = 27; +enum R_386_TLS_LDM_32 = 28; +enum R_386_TLS_LDM_PUSH = 29; +enum R_386_TLS_LDM_CALL = 30; +enum R_386_TLS_LDM_POP = 31; +enum R_386_TLS_LDO_32 = 32; +enum R_386_TLS_IE_32 = 33; +enum R_386_TLS_LE_32 = 34; +enum R_386_TLS_DTPMOD32 = 35; +enum R_386_TLS_DTPOFF32 = 36; +enum R_386_TLS_TPOFF32 = 37; +enum R_386_SIZE32 = 38; +enum R_386_TLS_GOTDESC = 39; +enum R_386_TLS_DESC_CALL = 40; +enum R_386_TLS_DESC = 41; +enum R_386_IRELATIVE = 42; +enum R_386_NUM = 43; + +enum STT_SPARC_REGISTER = 13; + +enum EF_SPARCV9_MM = 3; +enum EF_SPARCV9_TSO = 0; +enum EF_SPARCV9_PSO = 1; +enum EF_SPARCV9_RMO = 2; +enum EF_SPARC_LEDATA = 0x800000; +enum EF_SPARC_EXT_MASK = 0xFFFF00; +enum EF_SPARC_32PLUS = 0x000100; +enum EF_SPARC_SUN_US1 = 0x000200; +enum EF_SPARC_HAL_R1 = 0x000400; +enum EF_SPARC_SUN_US3 = 0x000800; + +enum R_SPARC_NONE = 0; +enum R_SPARC_8 = 1; +enum R_SPARC_16 = 2; +enum R_SPARC_32 = 3; +enum R_SPARC_DISP8 = 4; +enum R_SPARC_DISP16 = 5; +enum R_SPARC_DISP32 = 6; +enum R_SPARC_WDISP30 = 7; +enum R_SPARC_WDISP22 = 8; +enum R_SPARC_HI22 = 9; +enum R_SPARC_22 = 10; +enum R_SPARC_13 = 11; +enum R_SPARC_LO10 = 12; +enum R_SPARC_GOT10 = 13; +enum R_SPARC_GOT13 = 14; +enum R_SPARC_GOT22 = 15; +enum R_SPARC_PC10 = 16; +enum R_SPARC_PC22 = 17; +enum R_SPARC_WPLT30 = 18; +enum R_SPARC_COPY = 19; +enum R_SPARC_GLOB_DAT = 20; +enum R_SPARC_JMP_SLOT = 21; +enum R_SPARC_RELATIVE = 22; +enum R_SPARC_UA32 = 23; + +enum R_SPARC_PLT32 = 24; +enum R_SPARC_HIPLT22 = 25; +enum R_SPARC_LOPLT10 = 26; +enum R_SPARC_PCPLT32 = 27; +enum R_SPARC_PCPLT22 = 28; +enum R_SPARC_PCPLT10 = 29; +enum R_SPARC_10 = 30; +enum R_SPARC_11 = 31; +enum R_SPARC_64 = 32; +enum R_SPARC_OLO10 = 33; +enum R_SPARC_HH22 = 34; +enum R_SPARC_HM10 = 35; +enum R_SPARC_LM22 = 36; +enum R_SPARC_PC_HH22 = 37; +enum R_SPARC_PC_HM10 = 38; +enum R_SPARC_PC_LM22 = 39; +enum R_SPARC_WDISP16 = 40; +enum R_SPARC_WDISP19 = 41; +enum R_SPARC_GLOB_JMP = 42; +enum R_SPARC_7 = 43; +enum R_SPARC_5 = 44; +enum R_SPARC_6 = 45; +enum R_SPARC_DISP64 = 46; +enum R_SPARC_PLT64 = 47; +enum R_SPARC_HIX22 = 48; +enum R_SPARC_LOX10 = 49; +enum R_SPARC_H44 = 50; +enum R_SPARC_M44 = 51; +enum R_SPARC_L44 = 52; +enum R_SPARC_REGISTER = 53; +enum R_SPARC_UA64 = 54; +enum R_SPARC_UA16 = 55; +enum R_SPARC_TLS_GD_HI22 = 56; +enum R_SPARC_TLS_GD_LO10 = 57; +enum R_SPARC_TLS_GD_ADD = 58; +enum R_SPARC_TLS_GD_CALL = 59; +enum R_SPARC_TLS_LDM_HI22 = 60; +enum R_SPARC_TLS_LDM_LO10 = 61; +enum R_SPARC_TLS_LDM_ADD = 62; +enum R_SPARC_TLS_LDM_CALL = 63; +enum R_SPARC_TLS_LDO_HIX22 = 64; +enum R_SPARC_TLS_LDO_LOX10 = 65; +enum R_SPARC_TLS_LDO_ADD = 66; +enum R_SPARC_TLS_IE_HI22 = 67; +enum R_SPARC_TLS_IE_LO10 = 68; +enum R_SPARC_TLS_IE_LD = 69; +enum R_SPARC_TLS_IE_LDX = 70; +enum R_SPARC_TLS_IE_ADD = 71; +enum R_SPARC_TLS_LE_HIX22 = 72; +enum R_SPARC_TLS_LE_LOX10 = 73; +enum R_SPARC_TLS_DTPMOD32 = 74; +enum R_SPARC_TLS_DTPMOD64 = 75; +enum R_SPARC_TLS_DTPOFF32 = 76; +enum R_SPARC_TLS_DTPOFF64 = 77; +enum R_SPARC_TLS_TPOFF32 = 78; +enum R_SPARC_TLS_TPOFF64 = 79; +enum R_SPARC_GOTDATA_HIX22 = 80; +enum R_SPARC_GOTDATA_LOX10 = 81; +enum R_SPARC_GOTDATA_OP_HIX22 = 82; +enum R_SPARC_GOTDATA_OP_LOX10 = 83; +enum R_SPARC_GOTDATA_OP = 84; +enum R_SPARC_H34 = 85; +enum R_SPARC_SIZE32 = 86; +enum R_SPARC_SIZE64 = 87; +enum R_SPARC_WDISP10 = 88; +enum R_SPARC_JMP_IREL = 248; +enum R_SPARC_IRELATIVE = 249; +enum R_SPARC_GNU_VTINHERIT = 250; +enum R_SPARC_GNU_VTENTRY = 251; +enum R_SPARC_REV32 = 252; +enum R_SPARC_NUM = 253; + +enum DT_SPARC_REGISTER = 0x70000001; +enum DT_SPARC_NUM = 2; + +enum EF_MIPS_NOREORDER = 1; +enum EF_MIPS_PIC = 2; +enum EF_MIPS_CPIC = 4; +enum EF_MIPS_XGOT = 8; +enum EF_MIPS_64BIT_WHIRL = 16; +enum EF_MIPS_ABI2 = 32; +enum EF_MIPS_ABI_ON32 = 64; +enum EF_MIPS_ARCH = 0xf0000000; + +enum EF_MIPS_ARCH_1 = 0x00000000; +enum EF_MIPS_ARCH_2 = 0x10000000; +enum EF_MIPS_ARCH_3 = 0x20000000; +enum EF_MIPS_ARCH_4 = 0x30000000; +enum EF_MIPS_ARCH_5 = 0x40000000; +enum EF_MIPS_ARCH_32 = 0x50000000; +enum EF_MIPS_ARCH_64 = 0x60000000; +enum EF_MIPS_ARCH_32R2 = 0x70000000; +enum EF_MIPS_ARCH_64R2 = 0x80000000; + +enum E_MIPS_ARCH_1 = EF_MIPS_ARCH_1; +enum E_MIPS_ARCH_2 = EF_MIPS_ARCH_2; +enum E_MIPS_ARCH_3 = EF_MIPS_ARCH_3; +enum E_MIPS_ARCH_4 = EF_MIPS_ARCH_4; +enum E_MIPS_ARCH_5 = EF_MIPS_ARCH_5; +enum E_MIPS_ARCH_32 = EF_MIPS_ARCH_32; +enum E_MIPS_ARCH_64 = EF_MIPS_ARCH_64; + +enum SHN_MIPS_ACOMMON = 0xff00; +enum SHN_MIPS_TEXT = 0xff01; +enum SHN_MIPS_DATA = 0xff02; +enum SHN_MIPS_SCOMMON = 0xff03; +enum SHN_MIPS_SUNDEFINED = 0xff04; + +enum SHT_MIPS_LIBLIST = 0x70000000; +enum SHT_MIPS_MSYM = 0x70000001; +enum SHT_MIPS_CONFLICT = 0x70000002; +enum SHT_MIPS_GPTAB = 0x70000003; +enum SHT_MIPS_UCODE = 0x70000004; +enum SHT_MIPS_DEBUG = 0x70000005; +enum SHT_MIPS_REGINFO = 0x70000006; +enum SHT_MIPS_PACKAGE = 0x70000007; +enum SHT_MIPS_PACKSYM = 0x70000008; +enum SHT_MIPS_RELD = 0x70000009; +enum SHT_MIPS_IFACE = 0x7000000b; +enum SHT_MIPS_CONTENT = 0x7000000c; +enum SHT_MIPS_OPTIONS = 0x7000000d; +enum SHT_MIPS_SHDR = 0x70000010; +enum SHT_MIPS_FDESC = 0x70000011; +enum SHT_MIPS_EXTSYM = 0x70000012; +enum SHT_MIPS_DENSE = 0x70000013; +enum SHT_MIPS_PDESC = 0x70000014; +enum SHT_MIPS_LOCSYM = 0x70000015; +enum SHT_MIPS_AUXSYM = 0x70000016; +enum SHT_MIPS_OPTSYM = 0x70000017; +enum SHT_MIPS_LOCSTR = 0x70000018; +enum SHT_MIPS_LINE = 0x70000019; +enum SHT_MIPS_RFDESC = 0x7000001a; +enum SHT_MIPS_DELTASYM = 0x7000001b; +enum SHT_MIPS_DELTAINST = 0x7000001c; +enum SHT_MIPS_DELTACLASS = 0x7000001d; +enum SHT_MIPS_DWARF = 0x7000001e; +enum SHT_MIPS_DELTADECL = 0x7000001f; +enum SHT_MIPS_SYMBOL_LIB = 0x70000020; +enum SHT_MIPS_EVENTS = 0x70000021; +enum SHT_MIPS_TRANSLATE = 0x70000022; +enum SHT_MIPS_PIXIE = 0x70000023; +enum SHT_MIPS_XLATE = 0x70000024; +enum SHT_MIPS_XLATE_DEBUG = 0x70000025; +enum SHT_MIPS_WHIRL = 0x70000026; +enum SHT_MIPS_EH_REGION = 0x70000027; +enum SHT_MIPS_XLATE_OLD = 0x70000028; +enum SHT_MIPS_PDR_EXCEPTION = 0x70000029; + +enum SHF_MIPS_GPREL = 0x10000000; +enum SHF_MIPS_MERGE = 0x20000000; +enum SHF_MIPS_ADDR = 0x40000000; +enum SHF_MIPS_STRINGS = 0x80000000; +enum SHF_MIPS_NOSTRIP = 0x08000000; +enum SHF_MIPS_LOCAL = 0x04000000; +enum SHF_MIPS_NAMES = 0x02000000; +enum SHF_MIPS_NODUPE = 0x01000000; +enum STO_MIPS_DEFAULT = 0x0; +enum STO_MIPS_INTERNAL = 0x1; +enum STO_MIPS_HIDDEN = 0x2; +enum STO_MIPS_PROTECTED = 0x3; +enum STO_MIPS_PLT = 0x8; +enum STO_MIPS_SC_ALIGN_UNUSED = 0xff; +enum STB_MIPS_SPLIT_COMMON = 13; + +union Elf32_gptab +{ + struct _gt_header + { + Elf32_Word gt_current_g_value; + Elf32_Word gt_unused; + } _gt_header gt_header; + struct _gt_entry + { + Elf32_Word gt_g_value; + Elf32_Word gt_bytes; + } _gt_entry gt_entry; +} + +struct Elf32_RegInfo +{ + Elf32_Word ri_gprmask; + Elf32_Word[4] ri_cprmask; + Elf32_Sword ri_gp_value; +} + +struct Elf_Options +{ + ubyte kind; + ubyte size; + Elf32_Section section; + Elf32_Word info; +} + +enum ODK_NULL = 0; +enum ODK_REGINFO = 1; +enum ODK_EXCEPTIONS = 2; +enum ODK_PAD = 3; +enum ODK_HWPATCH = 4; +enum ODK_FILL = 5; +enum ODK_TAGS = 6; +enum ODK_HWAND = 7; +enum ODK_HWOR = 8; + +enum OEX_FPU_MIN = 0x1f; +enum OEX_FPU_MAX = 0x1f00; +enum OEX_PAGE0 = 0x10000; +enum OEX_SMM = 0x20000; +enum OEX_FPDBUG = 0x40000; +enum OEX_PRECISEFP = OEX_FPDBUG; +enum OEX_DISMISS = 0x80000; + +enum OEX_FPU_INVAL = 0x10; +enum OEX_FPU_DIV0 = 0x08; +enum OEX_FPU_OFLO = 0x04; +enum OEX_FPU_UFLO = 0x02; +enum OEX_FPU_INEX = 0x01; + +enum OHW_R4KEOP = 0x1; +enum OHW_R8KPFETCH = 0x2; +enum OHW_R5KEOP = 0x4; +enum OHW_R5KCVTL = 0x8; + +enum OPAD_PREFIX = 0x1; +enum OPAD_POSTFIX = 0x2; +enum OPAD_SYMBOL = 0x4; + +struct Elf_Options_Hw +{ + Elf32_Word hwp_flags1; + Elf32_Word hwp_flags2; +} + +enum OHWA0_R4KEOP_CHECKED = 0x00000001; +enum OHWA1_R4KEOP_CLEAN = 0x00000002; + +enum R_MIPS_NONE = 0; +enum R_MIPS_16 = 1; +enum R_MIPS_32 = 2; +enum R_MIPS_REL32 = 3; +enum R_MIPS_26 = 4; +enum R_MIPS_HI16 = 5; +enum R_MIPS_LO16 = 6; +enum R_MIPS_GPREL16 = 7; +enum R_MIPS_LITERAL = 8; +enum R_MIPS_GOT16 = 9; +enum R_MIPS_PC16 = 10; +enum R_MIPS_CALL16 = 11; +enum R_MIPS_GPREL32 = 12; + +enum R_MIPS_SHIFT5 = 16; +enum R_MIPS_SHIFT6 = 17; +enum R_MIPS_64 = 18; +enum R_MIPS_GOT_DISP = 19; +enum R_MIPS_GOT_PAGE = 20; +enum R_MIPS_GOT_OFST = 21; +enum R_MIPS_GOT_HI16 = 22; +enum R_MIPS_GOT_LO16 = 23; +enum R_MIPS_SUB = 24; +enum R_MIPS_INSERT_A = 25; +enum R_MIPS_INSERT_B = 26; +enum R_MIPS_DELETE = 27; +enum R_MIPS_HIGHER = 28; +enum R_MIPS_HIGHEST = 29; +enum R_MIPS_CALL_HI16 = 30; +enum R_MIPS_CALL_LO16 = 31; +enum R_MIPS_SCN_DISP = 32; +enum R_MIPS_REL16 = 33; +enum R_MIPS_ADD_IMMEDIATE = 34; +enum R_MIPS_PJUMP = 35; +enum R_MIPS_RELGOT = 36; +enum R_MIPS_JALR = 37; +enum R_MIPS_TLS_DTPMOD32 = 38; +enum R_MIPS_TLS_DTPREL32 = 39; +enum R_MIPS_TLS_DTPMOD64 = 40; +enum R_MIPS_TLS_DTPREL64 = 41; +enum R_MIPS_TLS_GD = 42; +enum R_MIPS_TLS_LDM = 43; +enum R_MIPS_TLS_DTPREL_HI16 = 44; +enum R_MIPS_TLS_DTPREL_LO16 = 45; +enum R_MIPS_TLS_GOTTPREL = 46; +enum R_MIPS_TLS_TPREL32 = 47; +enum R_MIPS_TLS_TPREL64 = 48; +enum R_MIPS_TLS_TPREL_HI16 = 49; +enum R_MIPS_TLS_TPREL_LO16 = 50; +enum R_MIPS_GLOB_DAT = 51; +enum R_MIPS_COPY = 126; +enum R_MIPS_JUMP_SLOT = 127; +enum R_MIPS_NUM = 128; + +enum PT_MIPS_REGINFO = 0x70000000; +enum PT_MIPS_RTPROC = 0x70000001; +enum PT_MIPS_OPTIONS = 0x70000002; + +enum PF_MIPS_LOCAL = 0x10000000; + +enum DT_MIPS_RLD_VERSION = 0x70000001; +enum DT_MIPS_TIME_STAMP = 0x70000002; +enum DT_MIPS_ICHECKSUM = 0x70000003; +enum DT_MIPS_IVERSION = 0x70000004; +enum DT_MIPS_FLAGS = 0x70000005; +enum DT_MIPS_BASE_ADDRESS = 0x70000006; +enum DT_MIPS_MSYM = 0x70000007; +enum DT_MIPS_CONFLICT = 0x70000008; +enum DT_MIPS_LIBLIST = 0x70000009; +enum DT_MIPS_LOCAL_GOTNO = 0x7000000a; +enum DT_MIPS_CONFLICTNO = 0x7000000b; +enum DT_MIPS_LIBLISTNO = 0x70000010; +enum DT_MIPS_SYMTABNO = 0x70000011; +enum DT_MIPS_UNREFEXTNO = 0x70000012; +enum DT_MIPS_GOTSYM = 0x70000013; +enum DT_MIPS_HIPAGENO = 0x70000014; +enum DT_MIPS_RLD_MAP = 0x70000016; +enum DT_MIPS_DELTA_CLASS = 0x70000017; +enum DT_MIPS_DELTA_CLASS_NO = 0x70000018; +enum DT_MIPS_DELTA_INSTANCE = 0x70000019; +enum DT_MIPS_DELTA_INSTANCE_NO = 0x7000001a; +enum DT_MIPS_DELTA_RELOC = 0x7000001b; +enum DT_MIPS_DELTA_RELOC_NO = 0x7000001c; +enum DT_MIPS_DELTA_SYM = 0x7000001d; +enum DT_MIPS_DELTA_SYM_NO = 0x7000001e; +enum DT_MIPS_DELTA_CLASSSYM = 0x70000020; +enum DT_MIPS_DELTA_CLASSSYM_NO = 0x70000021; +enum DT_MIPS_CXX_FLAGS = 0x70000022; +enum DT_MIPS_PIXIE_INIT = 0x70000023; +enum DT_MIPS_SYMBOL_LIB = 0x70000024; +enum DT_MIPS_LOCALPAGE_GOTIDX = 0x70000025; +enum DT_MIPS_LOCAL_GOTIDX = 0x70000026; +enum DT_MIPS_HIDDEN_GOTIDX = 0x70000027; +enum DT_MIPS_PROTECTED_GOTIDX = 0x70000028; +enum DT_MIPS_OPTIONS = 0x70000029; +enum DT_MIPS_INTERFACE = 0x7000002a; +enum DT_MIPS_DYNSTR_ALIGN = 0x7000002b; +enum DT_MIPS_INTERFACE_SIZE = 0x7000002c; +enum DT_MIPS_RLD_TEXT_RESOLVE_ADDR = 0x7000002d; +enum DT_MIPS_PERF_SUFFIX = 0x7000002e; +enum DT_MIPS_COMPACT_SIZE = 0x7000002f; +enum DT_MIPS_GP_VALUE = 0x70000030; +enum DT_MIPS_AUX_DYNAMIC = 0x70000031; +enum DT_MIPS_PLTGOT = 0x70000032; +enum DT_MIPS_RWPLT = 0x70000034; +enum DT_MIPS_NUM = 0x35; + +enum RHF_NONE = 0; +enum RHF_QUICKSTART = (1 << 0); +enum RHF_NOTPOT = (1 << 1); +enum RHF_NO_LIBRARY_REPLACEMENT = (1 << 2); +enum RHF_NO_MOVE = (1 << 3); +enum RHF_SGI_ONLY = (1 << 4); +enum RHF_GUARANTEE_INIT = (1 << 5); +enum RHF_DELTA_C_PLUS_PLUS = (1 << 6); +enum RHF_GUARANTEE_START_INIT = (1 << 7); +enum RHF_PIXIE = (1 << 8); +enum RHF_DEFAULT_DELAY_LOAD = (1 << 9); +enum RHF_REQUICKSTART = (1 << 10); +enum RHF_REQUICKSTARTED = (1 << 11); +enum RHF_CORD = (1 << 12); +enum RHF_NO_UNRES_UNDEF = (1 << 13); +enum RHF_RLD_ORDER_SAFE = (1 << 14); + +struct Elf32_Lib +{ + Elf32_Word l_name; + Elf32_Word l_time_stamp; + Elf32_Word l_checksum; + Elf32_Word l_version; + Elf32_Word l_flags; +} + +struct Elf64_Lib +{ + Elf64_Word l_name; + Elf64_Word l_time_stamp; + Elf64_Word l_checksum; + Elf64_Word l_version; + Elf64_Word l_flags; +} + +enum LL_NONE = 0; +enum LL_EXACT_MATCH = (1 << 0); +enum LL_IGNORE_INT_VER = (1 << 1); +enum LL_REQUIRE_MINOR = (1 << 2); +enum LL_EXPORTS = (1 << 3); +enum LL_DELAY_LOAD = (1 << 4); +enum LL_DELTA = (1 << 5); + +alias Elf32_Addr Elf32_Conflict; + +enum EF_PARISC_TRAPNIL = 0x00010000; +enum EF_PARISC_EXT = 0x00020000; +enum EF_PARISC_LSB = 0x00040000; +enum EF_PARISC_WIDE = 0x00080000; +enum EF_PARISC_NO_KABP = 0x00100000; +enum EF_PARISC_LAZYSWAP = 0x00400000; +enum EF_PARISC_ARCH = 0x0000ffff; + +enum EFA_PARISC_1_0 = 0x020b; +enum EFA_PARISC_1_1 = 0x0210; +enum EFA_PARISC_2_0 = 0x0214; + +enum SHN_PARISC_ANSI_COMMON = 0xff00; +enum SHN_PARISC_HUGE_COMMON = 0xff01; + +enum SHT_PARISC_EXT = 0x70000000; +enum SHT_PARISC_UNWIND = 0x70000001; +enum SHT_PARISC_DOC = 0x70000002; + +enum SHF_PARISC_SHORT = 0x20000000; +enum SHF_PARISC_HUGE = 0x40000000; +enum SHF_PARISC_SBP = 0x80000000; + +enum STT_PARISC_MILLICODE = 13; + +enum STT_HP_OPAQUE = (STT_LOOS + 0x1); +enum STT_HP_STUB = (STT_LOOS + 0x2); + +enum R_PARISC_NONE = 0; +enum R_PARISC_DIR32 = 1; +enum R_PARISC_DIR21L = 2; +enum R_PARISC_DIR17R = 3; +enum R_PARISC_DIR17F = 4; +enum R_PARISC_DIR14R = 6; +enum R_PARISC_PCREL32 = 9; +enum R_PARISC_PCREL21L = 10; +enum R_PARISC_PCREL17R = 11; +enum R_PARISC_PCREL17F = 12; +enum R_PARISC_PCREL14R = 14; +enum R_PARISC_DPREL21L = 18; +enum R_PARISC_DPREL14R = 22; +enum R_PARISC_GPREL21L = 26; +enum R_PARISC_GPREL14R = 30; +enum R_PARISC_LTOFF21L = 34; +enum R_PARISC_LTOFF14R = 38; +enum R_PARISC_SECREL32 = 41; +enum R_PARISC_SEGBASE = 48; +enum R_PARISC_SEGREL32 = 49; +enum R_PARISC_PLTOFF21L = 50; +enum R_PARISC_PLTOFF14R = 54; +enum R_PARISC_LTOFF_FPTR32 = 57; +enum R_PARISC_LTOFF_FPTR21L = 58; +enum R_PARISC_LTOFF_FPTR14R = 62; +enum R_PARISC_FPTR64 = 64; +enum R_PARISC_PLABEL32 = 65; +enum R_PARISC_PLABEL21L = 66; +enum R_PARISC_PLABEL14R = 70; +enum R_PARISC_PCREL64 = 72; +enum R_PARISC_PCREL22F = 74; +enum R_PARISC_PCREL14WR = 75; +enum R_PARISC_PCREL14DR = 76; +enum R_PARISC_PCREL16F = 77; +enum R_PARISC_PCREL16WF = 78; +enum R_PARISC_PCREL16DF = 79; +enum R_PARISC_DIR64 = 80; +enum R_PARISC_DIR14WR = 83; +enum R_PARISC_DIR14DR = 84; +enum R_PARISC_DIR16F = 85; +enum R_PARISC_DIR16WF = 86; +enum R_PARISC_DIR16DF = 87; +enum R_PARISC_GPREL64 = 88; +enum R_PARISC_GPREL14WR = 91; +enum R_PARISC_GPREL14DR = 92; +enum R_PARISC_GPREL16F = 93; +enum R_PARISC_GPREL16WF = 94; +enum R_PARISC_GPREL16DF = 95; +enum R_PARISC_LTOFF64 = 96; +enum R_PARISC_LTOFF14WR = 99; +enum R_PARISC_LTOFF14DR = 100; +enum R_PARISC_LTOFF16F = 101; +enum R_PARISC_LTOFF16WF = 102; +enum R_PARISC_LTOFF16DF = 103; +enum R_PARISC_SECREL64 = 104; +enum R_PARISC_SEGREL64 = 112; +enum R_PARISC_PLTOFF14WR = 115; +enum R_PARISC_PLTOFF14DR = 116; +enum R_PARISC_PLTOFF16F = 117; +enum R_PARISC_PLTOFF16WF = 118; +enum R_PARISC_PLTOFF16DF = 119; +enum R_PARISC_LTOFF_FPTR64 = 120; +enum R_PARISC_LTOFF_FPTR14WR = 123; +enum R_PARISC_LTOFF_FPTR14DR = 124; +enum R_PARISC_LTOFF_FPTR16F = 125; +enum R_PARISC_LTOFF_FPTR16WF = 126; +enum R_PARISC_LTOFF_FPTR16DF = 127; +enum R_PARISC_LORESERVE = 128; +enum R_PARISC_COPY = 128; +enum R_PARISC_IPLT = 129; +enum R_PARISC_EPLT = 130; +enum R_PARISC_TPREL32 = 153; +enum R_PARISC_TPREL21L = 154; +enum R_PARISC_TPREL14R = 158; +enum R_PARISC_LTOFF_TP21L = 162; +enum R_PARISC_LTOFF_TP14R = 166; +enum R_PARISC_LTOFF_TP14F = 167; +enum R_PARISC_TPREL64 = 216; +enum R_PARISC_TPREL14WR = 219; +enum R_PARISC_TPREL14DR = 220; +enum R_PARISC_TPREL16F = 221; +enum R_PARISC_TPREL16WF = 222; +enum R_PARISC_TPREL16DF = 223; +enum R_PARISC_LTOFF_TP64 = 224; +enum R_PARISC_LTOFF_TP14WR = 227; +enum R_PARISC_LTOFF_TP14DR = 228; +enum R_PARISC_LTOFF_TP16F = 229; +enum R_PARISC_LTOFF_TP16WF = 230; +enum R_PARISC_LTOFF_TP16DF = 231; +enum R_PARISC_GNU_VTENTRY = 232; +enum R_PARISC_GNU_VTINHERIT = 233; +enum R_PARISC_TLS_GD21L = 234; +enum R_PARISC_TLS_GD14R = 235; +enum R_PARISC_TLS_GDCALL = 236; +enum R_PARISC_TLS_LDM21L = 237; +enum R_PARISC_TLS_LDM14R = 238; +enum R_PARISC_TLS_LDMCALL = 239; +enum R_PARISC_TLS_LDO21L = 240; +enum R_PARISC_TLS_LDO14R = 241; +enum R_PARISC_TLS_DTPMOD32 = 242; +enum R_PARISC_TLS_DTPMOD64 = 243; +enum R_PARISC_TLS_DTPOFF32 = 244; +enum R_PARISC_TLS_DTPOFF64 = 245; +enum R_PARISC_TLS_LE21L = R_PARISC_TPREL21L; +enum R_PARISC_TLS_LE14R = R_PARISC_TPREL14R; +enum R_PARISC_TLS_IE21L = R_PARISC_LTOFF_TP21L; +enum R_PARISC_TLS_IE14R = R_PARISC_LTOFF_TP14R; +enum R_PARISC_TLS_TPREL32 = R_PARISC_TPREL32; +enum R_PARISC_TLS_TPREL64 = R_PARISC_TPREL64; +enum R_PARISC_HIRESERVE = 255; + +enum PT_HP_TLS = (PT_LOOS + 0x0); +enum PT_HP_CORE_NONE = (PT_LOOS + 0x1); +enum PT_HP_CORE_VERSION = (PT_LOOS + 0x2); +enum PT_HP_CORE_KERNEL = (PT_LOOS + 0x3); +enum PT_HP_CORE_COMM = (PT_LOOS + 0x4); +enum PT_HP_CORE_PROC = (PT_LOOS + 0x5); +enum PT_HP_CORE_LOADABLE = (PT_LOOS + 0x6); +enum PT_HP_CORE_STACK = (PT_LOOS + 0x7); +enum PT_HP_CORE_SHM = (PT_LOOS + 0x8); +enum PT_HP_CORE_MMF = (PT_LOOS + 0x9); +enum PT_HP_PARALLEL = (PT_LOOS + 0x10); +enum PT_HP_FASTBIND = (PT_LOOS + 0x11); +enum PT_HP_OPT_ANNOT = (PT_LOOS + 0x12); +enum PT_HP_HSL_ANNOT = (PT_LOOS + 0x13); +enum PT_HP_STACK = (PT_LOOS + 0x14); + +enum PT_PARISC_ARCHEXT = 0x70000000; +enum PT_PARISC_UNWIND = 0x70000001; + +enum PF_PARISC_SBP = 0x08000000; + +enum PF_HP_PAGE_SIZE = 0x00100000; +enum PF_HP_FAR_SHARED = 0x00200000; +enum PF_HP_NEAR_SHARED = 0x00400000; +enum PF_HP_CODE = 0x01000000; +enum PF_HP_MODIFY = 0x02000000; +enum PF_HP_LAZYSWAP = 0x04000000; +enum PF_HP_SBP = 0x08000000; + +enum EF_ALPHA_32BIT = 1; +enum EF_ALPHA_CANRELAX = 2; +enum SHT_ALPHA_DEBUG = 0x70000001; +enum SHT_ALPHA_REGINFO = 0x70000002; + +enum SHF_ALPHA_GPREL = 0x10000000; +enum STO_ALPHA_NOPV = 0x80; +enum STO_ALPHA_STD_GPLOAD = 0x88; + +enum R_ALPHA_NONE = 0; +enum R_ALPHA_REFLONG = 1; +enum R_ALPHA_REFQUAD = 2; +enum R_ALPHA_GPREL32 = 3; +enum R_ALPHA_LITERAL = 4; +enum R_ALPHA_LITUSE = 5; +enum R_ALPHA_GPDISP = 6; +enum R_ALPHA_BRADDR = 7; +enum R_ALPHA_HINT = 8; +enum R_ALPHA_SREL16 = 9; +enum R_ALPHA_SREL32 = 10; +enum R_ALPHA_SREL64 = 11; +enum R_ALPHA_GPRELHIGH = 17; +enum R_ALPHA_GPRELLOW = 18; +enum R_ALPHA_GPREL16 = 19; +enum R_ALPHA_COPY = 24; +enum R_ALPHA_GLOB_DAT = 25; +enum R_ALPHA_JMP_SLOT = 26; +enum R_ALPHA_RELATIVE = 27; +enum R_ALPHA_TLS_GD_HI = 28; +enum R_ALPHA_TLSGD = 29; +enum R_ALPHA_TLS_LDM = 30; +enum R_ALPHA_DTPMOD64 = 31; +enum R_ALPHA_GOTDTPREL = 32; +enum R_ALPHA_DTPREL64 = 33; +enum R_ALPHA_DTPRELHI = 34; +enum R_ALPHA_DTPRELLO = 35; +enum R_ALPHA_DTPREL16 = 36; +enum R_ALPHA_GOTTPREL = 37; +enum R_ALPHA_TPREL64 = 38; +enum R_ALPHA_TPRELHI = 39; +enum R_ALPHA_TPRELLO = 40; +enum R_ALPHA_TPREL16 = 41; +enum R_ALPHA_NUM = 46; +enum LITUSE_ALPHA_ADDR = 0; +enum LITUSE_ALPHA_BASE = 1; +enum LITUSE_ALPHA_BYTOFF = 2; +enum LITUSE_ALPHA_JSR = 3; +enum LITUSE_ALPHA_TLS_GD = 4; +enum LITUSE_ALPHA_TLS_LDM = 5; +enum DT_ALPHA_PLTRO = (DT_LOPROC + 0); +enum DT_ALPHA_NUM = 1; +enum EF_PPC_EMB = 0x80000000; +enum EF_PPC_RELOCATABLE = 0x00010000; +enum EF_PPC_RELOCATABLE_LIB = 0x00008000; +enum R_PPC_NONE = 0; +enum R_PPC_ADDR32 = 1; +enum R_PPC_ADDR24 = 2; +enum R_PPC_ADDR16 = 3; +enum R_PPC_ADDR16_LO = 4; +enum R_PPC_ADDR16_HI = 5; +enum R_PPC_ADDR16_HA = 6; +enum R_PPC_ADDR14 = 7; +enum R_PPC_ADDR14_BRTAKEN = 8; +enum R_PPC_ADDR14_BRNTAKEN = 9; +enum R_PPC_REL24 = 10; +enum R_PPC_REL14 = 11; +enum R_PPC_REL14_BRTAKEN = 12; +enum R_PPC_REL14_BRNTAKEN = 13; +enum R_PPC_GOT16 = 14; +enum R_PPC_GOT16_LO = 15; +enum R_PPC_GOT16_HI = 16; +enum R_PPC_GOT16_HA = 17; +enum R_PPC_PLTREL24 = 18; +enum R_PPC_COPY = 19; +enum R_PPC_GLOB_DAT = 20; +enum R_PPC_JMP_SLOT = 21; +enum R_PPC_RELATIVE = 22; +enum R_PPC_LOCAL24PC = 23; +enum R_PPC_UADDR32 = 24; +enum R_PPC_UADDR16 = 25; +enum R_PPC_REL32 = 26; +enum R_PPC_PLT32 = 27; +enum R_PPC_PLTREL32 = 28; +enum R_PPC_PLT16_LO = 29; +enum R_PPC_PLT16_HI = 30; +enum R_PPC_PLT16_HA = 31; +enum R_PPC_SDAREL16 = 32; +enum R_PPC_SECTOFF = 33; +enum R_PPC_SECTOFF_LO = 34; +enum R_PPC_SECTOFF_HI = 35; +enum R_PPC_SECTOFF_HA = 36; +enum R_PPC_TLS = 67; +enum R_PPC_DTPMOD32 = 68; +enum R_PPC_TPREL16 = 69; +enum R_PPC_TPREL16_LO = 70; +enum R_PPC_TPREL16_HI = 71; +enum R_PPC_TPREL16_HA = 72; +enum R_PPC_TPREL32 = 73; +enum R_PPC_DTPREL16 = 74; +enum R_PPC_DTPREL16_LO = 75; +enum R_PPC_DTPREL16_HI = 76; +enum R_PPC_DTPREL16_HA = 77; +enum R_PPC_DTPREL32 = 78; +enum R_PPC_GOT_TLSGD16 = 79; +enum R_PPC_GOT_TLSGD16_LO = 80; +enum R_PPC_GOT_TLSGD16_HI = 81; +enum R_PPC_GOT_TLSGD16_HA = 82; +enum R_PPC_GOT_TLSLD16 = 83; +enum R_PPC_GOT_TLSLD16_LO = 84; +enum R_PPC_GOT_TLSLD16_HI = 85; +enum R_PPC_GOT_TLSLD16_HA = 86; +enum R_PPC_GOT_TPREL16 = 87; +enum R_PPC_GOT_TPREL16_LO = 88; +enum R_PPC_GOT_TPREL16_HI = 89; +enum R_PPC_GOT_TPREL16_HA = 90; +enum R_PPC_GOT_DTPREL16 = 91; +enum R_PPC_GOT_DTPREL16_LO = 92; +enum R_PPC_GOT_DTPREL16_HI = 93; +enum R_PPC_GOT_DTPREL16_HA = 94; +enum R_PPC_EMB_NADDR32 = 101; +enum R_PPC_EMB_NADDR16 = 102; +enum R_PPC_EMB_NADDR16_LO = 103; +enum R_PPC_EMB_NADDR16_HI = 104; +enum R_PPC_EMB_NADDR16_HA = 105; +enum R_PPC_EMB_SDAI16 = 106; +enum R_PPC_EMB_SDA2I16 = 107; +enum R_PPC_EMB_SDA2REL = 108; +enum R_PPC_EMB_SDA21 = 109; +enum R_PPC_EMB_MRKREF = 110; +enum R_PPC_EMB_RELSEC16 = 111; +enum R_PPC_EMB_RELST_LO = 112; +enum R_PPC_EMB_RELST_HI = 113; +enum R_PPC_EMB_RELST_HA = 114; +enum R_PPC_EMB_BIT_FLD = 115; +enum R_PPC_EMB_RELSDA = 116; +enum R_PPC_DIAB_SDA21_LO = 180; +enum R_PPC_DIAB_SDA21_HI = 181; +enum R_PPC_DIAB_SDA21_HA = 182; +enum R_PPC_DIAB_RELSDA_LO = 183; +enum R_PPC_DIAB_RELSDA_HI = 184; +enum R_PPC_DIAB_RELSDA_HA = 185; +enum R_PPC_IRELATIVE = 248; +enum R_PPC_REL16 = 249; +enum R_PPC_REL16_LO = 250; +enum R_PPC_REL16_HI = 251; +enum R_PPC_REL16_HA = 252; +enum R_PPC_TOC16 = 255; +enum DT_PPC_GOT = (DT_LOPROC + 0); +enum DT_PPC_NUM = 1; +enum R_PPC64_NONE = R_PPC_NONE; +enum R_PPC64_ADDR32 = R_PPC_ADDR32; +enum R_PPC64_ADDR24 = R_PPC_ADDR24; +enum R_PPC64_ADDR16 = R_PPC_ADDR16; +enum R_PPC64_ADDR16_LO = R_PPC_ADDR16_LO; +enum R_PPC64_ADDR16_HI = R_PPC_ADDR16_HI; +enum R_PPC64_ADDR16_HA = R_PPC_ADDR16_HA; +enum R_PPC64_ADDR14 = R_PPC_ADDR14; +enum R_PPC64_ADDR14_BRTAKEN = R_PPC_ADDR14_BRTAKEN; +enum R_PPC64_ADDR14_BRNTAKEN = R_PPC_ADDR14_BRNTAKEN; +enum R_PPC64_REL24 = R_PPC_REL24; +enum R_PPC64_REL14 = R_PPC_REL14; +enum R_PPC64_REL14_BRTAKEN = R_PPC_REL14_BRTAKEN; +enum R_PPC64_REL14_BRNTAKEN = R_PPC_REL14_BRNTAKEN; +enum R_PPC64_GOT16 = R_PPC_GOT16; +enum R_PPC64_GOT16_LO = R_PPC_GOT16_LO; +enum R_PPC64_GOT16_HI = R_PPC_GOT16_HI; +enum R_PPC64_GOT16_HA = R_PPC_GOT16_HA; + +enum R_PPC64_COPY = R_PPC_COPY; +enum R_PPC64_GLOB_DAT = R_PPC_GLOB_DAT; +enum R_PPC64_JMP_SLOT = R_PPC_JMP_SLOT; +enum R_PPC64_RELATIVE = R_PPC_RELATIVE; + +enum R_PPC64_UADDR32 = R_PPC_UADDR32; +enum R_PPC64_UADDR16 = R_PPC_UADDR16; +enum R_PPC64_REL32 = R_PPC_REL32; +enum R_PPC64_PLT32 = R_PPC_PLT32; +enum R_PPC64_PLTREL32 = R_PPC_PLTREL32; +enum R_PPC64_PLT16_LO = R_PPC_PLT16_LO; +enum R_PPC64_PLT16_HI = R_PPC_PLT16_HI; +enum R_PPC64_PLT16_HA = R_PPC_PLT16_HA; + +enum R_PPC64_SECTOFF = R_PPC_SECTOFF; +enum R_PPC64_SECTOFF_LO = R_PPC_SECTOFF_LO; +enum R_PPC64_SECTOFF_HI = R_PPC_SECTOFF_HI; +enum R_PPC64_SECTOFF_HA = R_PPC_SECTOFF_HA; +enum R_PPC64_ADDR30 = 37; +enum R_PPC64_ADDR64 = 38; +enum R_PPC64_ADDR16_HIGHER = 39; +enum R_PPC64_ADDR16_HIGHERA = 40; +enum R_PPC64_ADDR16_HIGHEST = 41; +enum R_PPC64_ADDR16_HIGHESTA = 42; +enum R_PPC64_UADDR64 = 43; +enum R_PPC64_REL64 = 44; +enum R_PPC64_PLT64 = 45; +enum R_PPC64_PLTREL64 = 46; +enum R_PPC64_TOC16 = 47; +enum R_PPC64_TOC16_LO = 48; +enum R_PPC64_TOC16_HI = 49; +enum R_PPC64_TOC16_HA = 50; +enum R_PPC64_TOC = 51; +enum R_PPC64_PLTGOT16 = 52; +enum R_PPC64_PLTGOT16_LO = 53; +enum R_PPC64_PLTGOT16_HI = 54; +enum R_PPC64_PLTGOT16_HA = 55; + +enum R_PPC64_ADDR16_DS = 56; +enum R_PPC64_ADDR16_LO_DS = 57; +enum R_PPC64_GOT16_DS = 58; +enum R_PPC64_GOT16_LO_DS = 59; +enum R_PPC64_PLT16_LO_DS = 60; +enum R_PPC64_SECTOFF_DS = 61; +enum R_PPC64_SECTOFF_LO_DS = 62; +enum R_PPC64_TOC16_DS = 63; +enum R_PPC64_TOC16_LO_DS = 64; +enum R_PPC64_PLTGOT16_DS = 65; +enum R_PPC64_PLTGOT16_LO_DS = 66; +enum R_PPC64_TLS = 67; +enum R_PPC64_DTPMOD64 = 68; +enum R_PPC64_TPREL16 = 69; +enum R_PPC64_TPREL16_LO = 70; +enum R_PPC64_TPREL16_HI = 71; +enum R_PPC64_TPREL16_HA = 72; +enum R_PPC64_TPREL64 = 73; +enum R_PPC64_DTPREL16 = 74; +enum R_PPC64_DTPREL16_LO = 75; +enum R_PPC64_DTPREL16_HI = 76; +enum R_PPC64_DTPREL16_HA = 77; +enum R_PPC64_DTPREL64 = 78; +enum R_PPC64_GOT_TLSGD16 = 79; +enum R_PPC64_GOT_TLSGD16_LO = 80; +enum R_PPC64_GOT_TLSGD16_HI = 81; +enum R_PPC64_GOT_TLSGD16_HA = 82; +enum R_PPC64_GOT_TLSLD16 = 83; +enum R_PPC64_GOT_TLSLD16_LO = 84; +enum R_PPC64_GOT_TLSLD16_HI = 85; +enum R_PPC64_GOT_TLSLD16_HA = 86; +enum R_PPC64_GOT_TPREL16_DS = 87; +enum R_PPC64_GOT_TPREL16_LO_DS = 88; +enum R_PPC64_GOT_TPREL16_HI = 89; +enum R_PPC64_GOT_TPREL16_HA = 90; +enum R_PPC64_GOT_DTPREL16_DS = 91; +enum R_PPC64_GOT_DTPREL16_LO_DS = 92; +enum R_PPC64_GOT_DTPREL16_HI = 93; +enum R_PPC64_GOT_DTPREL16_HA = 94; +enum R_PPC64_TPREL16_DS = 95; +enum R_PPC64_TPREL16_LO_DS = 96; +enum R_PPC64_TPREL16_HIGHER = 97; +enum R_PPC64_TPREL16_HIGHERA = 98; +enum R_PPC64_TPREL16_HIGHEST = 99; +enum R_PPC64_TPREL16_HIGHESTA = 100; +enum R_PPC64_DTPREL16_DS = 101; +enum R_PPC64_DTPREL16_LO_DS = 102; +enum R_PPC64_DTPREL16_HIGHER = 103; +enum R_PPC64_DTPREL16_HIGHERA = 104; +enum R_PPC64_DTPREL16_HIGHEST = 105; +enum R_PPC64_DTPREL16_HIGHESTA = 106; +enum R_PPC64_JMP_IREL = 247; +enum R_PPC64_IRELATIVE = 248; +enum R_PPC64_REL16 = 249; +enum R_PPC64_REL16_LO = 250; +enum R_PPC64_REL16_HI = 251; +enum R_PPC64_REL16_HA = 252; +enum DT_PPC64_GLINK = (DT_LOPROC + 0); +enum DT_PPC64_OPD = (DT_LOPROC + 1); +enum DT_PPC64_OPDSZ = (DT_LOPROC + 2); +enum DT_PPC64_NUM = 3; +enum EF_ARM_RELEXEC = 0x01; +enum EF_ARM_HASENTRY = 0x02; +enum EF_ARM_INTERWORK = 0x04; +enum EF_ARM_APCS_26 = 0x08; +enum EF_ARM_APCS_FLOAT = 0x10; +enum EF_ARM_PIC = 0x20; +enum EF_ARM_ALIGN8 = 0x40; +enum EF_ARM_NEW_ABI = 0x80; +enum EF_ARM_OLD_ABI = 0x100; +enum EF_ARM_SOFT_FLOAT = 0x200; +enum EF_ARM_VFP_FLOAT = 0x400; +enum EF_ARM_MAVERICK_FLOAT = 0x800; + +enum EF_ARM_ABI_FLOAT_SOFT = 0x200; +enum EF_ARM_ABI_FLOAT_HARD = 0x400; +enum EF_ARM_SYMSARESORTED = 0x04; +enum EF_ARM_DYNSYMSUSESEGIDX = 0x08; +enum EF_ARM_MAPSYMSFIRST = 0x10; +enum EF_ARM_EABIMASK = 0XFF000000; +enum EF_ARM_BE8 = 0x00800000; +enum EF_ARM_LE8 = 0x00400000; + +extern (D) auto EF_ARM_EABI_VERSION(F)(F flags) { return flags & EF_ARM_EABIMASK; } +enum EF_ARM_EABI_UNKNOWN = 0x00000000; +enum EF_ARM_EABI_VER1 = 0x01000000; +enum EF_ARM_EABI_VER2 = 0x02000000; +enum EF_ARM_EABI_VER3 = 0x03000000; +enum EF_ARM_EABI_VER4 = 0x04000000; +enum EF_ARM_EABI_VER5 = 0x05000000; +enum STT_ARM_TFUNC = STT_LOPROC; +enum STT_ARM_16BIT = STT_HIPROC; +enum SHF_ARM_ENTRYSECT = 0x10000000; +enum SHF_ARM_COMDEF = 0x80000000; +enum PF_ARM_SB = 0x10000000; +enum PF_ARM_PI = 0x20000000; +enum PF_ARM_ABS = 0x40000000; +enum PT_ARM_EXIDX = (PT_LOPROC + 1); +enum SHT_ARM_EXIDX = (SHT_LOPROC + 1); +enum SHT_ARM_PREEMPTMAP = (SHT_LOPROC + 2); +enum SHT_ARM_ATTRIBUTES = (SHT_LOPROC + 3); + +enum R_AARCH64_NONE = 0; +enum R_AARCH64_ABS64 = 257; +enum R_AARCH64_ABS32 = 258; +enum R_AARCH64_COPY = 1024; +enum R_AARCH64_GLOB_DAT = 1025; +enum R_AARCH64_JUMP_SLOT = 1026; +enum R_AARCH64_RELATIVE = 1027; +enum R_AARCH64_TLS_DTPMOD64 = 1028; +enum R_AARCH64_TLS_DTPREL64 = 1029; +enum R_AARCH64_TLS_TPREL64 = 1030; +enum R_AARCH64_TLSDESC = 1031; + +enum R_ARM_NONE = 0; +enum R_ARM_PC24 = 1; +enum R_ARM_ABS32 = 2; +enum R_ARM_REL32 = 3; +enum R_ARM_PC13 = 4; +enum R_ARM_ABS16 = 5; +enum R_ARM_ABS12 = 6; +enum R_ARM_THM_ABS5 = 7; +enum R_ARM_ABS8 = 8; +enum R_ARM_SBREL32 = 9; +enum R_ARM_THM_PC22 = 10; +enum R_ARM_THM_PC8 = 11; +enum R_ARM_AMP_VCALL9 = 12; +enum R_ARM_SWI24 = 13; +enum R_ARM_TLS_DESC = 13; +enum R_ARM_THM_SWI8 = 14; +enum R_ARM_XPC25 = 15; +enum R_ARM_THM_XPC22 = 16; +enum R_ARM_TLS_DTPMOD32 = 17; +enum R_ARM_TLS_DTPOFF32 = 18; +enum R_ARM_TLS_TPOFF32 = 19; +enum R_ARM_COPY = 20; +enum R_ARM_GLOB_DAT = 21; +enum R_ARM_JUMP_SLOT = 22; +enum R_ARM_RELATIVE = 23; +enum R_ARM_GOTOFF = 24; +enum R_ARM_GOTPC = 25; +enum R_ARM_GOT32 = 26; +enum R_ARM_PLT32 = 27; +enum R_ARM_ALU_PCREL_7_0 = 32; +enum R_ARM_ALU_PCREL_15_8 = 33; +enum R_ARM_ALU_PCREL_23_15 = 34; +enum R_ARM_LDR_SBREL_11_0 = 35; +enum R_ARM_ALU_SBREL_19_12 = 36; +enum R_ARM_ALU_SBREL_27_20 = 37; +enum R_ARM_TLS_GOTDESC = 90; +enum R_ARM_TLS_CALL = 91; +enum R_ARM_TLS_DESCSEQ = 92; +enum R_ARM_THM_TLS_CALL = 93; +enum R_ARM_GNU_VTENTRY = 100; +enum R_ARM_GNU_VTINHERIT = 101; +enum R_ARM_THM_PC11 = 102; +enum R_ARM_THM_PC9 = 103; +enum R_ARM_TLS_GD32 = 104; +enum R_ARM_TLS_LDM32 = 105; +enum R_ARM_TLS_LDO32 = 106; +enum R_ARM_TLS_IE32 = 107; +enum R_ARM_TLS_LE32 = 108; +enum R_ARM_THM_TLS_DESCSEQ = 129; +enum R_ARM_IRELATIVE = 160; +enum R_ARM_RXPC25 = 249; +enum R_ARM_RSBREL32 = 250; +enum R_ARM_THM_RPC22 = 251; +enum R_ARM_RREL32 = 252; +enum R_ARM_RABS22 = 253; +enum R_ARM_RPC24 = 254; +enum R_ARM_RBASE = 255; +enum R_ARM_NUM = 256; +enum EF_IA_64_MASKOS = 0x0000000f; +enum EF_IA_64_ABI64 = 0x00000010; +enum EF_IA_64_ARCH = 0xff000000; +enum PT_IA_64_ARCHEXT = (PT_LOPROC + 0); +enum PT_IA_64_UNWIND = (PT_LOPROC + 1); +enum PT_IA_64_HP_OPT_ANOT = (PT_LOOS + 0x12); +enum PT_IA_64_HP_HSL_ANOT = (PT_LOOS + 0x13); +enum PT_IA_64_HP_STACK = (PT_LOOS + 0x14); +enum PF_IA_64_NORECOV = 0x80000000; +enum SHT_IA_64_EXT = (SHT_LOPROC + 0); +enum SHT_IA_64_UNWIND = (SHT_LOPROC + 1); +enum SHF_IA_64_SHORT = 0x10000000; +enum SHF_IA_64_NORECOV = 0x20000000; +enum DT_IA_64_PLT_RESERVE = (DT_LOPROC + 0); +enum DT_IA_64_NUM = 1; +enum R_IA64_NONE = 0x00; +enum R_IA64_IMM14 = 0x21; +enum R_IA64_IMM22 = 0x22; +enum R_IA64_IMM64 = 0x23; +enum R_IA64_DIR32MSB = 0x24; +enum R_IA64_DIR32LSB = 0x25; +enum R_IA64_DIR64MSB = 0x26; +enum R_IA64_DIR64LSB = 0x27; +enum R_IA64_GPREL22 = 0x2a; +enum R_IA64_GPREL64I = 0x2b; +enum R_IA64_GPREL32MSB = 0x2c; +enum R_IA64_GPREL32LSB = 0x2d; +enum R_IA64_GPREL64MSB = 0x2e; +enum R_IA64_GPREL64LSB = 0x2f; +enum R_IA64_LTOFF22 = 0x32; +enum R_IA64_LTOFF64I = 0x33; +enum R_IA64_PLTOFF22 = 0x3a; +enum R_IA64_PLTOFF64I = 0x3b; +enum R_IA64_PLTOFF64MSB = 0x3e; +enum R_IA64_PLTOFF64LSB = 0x3f; +enum R_IA64_FPTR64I = 0x43; +enum R_IA64_FPTR32MSB = 0x44; +enum R_IA64_FPTR32LSB = 0x45; +enum R_IA64_FPTR64MSB = 0x46; +enum R_IA64_FPTR64LSB = 0x47; +enum R_IA64_PCREL60B = 0x48; +enum R_IA64_PCREL21B = 0x49; +enum R_IA64_PCREL21M = 0x4a; +enum R_IA64_PCREL21F = 0x4b; +enum R_IA64_PCREL32MSB = 0x4c; +enum R_IA64_PCREL32LSB = 0x4d; +enum R_IA64_PCREL64MSB = 0x4e; +enum R_IA64_PCREL64LSB = 0x4f; +enum R_IA64_LTOFF_FPTR22 = 0x52; +enum R_IA64_LTOFF_FPTR64I = 0x53; +enum R_IA64_LTOFF_FPTR32MSB = 0x54; +enum R_IA64_LTOFF_FPTR32LSB = 0x55; +enum R_IA64_LTOFF_FPTR64MSB = 0x56; +enum R_IA64_LTOFF_FPTR64LSB = 0x57; +enum R_IA64_SEGREL32MSB = 0x5c; +enum R_IA64_SEGREL32LSB = 0x5d; +enum R_IA64_SEGREL64MSB = 0x5e; +enum R_IA64_SEGREL64LSB = 0x5f; +enum R_IA64_SECREL32MSB = 0x64; +enum R_IA64_SECREL32LSB = 0x65; +enum R_IA64_SECREL64MSB = 0x66; +enum R_IA64_SECREL64LSB = 0x67; +enum R_IA64_REL32MSB = 0x6c; +enum R_IA64_REL32LSB = 0x6d; +enum R_IA64_REL64MSB = 0x6e; +enum R_IA64_REL64LSB = 0x6f; +enum R_IA64_LTV32MSB = 0x74; +enum R_IA64_LTV32LSB = 0x75; +enum R_IA64_LTV64MSB = 0x76; +enum R_IA64_LTV64LSB = 0x77; +enum R_IA64_PCREL21BI = 0x79; +enum R_IA64_PCREL22 = 0x7a; +enum R_IA64_PCREL64I = 0x7b; +enum R_IA64_IPLTMSB = 0x80; +enum R_IA64_IPLTLSB = 0x81; +enum R_IA64_COPY = 0x84; +enum R_IA64_SUB = 0x85; +enum R_IA64_LTOFF22X = 0x86; +enum R_IA64_LDXMOV = 0x87; +enum R_IA64_TPREL14 = 0x91; +enum R_IA64_TPREL22 = 0x92; +enum R_IA64_TPREL64I = 0x93; +enum R_IA64_TPREL64MSB = 0x96; +enum R_IA64_TPREL64LSB = 0x97; +enum R_IA64_LTOFF_TPREL22 = 0x9a; +enum R_IA64_DTPMOD64MSB = 0xa6; +enum R_IA64_DTPMOD64LSB = 0xa7; +enum R_IA64_LTOFF_DTPMOD22 = 0xaa; +enum R_IA64_DTPREL14 = 0xb1; +enum R_IA64_DTPREL22 = 0xb2; +enum R_IA64_DTPREL64I = 0xb3; +enum R_IA64_DTPREL32MSB = 0xb4; +enum R_IA64_DTPREL32LSB = 0xb5; +enum R_IA64_DTPREL64MSB = 0xb6; +enum R_IA64_DTPREL64LSB = 0xb7; +enum R_IA64_LTOFF_DTPREL22 = 0xba; +enum EF_SH_MACH_MASK = 0x1f; +enum EF_SH_UNKNOWN = 0x0; +enum EF_SH1 = 0x1; +enum EF_SH2 = 0x2; +enum EF_SH3 = 0x3; +enum EF_SH_DSP = 0x4; +enum EF_SH3_DSP = 0x5; +enum EF_SH4AL_DSP = 0x6; +enum EF_SH3E = 0x8; +enum EF_SH4 = 0x9; +enum EF_SH2E = 0xb; +enum EF_SH4A = 0xc; +enum EF_SH2A = 0xd; +enum EF_SH4_NOFPU = 0x10; +enum EF_SH4A_NOFPU = 0x11; +enum EF_SH4_NOMMU_NOFPU = 0x12; +enum EF_SH2A_NOFPU = 0x13; +enum EF_SH3_NOMMU = 0x14; +enum EF_SH2A_SH4_NOFPU = 0x15; +enum EF_SH2A_SH3_NOFPU = 0x16; +enum EF_SH2A_SH4 = 0x17; +enum EF_SH2A_SH3E = 0x18; +enum R_SH_NONE = 0; +enum R_SH_DIR32 = 1; +enum R_SH_REL32 = 2; +enum R_SH_DIR8WPN = 3; +enum R_SH_IND12W = 4; +enum R_SH_DIR8WPL = 5; +enum R_SH_DIR8WPZ = 6; +enum R_SH_DIR8BP = 7; +enum R_SH_DIR8W = 8; +enum R_SH_DIR8L = 9; +enum R_SH_SWITCH16 = 25; +enum R_SH_SWITCH32 = 26; +enum R_SH_USES = 27; +enum R_SH_COUNT = 28; +enum R_SH_ALIGN = 29; +enum R_SH_CODE = 30; +enum R_SH_DATA = 31; +enum R_SH_LABEL = 32; +enum R_SH_SWITCH8 = 33; +enum R_SH_GNU_VTINHERIT = 34; +enum R_SH_GNU_VTENTRY = 35; +enum R_SH_TLS_GD_32 = 144; +enum R_SH_TLS_LD_32 = 145; +enum R_SH_TLS_LDO_32 = 146; +enum R_SH_TLS_IE_32 = 147; +enum R_SH_TLS_LE_32 = 148; +enum R_SH_TLS_DTPMOD32 = 149; +enum R_SH_TLS_DTPOFF32 = 150; +enum R_SH_TLS_TPOFF32 = 151; +enum R_SH_GOT32 = 160; +enum R_SH_PLT32 = 161; +enum R_SH_COPY = 162; +enum R_SH_GLOB_DAT = 163; +enum R_SH_JMP_SLOT = 164; +enum R_SH_RELATIVE = 165; +enum R_SH_GOTOFF = 166; +enum R_SH_GOTPC = 167; +enum R_SH_NUM = 256; + +enum EF_S390_HIGH_GPRS = 0x00000001; + +enum R_390_NONE = 0; +enum R_390_8 = 1; +enum R_390_12 = 2; +enum R_390_16 = 3; +enum R_390_32 = 4; +enum R_390_PC32 = 5; +enum R_390_GOT12 = 6; +enum R_390_GOT32 = 7; +enum R_390_PLT32 = 8; +enum R_390_COPY = 9; +enum R_390_GLOB_DAT = 10; +enum R_390_JMP_SLOT = 11; +enum R_390_RELATIVE = 12; +enum R_390_GOTOFF32 = 13; +enum R_390_GOTPC = 14; +enum R_390_GOT16 = 15; +enum R_390_PC16 = 16; +enum R_390_PC16DBL = 17; +enum R_390_PLT16DBL = 18; +enum R_390_PC32DBL = 19; +enum R_390_PLT32DBL = 20; +enum R_390_GOTPCDBL = 21; +enum R_390_64 = 22; +enum R_390_PC64 = 23; +enum R_390_GOT64 = 24; +enum R_390_PLT64 = 25; +enum R_390_GOTENT = 26; +enum R_390_GOTOFF16 = 27; +enum R_390_GOTOFF64 = 28; +enum R_390_GOTPLT12 = 29; +enum R_390_GOTPLT16 = 30; +enum R_390_GOTPLT32 = 31; +enum R_390_GOTPLT64 = 32; +enum R_390_GOTPLTENT = 33; +enum R_390_PLTOFF16 = 34; +enum R_390_PLTOFF32 = 35; +enum R_390_PLTOFF64 = 36; +enum R_390_TLS_LOAD = 37; +enum R_390_TLS_GDCALL = 38; +enum R_390_TLS_LDCALL = 39; +enum R_390_TLS_GD32 = 40; +enum R_390_TLS_GD64 = 41; +enum R_390_TLS_GOTIE12 = 42; +enum R_390_TLS_GOTIE32 = 43; +enum R_390_TLS_GOTIE64 = 44; +enum R_390_TLS_LDM32 = 45; +enum R_390_TLS_LDM64 = 46; +enum R_390_TLS_IE32 = 47; +enum R_390_TLS_IE64 = 48; +enum R_390_TLS_IEENT = 49; +enum R_390_TLS_LE32 = 50; +enum R_390_TLS_LE64 = 51; +enum R_390_TLS_LDO32 = 52; +enum R_390_TLS_LDO64 = 53; +enum R_390_TLS_DTPMOD = 54; +enum R_390_TLS_DTPOFF = 55; +enum R_390_TLS_TPOFF = 56; +enum R_390_20 = 57; +enum R_390_GOT20 = 58; +enum R_390_GOTPLT20 = 59; +enum R_390_TLS_GOTIE20 = 60; +enum R_390_IRELATIVE = 61; +enum R_390_NUM = 62; +enum R_CRIS_NONE = 0; +enum R_CRIS_8 = 1; +enum R_CRIS_16 = 2; +enum R_CRIS_32 = 3; +enum R_CRIS_8_PCREL = 4; +enum R_CRIS_16_PCREL = 5; +enum R_CRIS_32_PCREL = 6; +enum R_CRIS_GNU_VTINHERIT = 7; +enum R_CRIS_GNU_VTENTRY = 8; +enum R_CRIS_COPY = 9; +enum R_CRIS_GLOB_DAT = 10; +enum R_CRIS_JUMP_SLOT = 11; +enum R_CRIS_RELATIVE = 12; +enum R_CRIS_16_GOT = 13; +enum R_CRIS_32_GOT = 14; +enum R_CRIS_16_GOTPLT = 15; +enum R_CRIS_32_GOTPLT = 16; +enum R_CRIS_32_GOTREL = 17; +enum R_CRIS_32_PLT_GOTREL = 18; +enum R_CRIS_32_PLT_PCREL = 19; + +enum R_CRIS_NUM = 20; +enum R_X86_64_NONE = 0; +enum R_X86_64_64 = 1; +enum R_X86_64_PC32 = 2; +enum R_X86_64_GOT32 = 3; +enum R_X86_64_PLT32 = 4; +enum R_X86_64_COPY = 5; +enum R_X86_64_GLOB_DAT = 6; +enum R_X86_64_JUMP_SLOT = 7; +enum R_X86_64_RELATIVE = 8; +enum R_X86_64_GOTPCREL = 9; +enum R_X86_64_32 = 10; +enum R_X86_64_32S = 11; +enum R_X86_64_16 = 12; +enum R_X86_64_PC16 = 13; +enum R_X86_64_8 = 14; +enum R_X86_64_PC8 = 15; +enum R_X86_64_DTPMOD64 = 16; +enum R_X86_64_DTPOFF64 = 17; +enum R_X86_64_TPOFF64 = 18; +enum R_X86_64_TLSGD = 19; +enum R_X86_64_TLSLD = 20; +enum R_X86_64_DTPOFF32 = 21; +enum R_X86_64_GOTTPOFF = 22; +enum R_X86_64_TPOFF32 = 23; +enum R_X86_64_PC64 = 24; +enum R_X86_64_GOTOFF64 = 25; +enum R_X86_64_GOTPC32 = 26; +enum R_X86_64_GOT64 = 27; +enum R_X86_64_GOTPCREL64 = 28; +enum R_X86_64_GOTPC64 = 29; +enum R_X86_64_GOTPLT64 = 30; +enum R_X86_64_PLTOFF64 = 31; +enum R_X86_64_SIZE32 = 32; +enum R_X86_64_SIZE64 = 33; +enum R_X86_64_GOTPC32_TLSDESC = 34; +enum R_X86_64_TLSDESC_CALL = 35; +enum R_X86_64_TLSDESC = 36; +enum R_X86_64_IRELATIVE = 37; +enum R_X86_64_RELATIVE64 = 38; + +enum R_X86_64_NUM = 39; +enum R_MN10300_NONE = 0; +enum R_MN10300_32 = 1; +enum R_MN10300_16 = 2; +enum R_MN10300_8 = 3; +enum R_MN10300_PCREL32 = 4; +enum R_MN10300_PCREL16 = 5; +enum R_MN10300_PCREL8 = 6; +enum R_MN10300_GNU_VTINHERIT = 7; +enum R_MN10300_GNU_VTENTRY = 8; +enum R_MN10300_24 = 9; +enum R_MN10300_GOTPC32 = 10; +enum R_MN10300_GOTPC16 = 11; +enum R_MN10300_GOTOFF32 = 12; +enum R_MN10300_GOTOFF24 = 13; +enum R_MN10300_GOTOFF16 = 14; +enum R_MN10300_PLT32 = 15; +enum R_MN10300_PLT16 = 16; +enum R_MN10300_GOT32 = 17; +enum R_MN10300_GOT24 = 18; +enum R_MN10300_GOT16 = 19; +enum R_MN10300_COPY = 20; +enum R_MN10300_GLOB_DAT = 21; +enum R_MN10300_JMP_SLOT = 22; +enum R_MN10300_RELATIVE = 23; +enum R_MN10300_TLS_GD = 24; +enum R_MN10300_TLS_LD = 25; +enum R_MN10300_TLS_LDO = 26; +enum R_MN10300_TLS_GOTIE = 27; +enum R_MN10300_TLS_IE = 28; +enum R_MN10300_TLS_LE = 29; +enum R_MN10300_TLS_DTPMOD = 30; +enum R_MN10300_TLS_DTPOFF = 31; +enum R_MN10300_TLS_TPOFF = 32; +enum R_MN10300_SYM_DIFF = 33; +enum R_MN10300_ALIGN = 34; +enum R_MN10300_NUM = 35; +enum R_M32R_NONE = 0; +enum R_M32R_16 = 1; +enum R_M32R_32 = 2; +enum R_M32R_24 = 3; +enum R_M32R_10_PCREL = 4; +enum R_M32R_18_PCREL = 5; +enum R_M32R_26_PCREL = 6; +enum R_M32R_HI16_ULO = 7; +enum R_M32R_HI16_SLO = 8; +enum R_M32R_LO16 = 9; +enum R_M32R_SDA16 = 10; +enum R_M32R_GNU_VTINHERIT = 11; +enum R_M32R_GNU_VTENTRY = 12; +enum R_M32R_16_RELA = 33; +enum R_M32R_32_RELA = 34; +enum R_M32R_24_RELA = 35; +enum R_M32R_10_PCREL_RELA = 36; +enum R_M32R_18_PCREL_RELA = 37; +enum R_M32R_26_PCREL_RELA = 38; +enum R_M32R_HI16_ULO_RELA = 39; +enum R_M32R_HI16_SLO_RELA = 40; +enum R_M32R_LO16_RELA = 41; +enum R_M32R_SDA16_RELA = 42; +enum R_M32R_RELA_GNU_VTINHERIT = 43; +enum R_M32R_RELA_GNU_VTENTRY = 44; +enum R_M32R_REL32 = 45; + +enum R_M32R_GOT24 = 48; +enum R_M32R_26_PLTREL = 49; +enum R_M32R_COPY = 50; +enum R_M32R_GLOB_DAT = 51; +enum R_M32R_JMP_SLOT = 52; +enum R_M32R_RELATIVE = 53; +enum R_M32R_GOTOFF = 54; +enum R_M32R_GOTPC24 = 55; +enum R_M32R_GOT16_HI_ULO = 56; +enum R_M32R_GOT16_HI_SLO = 57; +enum R_M32R_GOT16_LO = 58; +enum R_M32R_GOTPC_HI_ULO = 59; +enum R_M32R_GOTPC_HI_SLO = 60; +enum R_M32R_GOTPC_LO = 61; +enum R_M32R_GOTOFF_HI_ULO = 62; +enum R_M32R_GOTOFF_HI_SLO = 63; +enum R_M32R_GOTOFF_LO = 64; +enum R_M32R_NUM = 256; +enum R_TILEPRO_NONE = 0; +enum R_TILEPRO_32 = 1; +enum R_TILEPRO_16 = 2; +enum R_TILEPRO_8 = 3; +enum R_TILEPRO_32_PCREL = 4; +enum R_TILEPRO_16_PCREL = 5; +enum R_TILEPRO_8_PCREL = 6; +enum R_TILEPRO_LO16 = 7; +enum R_TILEPRO_HI16 = 8; +enum R_TILEPRO_HA16 = 9; +enum R_TILEPRO_COPY = 10; +enum R_TILEPRO_GLOB_DAT = 11; +enum R_TILEPRO_JMP_SLOT = 12; +enum R_TILEPRO_RELATIVE = 13; +enum R_TILEPRO_BROFF_X1 = 14; +enum R_TILEPRO_JOFFLONG_X1 = 15; +enum R_TILEPRO_JOFFLONG_X1_PLT = 16; +enum R_TILEPRO_IMM8_X0 = 17; +enum R_TILEPRO_IMM8_Y0 = 18; +enum R_TILEPRO_IMM8_X1 = 19; +enum R_TILEPRO_IMM8_Y1 = 20; +enum R_TILEPRO_MT_IMM15_X1 = 21; +enum R_TILEPRO_MF_IMM15_X1 = 22; +enum R_TILEPRO_IMM16_X0 = 23; +enum R_TILEPRO_IMM16_X1 = 24; +enum R_TILEPRO_IMM16_X0_LO = 25; +enum R_TILEPRO_IMM16_X1_LO = 26; +enum R_TILEPRO_IMM16_X0_HI = 27; +enum R_TILEPRO_IMM16_X1_HI = 28; +enum R_TILEPRO_IMM16_X0_HA = 29; +enum R_TILEPRO_IMM16_X1_HA = 30; +enum R_TILEPRO_IMM16_X0_PCREL = 31; +enum R_TILEPRO_IMM16_X1_PCREL = 32; +enum R_TILEPRO_IMM16_X0_LO_PCREL = 33; +enum R_TILEPRO_IMM16_X1_LO_PCREL = 34; +enum R_TILEPRO_IMM16_X0_HI_PCREL = 35; +enum R_TILEPRO_IMM16_X1_HI_PCREL = 36; +enum R_TILEPRO_IMM16_X0_HA_PCREL = 37; +enum R_TILEPRO_IMM16_X1_HA_PCREL = 38; +enum R_TILEPRO_IMM16_X0_GOT = 39; +enum R_TILEPRO_IMM16_X1_GOT = 40; +enum R_TILEPRO_IMM16_X0_GOT_LO = 41; +enum R_TILEPRO_IMM16_X1_GOT_LO = 42; +enum R_TILEPRO_IMM16_X0_GOT_HI = 43; +enum R_TILEPRO_IMM16_X1_GOT_HI = 44; +enum R_TILEPRO_IMM16_X0_GOT_HA = 45; +enum R_TILEPRO_IMM16_X1_GOT_HA = 46; +enum R_TILEPRO_MMSTART_X0 = 47; +enum R_TILEPRO_MMEND_X0 = 48; +enum R_TILEPRO_MMSTART_X1 = 49; +enum R_TILEPRO_MMEND_X1 = 50; +enum R_TILEPRO_SHAMT_X0 = 51; +enum R_TILEPRO_SHAMT_X1 = 52; +enum R_TILEPRO_SHAMT_Y0 = 53; +enum R_TILEPRO_SHAMT_Y1 = 54; +enum R_TILEPRO_DEST_IMM8_X1 = 55; +enum R_TILEPRO_TLS_GD_CALL = 60; +enum R_TILEPRO_IMM8_X0_TLS_GD_ADD = 61; +enum R_TILEPRO_IMM8_X1_TLS_GD_ADD = 62; +enum R_TILEPRO_IMM8_Y0_TLS_GD_ADD = 63; +enum R_TILEPRO_IMM8_Y1_TLS_GD_ADD = 64; +enum R_TILEPRO_TLS_IE_LOAD = 65; +enum R_TILEPRO_IMM16_X0_TLS_GD = 66; +enum R_TILEPRO_IMM16_X1_TLS_GD = 67; +enum R_TILEPRO_IMM16_X0_TLS_GD_LO = 68; +enum R_TILEPRO_IMM16_X1_TLS_GD_LO = 69; +enum R_TILEPRO_IMM16_X0_TLS_GD_HI = 70; +enum R_TILEPRO_IMM16_X1_TLS_GD_HI = 71; +enum R_TILEPRO_IMM16_X0_TLS_GD_HA = 72; +enum R_TILEPRO_IMM16_X1_TLS_GD_HA = 73; +enum R_TILEPRO_IMM16_X0_TLS_IE = 74; +enum R_TILEPRO_IMM16_X1_TLS_IE = 75; +enum R_TILEPRO_IMM16_X0_TLS_IE_LO = 76; +enum R_TILEPRO_IMM16_X1_TLS_IE_LO = 77; +enum R_TILEPRO_IMM16_X0_TLS_IE_HI = 78; +enum R_TILEPRO_IMM16_X1_TLS_IE_HI = 79; +enum R_TILEPRO_IMM16_X0_TLS_IE_HA = 80; +enum R_TILEPRO_IMM16_X1_TLS_IE_HA = 81; +enum R_TILEPRO_TLS_DTPMOD32 = 82; +enum R_TILEPRO_TLS_DTPOFF32 = 83; +enum R_TILEPRO_TLS_TPOFF32 = 84; +enum R_TILEPRO_IMM16_X0_TLS_LE = 85; +enum R_TILEPRO_IMM16_X1_TLS_LE = 86; +enum R_TILEPRO_IMM16_X0_TLS_LE_LO = 87; +enum R_TILEPRO_IMM16_X1_TLS_LE_LO = 88; +enum R_TILEPRO_IMM16_X0_TLS_LE_HI = 89; +enum R_TILEPRO_IMM16_X1_TLS_LE_HI = 90; +enum R_TILEPRO_IMM16_X0_TLS_LE_HA = 91; +enum R_TILEPRO_IMM16_X1_TLS_LE_HA = 92; + +enum R_TILEPRO_GNU_VTINHERIT = 128; +enum R_TILEPRO_GNU_VTENTRY = 129; + +enum R_TILEPRO_NUM = 130; +enum R_TILEGX_NONE = 0; +enum R_TILEGX_64 = 1; +enum R_TILEGX_32 = 2; +enum R_TILEGX_16 = 3; +enum R_TILEGX_8 = 4; +enum R_TILEGX_64_PCREL = 5; +enum R_TILEGX_32_PCREL = 6; +enum R_TILEGX_16_PCREL = 7; +enum R_TILEGX_8_PCREL = 8; +enum R_TILEGX_HW0 = 9; +enum R_TILEGX_HW1 = 10; +enum R_TILEGX_HW2 = 11; +enum R_TILEGX_HW3 = 12; +enum R_TILEGX_HW0_LAST = 13; +enum R_TILEGX_HW1_LAST = 14; +enum R_TILEGX_HW2_LAST = 15; +enum R_TILEGX_COPY = 16; +enum R_TILEGX_GLOB_DAT = 17; +enum R_TILEGX_JMP_SLOT = 18; +enum R_TILEGX_RELATIVE = 19; +enum R_TILEGX_BROFF_X1 = 20; +enum R_TILEGX_JUMPOFF_X1 = 21; +enum R_TILEGX_JUMPOFF_X1_PLT = 22; +enum R_TILEGX_IMM8_X0 = 23; +enum R_TILEGX_IMM8_Y0 = 24; +enum R_TILEGX_IMM8_X1 = 25; +enum R_TILEGX_IMM8_Y1 = 26; +enum R_TILEGX_DEST_IMM8_X1 = 27; +enum R_TILEGX_MT_IMM14_X1 = 28; +enum R_TILEGX_MF_IMM14_X1 = 29; +enum R_TILEGX_MMSTART_X0 = 30; +enum R_TILEGX_MMEND_X0 = 31; +enum R_TILEGX_SHAMT_X0 = 32; +enum R_TILEGX_SHAMT_X1 = 33; +enum R_TILEGX_SHAMT_Y0 = 34; +enum R_TILEGX_SHAMT_Y1 = 35; +enum R_TILEGX_IMM16_X0_HW0 = 36; +enum R_TILEGX_IMM16_X1_HW0 = 37; +enum R_TILEGX_IMM16_X0_HW1 = 38; +enum R_TILEGX_IMM16_X1_HW1 = 39; +enum R_TILEGX_IMM16_X0_HW2 = 40; +enum R_TILEGX_IMM16_X1_HW2 = 41; +enum R_TILEGX_IMM16_X0_HW3 = 42; +enum R_TILEGX_IMM16_X1_HW3 = 43; +enum R_TILEGX_IMM16_X0_HW0_LAST = 44; +enum R_TILEGX_IMM16_X1_HW0_LAST = 45; +enum R_TILEGX_IMM16_X0_HW1_LAST = 46; +enum R_TILEGX_IMM16_X1_HW1_LAST = 47; +enum R_TILEGX_IMM16_X0_HW2_LAST = 48; +enum R_TILEGX_IMM16_X1_HW2_LAST = 49; +enum R_TILEGX_IMM16_X0_HW0_PCREL = 50; +enum R_TILEGX_IMM16_X1_HW0_PCREL = 51; +enum R_TILEGX_IMM16_X0_HW1_PCREL = 52; +enum R_TILEGX_IMM16_X1_HW1_PCREL = 53; +enum R_TILEGX_IMM16_X0_HW2_PCREL = 54; +enum R_TILEGX_IMM16_X1_HW2_PCREL = 55; +enum R_TILEGX_IMM16_X0_HW3_PCREL = 56; +enum R_TILEGX_IMM16_X1_HW3_PCREL = 57; +enum R_TILEGX_IMM16_X0_HW0_LAST_PCREL = 58; +enum R_TILEGX_IMM16_X1_HW0_LAST_PCREL = 59; +enum R_TILEGX_IMM16_X0_HW1_LAST_PCREL = 60; +enum R_TILEGX_IMM16_X1_HW1_LAST_PCREL = 61; +enum R_TILEGX_IMM16_X0_HW2_LAST_PCREL = 62; +enum R_TILEGX_IMM16_X1_HW2_LAST_PCREL = 63; +enum R_TILEGX_IMM16_X0_HW0_GOT = 64; +enum R_TILEGX_IMM16_X1_HW0_GOT = 65; +enum R_TILEGX_IMM16_X0_HW0_PLT_PCREL = 66; +enum R_TILEGX_IMM16_X1_HW0_PLT_PCREL = 67; +enum R_TILEGX_IMM16_X0_HW1_PLT_PCREL = 68; +enum R_TILEGX_IMM16_X1_HW1_PLT_PCREL = 69; +enum R_TILEGX_IMM16_X0_HW2_PLT_PCREL = 70; +enum R_TILEGX_IMM16_X1_HW2_PLT_PCREL = 71; +enum R_TILEGX_IMM16_X0_HW0_LAST_GOT = 72; +enum R_TILEGX_IMM16_X1_HW0_LAST_GOT = 73; +enum R_TILEGX_IMM16_X0_HW1_LAST_GOT = 74; +enum R_TILEGX_IMM16_X1_HW1_LAST_GOT = 75; +enum R_TILEGX_IMM16_X0_HW3_PLT_PCREL = 76; +enum R_TILEGX_IMM16_X1_HW3_PLT_PCREL = 77; +enum R_TILEGX_IMM16_X0_HW0_TLS_GD = 78; +enum R_TILEGX_IMM16_X1_HW0_TLS_GD = 79; +enum R_TILEGX_IMM16_X0_HW0_TLS_LE = 80; +enum R_TILEGX_IMM16_X1_HW0_TLS_LE = 81; +enum R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE = 82; +enum R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE = 83; +enum R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE = 84; +enum R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE = 85; +enum R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD = 86; +enum R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD = 87; +enum R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD = 88; +enum R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD = 89; +enum R_TILEGX_IMM16_X0_HW0_TLS_IE = 92; +enum R_TILEGX_IMM16_X1_HW0_TLS_IE = 93; +enum R_TILEGX_IMM16_X0_HW0_LAST_PLT_PCREL = 94; +enum R_TILEGX_IMM16_X1_HW0_LAST_PLT_PCREL = 95; +enum R_TILEGX_IMM16_X0_HW1_LAST_PLT_PCREL = 96; +enum R_TILEGX_IMM16_X1_HW1_LAST_PLT_PCREL = 97; +enum R_TILEGX_IMM16_X0_HW2_LAST_PLT_PCREL = 98; +enum R_TILEGX_IMM16_X1_HW2_LAST_PLT_PCREL = 99; +enum R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE = 100; +enum R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE = 101; +enum R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE = 102; +enum R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE = 103; +enum R_TILEGX_TLS_DTPMOD64 = 106; +enum R_TILEGX_TLS_DTPOFF64 = 107; +enum R_TILEGX_TLS_TPOFF64 = 108; +enum R_TILEGX_TLS_DTPMOD32 = 109; +enum R_TILEGX_TLS_DTPOFF32 = 110; +enum R_TILEGX_TLS_TPOFF32 = 111; +enum R_TILEGX_TLS_GD_CALL = 112; +enum R_TILEGX_IMM8_X0_TLS_GD_ADD = 113; +enum R_TILEGX_IMM8_X1_TLS_GD_ADD = 114; +enum R_TILEGX_IMM8_Y0_TLS_GD_ADD = 115; +enum R_TILEGX_IMM8_Y1_TLS_GD_ADD = 116; +enum R_TILEGX_TLS_IE_LOAD = 117; +enum R_TILEGX_IMM8_X0_TLS_ADD = 118; +enum R_TILEGX_IMM8_X1_TLS_ADD = 119; +enum R_TILEGX_IMM8_Y0_TLS_ADD = 120; +enum R_TILEGX_IMM8_Y1_TLS_ADD = 121; + +enum R_TILEGX_GNU_VTINHERIT = 128; +enum R_TILEGX_GNU_VTENTRY = 129; + +enum R_TILEGX_NUM = 130; diff --git a/lib/std_edit/link.d b/lib/std_edit/link.d new file mode 100644 index 0000000..bea8dc6 --- /dev/null +++ b/lib/std_edit/link.d @@ -0,0 +1,185 @@ +/** + * D header file for GNU/Linux + * + * $(LINK2 http://sourceware.org/git/?p=glibc.git;a=blob;f=elf/link.h, glibc elf/link.h) + */ +module std_edit.link; + +extern (C): +nothrow: +@system: + +version (ARM) version = ARM_Any; +version (AArch64) version = ARM_Any; +version (HPPA) version = HPPA_Any; +version (MIPS32) version = MIPS_Any; +version (MIPS64) version = MIPS_Any; +version (PPC) version = PPC_Any; +version (PPC64) version = PPC_Any; +version (RISCV32) version = RISCV_Any; +version (RISCV64) version = RISCV_Any; +version (S390) version = IBMZ_Any; +version (SPARC) version = SPARC_Any; +version (SPARC64) version = SPARC_Any; +version (SystemZ) version = IBMZ_Any; +version (X86) version = X86_Any; +version (X86_64) version = X86_Any; + +import core.stdc.stdint : uintptr_t, uint32_t, uint64_t; +import std_edit.elf; + +version (D_LP64) + enum __WORDSIZE = 64; +else + enum __WORDSIZE = 32; + +// +version (Android) +{ + alias __WORDSIZE __ELF_NATIVE_CLASS; + version (D_LP64) + alias uint64_t Elf_Symndx; + else + alias uint32_t Elf_Symndx; +} +else version (X86_Any) +{ + // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/elfclass.h + alias __WORDSIZE __ELF_NATIVE_CLASS; + alias uint32_t Elf_Symndx; +} +else version (HPPA_Any) +{ + // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/elfclass.h + alias __WORDSIZE __ELF_NATIVE_CLASS; + alias uint32_t Elf_Symndx; +} +else version (MIPS_Any) +{ + // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/elfclass.h + alias __WORDSIZE __ELF_NATIVE_CLASS; + alias uint32_t Elf_Symndx; +} +else version (PPC_Any) +{ + // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/elfclass.h + alias __WORDSIZE __ELF_NATIVE_CLASS; + alias uint32_t Elf_Symndx; +} +else version (ARM_Any) +{ + // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/elfclass.h + alias __WORDSIZE __ELF_NATIVE_CLASS; + alias uint32_t Elf_Symndx; +} +else version (RISCV_Any) +{ + // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/elfclass.h + alias __WORDSIZE __ELF_NATIVE_CLASS; + alias uint32_t Elf_Symndx; +} +else version (SPARC_Any) +{ + // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/elfclass.h + alias __WORDSIZE __ELF_NATIVE_CLASS; + alias uint32_t Elf_Symndx; +} +else version (IBMZ_Any) +{ + // http://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/s390/bits/elfclass.h + alias __WORDSIZE __ELF_NATIVE_CLASS; + static if (__WORDSIZE == 64) + alias uint64_t Elf_Symndx; + else + alias uint32_t Elf_Symndx; +} +else + static assert(0, "unimplemented"); +// + +template ElfW(string type) +{ + mixin("alias Elf"~__ELF_NATIVE_CLASS.stringof~"_"~type~" ElfW;"); +} + +enum +{ + RT_CONSISTENT, + RT_ADD, + RT_DELETE, +} + +struct r_debug +{ + int r_version; + link_map* r_map; + ElfW!"Addr" r_brk; + typeof(RT_CONSISTENT) r_state; + ElfW!"Addr" r_ldbase; +} + +extern r_debug _r_debug; +extern ElfW!"Dyn"* _DYNAMIC; + +struct link_map +{ + ElfW!"Addr" l_addr; + char* l_name; + ElfW!"Dyn"* l_ld; + link_map* l_next, l_prev; +} + +enum +{ + LA_ACT_CONSISTENT, + LA_ACT_ADD, + LA_ACT_DELETE, +} + +enum +{ + LA_SER_ORIG = 0x01, + LA_SER_LIBPATH = 0x02, + LA_SER_RUNPATH = 0x04, + LA_SER_CONFIG = 0x08, + LA_SER_DEFAULT = 0x40, + LA_SER_SECURE = 0x80, +} + + +enum +{ + LA_FLG_BINDTO = 0x01, + LA_FLG_BINDFROM = 0x02, +} + + +enum +{ + LA_SYMB_NOPLTENTER = 0x01, + LA_SYMB_NOPLTEXIT = 0x02, + LA_SYMB_STRUCTCALL = 0x04, + LA_SYMB_DLSYM = 0x08, + LA_SYMB_ALTVALUE = 0x10, +} + +struct dl_phdr_info +{ + ElfW!"Addr" dlpi_addr; + const(char)* dlpi_name; + const(ElfW!"Phdr")* dlpi_phdr; + ElfW!"Half" dlpi_phnum; + + // check the SIZE argument of the dl_iterate_phdr callback whether + // the following members are available + ulong dlpi_adds; + ulong dlpi_subs; + + size_t dlpi_tls_modid; + void *dlpi_tls_data; +} + +private alias extern(C) int function(dl_phdr_info*, size_t, void *) dl_iterate_phdr_cb; +private alias extern(C) int function(dl_phdr_info*, size_t, void *) @nogc dl_iterate_phdr_cb_ngc; +extern int dl_iterate_phdr(dl_iterate_phdr_cb __callback, void*__data); +extern int dl_iterate_phdr(dl_iterate_phdr_cb_ngc __callback, void*__data) @nogc; diff --git a/mkcassette/app.d b/mkcassette/app.d index e5278ae..fe09151 100644 --- a/mkcassette/app.d +++ b/mkcassette/app.d @@ -13,6 +13,7 @@ import std.mmfile; import std.net.curl; import std.parallelism; import std.path; +import process = std.process; import std.range; import std.zip; @@ -53,11 +54,21 @@ int main(string[] args) { log.infoF!"%s v%s"(mkcassetteBranding, provisionVersion); char[] identifier = cast(char[]) "ba10defe42ea69ff"; - string configurationPath = expandTilde("~/.config/Provision"); string outputFile = "./otp-file.acs"; ulong days = 90; bool onlyInit = false; bool apkDownloadAllowed = true; + version (Windows) { + string configurationPath = process.environment["LocalAppData"].buildPath("Provision"); + } else { + string configurationPath; + string xdgConfigPath = process.environment.get("XDG_CONFIG_HOME"); + if (xdgConfigPath) { + configurationPath = xdgConfigPath.buildPath("Provision"); + } else { + configurationPath = expandTilde("~/.config/Provision/"); + } + } // Parse command-line arguments auto helpInformation = getopt( diff --git a/retrieve_headers/app.d b/retrieve_headers/app.d index 7996635..2a81ed8 100644 --- a/retrieve_headers/app.d +++ b/retrieve_headers/app.d @@ -3,9 +3,10 @@ module app; import std.array; import std.base64; import std.conv: to; +import file = std.file; import std.format; import std.path; -import file = std.file; +import process = std.process; import provision; import slf4d; @@ -24,13 +25,28 @@ version (X86_64) { } int main(string[] args) { - if (args.length == 2 && args[1] == "debug") { - import slf4d.default_provider; - auto provider = new shared DefaultProvider(true, Levels.DEBUG); - configureLoggingProvider(provider); + import slf4d.default_provider; + Levels logLevel; + debug { + logLevel = Levels.TRACE; + } else { + logLevel = args.length == 2 && args[1] == "debug" ? Levels.TRACE : Levels.INFO; + } + auto provider = new shared DefaultProvider(true, logLevel); + configureLoggingProvider(provider); + + version (Windows) { + string configurationPath = process.environment["LocalAppData"].buildPath("Provision"); + } else { + string configurationPath; + string xdgConfigPath = process.environment.get("XDG_CONFIG_HOME"); + if (xdgConfigPath) { + configurationPath = xdgConfigPath.buildPath("Provision"); + } else { + configurationPath = expandTilde("~/.config/Provision/"); + } } - string configurationPath = expandTilde("~/.config/Provision/"); if (!file.exists(configurationPath)) { file.mkdirRecurse(configurationPath); } From 1f9e2f3c7edc312590fba227874cf17363ad188d Mon Sep 17 00:00:00 2001 From: Dadoum Date: Fri, 9 Jun 2023 11:58:15 +0200 Subject: [PATCH 02/19] Port to dlang-requests --- .gitignore | 1 + CMakeLists.txt | 2 +- cmake/cmake-d | 2 +- cmake/dependencies.cmake | 1 + dub.sdl | 1 + dub.selections.json | 8 +++++- lib/provision/adi.d | 61 +++++++++++++++++++++++----------------- 7 files changed, 47 insertions(+), 29 deletions(-) diff --git a/.gitignore b/.gitignore index e4e9e26..89d3927 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ bin/ .dub/ +cmake-build-* \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index de09339..f68e83b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,7 +67,7 @@ else() endif() endif() -target_link_libraries(provision PUBLIC plist slf4d) +target_link_libraries(provision PUBLIC plist slf4d requests) set(RETRIEVE_HEADERS_SOURCE_DIR "retrieve_headers/") file(GLOB_RECURSE RETRIEVE_HEADERS_D_SOURCES "${RETRIEVE_HEADERS_SOURCE_DIR}*.d") diff --git a/cmake/cmake-d b/cmake/cmake-d index cb455cf..d786867 160000 --- a/cmake/cmake-d +++ b/cmake/cmake-d @@ -1 +1 @@ -Subproject commit cb455cf3d818d6e6c41c3614d29cdd9a0793c711 +Subproject commit d786867f671057d2185a9a6b139018a7db8aa1e3 diff --git a/cmake/dependencies.cmake b/cmake/dependencies.cmake index 9fb2f2c..d8034d3 100644 --- a/cmake/dependencies.cmake +++ b/cmake/dependencies.cmake @@ -3,6 +3,7 @@ include(UseDub) +DubProject_Add(requests ~2.0.9) DubProject_Add(slf4d ~2.1.1) if(build_anisetteserver) diff --git a/dub.sdl b/dub.sdl index 9a24fee..70f9f94 100644 --- a/dub.sdl +++ b/dub.sdl @@ -9,6 +9,7 @@ targetPath "bin" sourcePaths "lib" importPaths "lib" +dependency "requests" version="~>2.0.9" dependency "slf4d" version="~>2.1.1" configuration "plist-d" { diff --git a/dub.selections.json b/dub.selections.json index 271c2e1..fee4e3c 100644 --- a/dub.selections.json +++ b/dub.selections.json @@ -1,10 +1,16 @@ { "fileVersion": 1, "versions": { + "automem": "0.6.9", + "cachetools": "0.4.1", "dxml": "0.4.3", "handy-httpd": "5.2.1", "httparsed": "1.2.1", "plist": "~master", - "slf4d": "2.1.1" + "plist-d": {"version":"d494cf3fe79a2bb20583173c0c8cf85ef33b719e","repository":"git+https://github.com/Dadoum/libplist-d.git"}, + "requests": "2.0.9", + "slf4d": "2.1.1", + "test_allocator": "0.3.4", + "unit-threaded": "0.10.8" } } diff --git a/lib/provision/adi.d b/lib/provision/adi.d index c2352f5..4495232 100644 --- a/lib/provision/adi.d +++ b/lib/provision/adi.d @@ -7,10 +7,11 @@ import std.digest.sha; import file = std.file; import std.format; import std.json; -import std.net.curl; import std.path; import std.string; +import requests; + import slf4d; version (LibPlist) { @@ -325,7 +326,7 @@ public class Device { } public class ProvisioningSession { - private HTTP httpClient; + private Request request; private string[string] urlBag; private ADI adi; @@ -335,32 +336,34 @@ public class ProvisioningSession { this.adi = adi; this.device = device; - httpClient = HTTP(); + request = Request(); - httpClient.setUserAgent("akd/1.0 CFNetwork/1404.0.5 Darwin/22.3.0"); - httpClient.handle.set(CurlOption.ssl_verifypeer, 0); + request.sslSetVerifyPeer(false); + request.addHeaders([ + "User-Agent": "akd/1.0 CFNetwork/1404.0.5 Darwin/22.3.0", - // they are somehow not using the plist content-type in AuthKit - httpClient.addRequestHeader("Content-Type", "application/x-www-form-urlencoded"); - httpClient.addRequestHeader("Connection", "keep-alive"); + // they are somehow not using the plist content-type in AuthKit + "Content-Type": "application/x-www-form-urlencoded", + "Connection": "keep-alive", - httpClient.addRequestHeader("X-Mme-Device-Id", device.uniqueDeviceIdentifier); - // on macOS, MMe for the Client-Info header is written with 2 caps, while on Windows it is Mme... - // and HTTP headers are supposed to be case-insensitive in the HTTP spec... - httpClient.addRequestHeader("X-MMe-Client-Info", device.serverFriendlyDescription); - httpClient.addRequestHeader("X-Apple-I-MD-LU", device.localUserUUID); + "X-Mme-Device-Id": device.uniqueDeviceIdentifier, + // on macOS, MMe for the Client-Info header is written with 2 caps, while on Windows it is Mme... + // and HTTP headers are supposed to be case-insensitive in the HTTP spec... + "X-MMe-Client-Info": device.serverFriendlyDescription, + "X-Apple-I-MD-LU": device.localUserUUID, - // httpClient.addRequestHeader("X-Apple-I-MLB", device.logicBoardSerialNumber); // 17 letters, uppercase in Apple's base 34 - // httpClient.addRequestHeader("X-Apple-I-ROM", device.romAddress); // 6 bytes, lowercase hexadecimal - // httpClient.addRequestHeader("X-Apple-I-SRL-NO", device.machineSerialNumber); // 12 letters, uppercase + // "X-Apple-I-MLB": device.logicBoardSerialNumber, // 17 letters, uppercase in Apple's base 34 + // "X-Apple-I-ROM": device.romAddress, // 6 bytes, lowercase hexadecimal + // "X-Apple-I-SRL-NO": device.machineSerialNumber, // 12 letters, uppercase - // different apps can be used, I already saw fmfd and Setup here - // and Reprovision uses Xcode in some requests, so maybe it is possible here too. - httpClient.addRequestHeader("X-Apple-Client-App-Name", "Setup"); + // different apps can be used, I already saw fmfd and Setup here + // and Reprovision uses Xcode in some requests, so maybe it is possible here too. + "X-Apple-Client-App-Name": "Setup", + ]); } public void loadURLBag() { - string content = cast(string) std.net.curl.get("https://gsa.apple.com/grandslam/GsService2/lookup", httpClient); + string content = request.get("https://gsa.apple.com/grandslam/GsService2/lookup").responseBody.data!string(); version (LibPlist) { PlistDict plist = cast(PlistDict) Plist.fromXml(content); @@ -391,8 +394,8 @@ public class ProvisioningSession { import std.datetime.systime; - httpClient.addRequestHeader("X-Apple-I-Client-Time", Clock.currTime().toISOExtString()); - string startProvisioningPlist = cast(string) post(urlBag["midStartProvisioning"], + request.headers["X-Apple-I-Client-Time"] = Clock.currTime().stripMilliseconds().toISOExtString(); + string startProvisioningPlist = request.post(urlBag["midStartProvisioning"], " @@ -402,7 +405,7 @@ public class ProvisioningSession { \tRequest \t -", httpClient); +").responseBody.data!string(); scope string spimStr; { @@ -423,8 +426,8 @@ public class ProvisioningSession { scope auto cpim = adi.startProvisioning(dsId, spim); scope (failure) try { adi.destroyProvisioning(cpim.session); } catch(Throwable) {} - httpClient.addRequestHeader("X-Apple-I-Client-Time", Clock.currTime().toISOExtString()); - string endProvisioningPlist = cast(string) post(urlBag["midFinishProvisioning"], format!" + request.headers["X-Apple-I-Client-Time"] = Clock.currTime().stripMilliseconds().toISOExtString(); + string endProvisioningPlist = request.post(urlBag["midFinishProvisioning"], format!" @@ -436,7 +439,7 @@ public class ProvisioningSession { \t\t%s \t -"(Base64.encode(cpim.clientProvisioningIntermediateMetadata)), httpClient); +"(Base64.encode(cpim.clientProvisioningIntermediateMetadata))).responseBody.data!string(); scope ulong routingInformation; scope ubyte[] persistentTokenMetadata; @@ -584,3 +587,9 @@ public class ADIException: Exception { return errorCode; } } + +import std.datetime: dur, SysTime; +private SysTime stripMilliseconds(return SysTime time) { + time.fracSecs = dur!"msecs"(0); + return time; +} From 6d3cc856c91854354d3c83181a7b7e491d46a06d Mon Sep 17 00:00:00 2001 From: Dadoum Date: Mon, 12 Jun 2023 21:19:46 +0200 Subject: [PATCH 03/19] Port to Windows, and attempt adding an action. --- .github/workflows/cmake-windows.yml | 32 +++++++++++++++++ anisette_server/app.d | 7 +++- lib/provision/adi.d | 22 ++++++------ lib/provision/androidlibrary.d | 55 ++++++++++++++++++++++++++--- lib/provision/compat/general.d | 52 +++++++++++++-------------- lib/provision/compat/macos.d | 36 +++++++++++++++++++ lib/provision/compat/windows.d | 4 +-- lib/provision/symbols.d | 6 ++-- retrieve_headers/app.d | 7 +++- 9 files changed, 172 insertions(+), 49 deletions(-) create mode 100644 .github/workflows/cmake-windows.yml create mode 100644 lib/provision/compat/macos.d diff --git a/.github/workflows/cmake-windows.yml b/.github/workflows/cmake-windows.yml new file mode 100644 index 0000000..8ac4deb --- /dev/null +++ b/.github/workflows/cmake-windows.yml @@ -0,0 +1,32 @@ +name: x86_64 builds + +on: push + +env: + BUILD_TYPE: Release + +jobs: + build-anisette-server-windows-x86_64: + runs-on: windows-2019 + + steps: + - uses: actions/checkout@v3 + with: + submodules: recursive + + - uses: actions/checkout@v2 + - uses: dlang-community/setup-dlang@v1 + with: + compiler: ldc-latest + + - name: Build + run: dub build :anisette-server -b release -c "static" + + - name: Rename + run: mv "${{github.workspace}}/bin/provision_anisette-server.exe" "${{github.workspace}}/bin/anisette-server-x86_64.exe" + + - uses: actions/upload-artifact@v3 + with: + name: anisette-server-x86_64 + path: | + ${{github.workspace}}/bin/anisette-server-x86_64.exe diff --git a/anisette_server/app.d b/anisette_server/app.d index 053be52..68dedbe 100644 --- a/anisette_server/app.d +++ b/anisette_server/app.d @@ -176,7 +176,12 @@ void main(string[] args) { import std.datetime.systime; import std.datetime.timezone; import core.time; - auto time = Clock.currTime(); + version (Windows) { + import std.datetime.timezone; + auto time = Clock.currTime(UTC()); + } else { + auto time = Clock.currTime(); + } auto otp = adi.requestOTP(dsId); diff --git a/lib/provision/adi.d b/lib/provision/adi.d index ba13ee1..ee18c9f 100644 --- a/lib/provision/adi.d +++ b/lib/provision/adi.d @@ -58,7 +58,7 @@ public class ADI { public void provisioningPath(string path) { __provisioningPath = path; - pADISetProvisioningPath.androidInvoke(path.toStringz).unwrapADIError(); + androidInvoke!pADISetProvisioningPath(path.toStringz).unwrapADIError(); } private string __identifier; @@ -68,7 +68,7 @@ public class ADI { public void identifier(string identifier) { __identifier = identifier; - pADISetAndroidID.androidInvoke(identifier.ptr, cast(uint) identifier.length).unwrapADIError(); + androidInvoke!pADISetAndroidID(identifier.ptr, cast(uint) identifier.length).unwrapADIError(); } public this(string libraryPath) { @@ -121,11 +121,11 @@ public class ADI { } public void loadLibrary(string libraryPath) { - pADILoadLibraryWithPath.androidInvoke(cast(const(char*)) libraryPath.toStringz).unwrapADIError(); + androidInvoke!pADILoadLibraryWithPath(cast(const(char*)) libraryPath.toStringz).unwrapADIError(); } public void eraseProvisioning(ulong dsId) { - pADIProvisioningErase.androidInvoke(dsId).unwrapADIError(); + androidInvoke!pADIProvisioningErase(dsId).unwrapADIError(); } struct SynchronizationResumeMetadata { @@ -154,7 +154,7 @@ public class ADI { ubyte* mid; uint midLength; - pADISynchronize.androidInvoke( + androidInvoke!pADISynchronize( dsId, serverIntermediateMetadata.ptr, cast(uint) serverIntermediateMetadata.length, @@ -168,11 +168,11 @@ public class ADI { } public void destroyProvisioning(uint session) { - pADIProvisioningDestroy.androidInvoke(session).unwrapADIError(); + androidInvoke!pADIProvisioningDestroy(session).unwrapADIError(); } public void endProvisioning(uint session, ubyte[] persistentTokenMetadata, ubyte[] trustKey) { - pADIProvisioningEnd.androidInvoke( + androidInvoke!pADIProvisioningEnd( session, persistentTokenMetadata.ptr, cast(uint) persistentTokenMetadata.length, @@ -205,7 +205,7 @@ public class ADI { uint cpimLength; uint session; - pADIProvisioningStart.androidInvoke( + androidInvoke!pADIProvisioningStart( dsId, serverProvisioningIntermediateMetadata.ptr, cast(uint) serverProvisioningIntermediateMetadata.length, @@ -218,7 +218,7 @@ public class ADI { } public bool isMachineProvisioned(ulong dsId) { - int errorCode = pADIGetLoginCode.androidInvoke(dsId); + int errorCode = androidInvoke!pADIGetLoginCode(dsId); if (errorCode == 0) { return true; @@ -230,7 +230,7 @@ public class ADI { } public void dispose(void* ptr) { - pADIDispose.androidInvoke(ptr).unwrapADIError(); + androidInvoke!pADIDispose(ptr).unwrapADIError(); } struct OneTimePassword { @@ -259,7 +259,7 @@ public class ADI { ubyte* mid; uint midLength; - pADIOTPRequest.androidInvoke( + androidInvoke!pADIOTPRequest( dsId, &mid, &midLength, diff --git a/lib/provision/androidlibrary.d b/lib/provision/androidlibrary.d index 256f117..9d77cb3 100644 --- a/lib/provision/androidlibrary.d +++ b/lib/provision/androidlibrary.d @@ -35,6 +35,10 @@ public class AndroidLibrary { package SymbolHashTable hashTable; package AndroidLibrary[] loadedLibraries; + void[][] stubMaps; + size_t currentMapOffset = 0; + void[][] segments; + public void*[string] hooks; private ElfW!"Shdr"[] relocationSections; @@ -179,7 +183,7 @@ public class AndroidLibrary { addend = *cast(size_t*) (cast(size_t) allocation.ptr + offset); } } - auto symbol = getSymbolImplementation(getSymbolName(dynamicSymbolTable[symbolIndex])); + auto symbol = getSymbolImplementation(&dynamicStringTable[dynamicSymbolTable[symbolIndex].st_name]); auto location = cast(size_t*) (cast(size_t) allocation.ptr + offset); @@ -202,6 +206,35 @@ public class AndroidLibrary { } } + private void* buildStub(char* name) { + ubyte[] code = buildStubCode(name); + if (stubMaps.length == 0 || currentMapOffset + code.length > stubMaps[$ - 1].length) { + stubMaps ~= MmapAllocator.instance.allocate(pageSize); + currentMapOffset = 0; + } + + void[] currentStubMap = stubMaps[$ - 1]; + + mprotect(currentStubMap.ptr, currentStubMap.length, PROT_READ | PROT_WRITE); + currentStubMap[currentMapOffset..currentMapOffset + code.length] = code; + mprotect(currentStubMap.ptr, currentStubMap.length, PROT_READ | PROT_EXEC); + + void* address = ¤tStubMap[currentMapOffset]; + currentMapOffset += code.length; + return address; + } + + private ubyte[] buildStubCode(char* name) { + // generates x86_64 assembler code for `undefinedSymbol(name)` + // it's never going to return back so we don't care about not saving registers. + import provision.symbols; + return [ + ub!0x48, ub!0xBF, ] ~ name.ubytes() ~ [ // mov name %rdi + ub!0x48, ub!0xB8, ] ~ (&undefinedSymbol).ubytes() ~ [ // mov &undefinedSymbol %rax + ub!0xFF, ub!0xE0 // jmp *%rax + ]; + } + private string getSymbolName(ElfW!"Sym" symbol) { return cast(string) fromStringz(&dynamicStringTable[symbol.st_name]); } @@ -210,14 +243,18 @@ public class AndroidLibrary { return cast(string) fromStringz(§ionNamesTable[section.sh_name]); } - void* getSymbolImplementation(string symbolName) { + void* getSymbolImplementation(char* name) { + string symbolName = cast(string) name.fromStringz(); void** hook = symbolName in hooks; if (hook) { return *hook; } import provision.symbols; - return lookupSymbol(symbolName); + auto sym = lookupSymbol(symbolName); + if (!sym) + sym = buildStub(name); + return sym; } void* load(string symbolName) { @@ -438,6 +475,14 @@ template R_GENERIC(string relocationType) { enum R_GENERIC = mixin("R_" ~ relocationArch ~ "_" ~ relocationType); } +template ub(ubyte a) { + enum ub = a; +} + +ubyte[T.sizeof] ubytes(T)(T val) { + return *cast(ubyte[T.sizeof]*) &val; +} + size_t pageFloor(size_t number) { return number & pageMask; } @@ -465,7 +510,7 @@ class LoaderException: Exception { } class UndefinedSymbolException: Exception { - this(string file = __FILE__, size_t line = __LINE__) { - super("An undefined symbol has been called!", file, line); + this(string symbol, string file = __FILE__, size_t line = __LINE__) { + super(format!"An undefined symbol has been called: %s."(symbol), file, line); } } diff --git a/lib/provision/compat/general.d b/lib/provision/compat/general.d index be64dba..ac9d9b6 100644 --- a/lib/provision/compat/general.d +++ b/lib/provision/compat/general.d @@ -1,11 +1,18 @@ module provision.compat.general; -version (linux) { - import std.meta; - alias sysv = AliasSeq!(); -} else { +version (Windows) { + version (X86) { + version = WindowsHacks; + } + version (X86_64) { + version = WindowsHacks; + } +} + +version (WindowsHacks) { version (LDC) { import ldc.attributes; + import ldc.llvmasm; enum sysv = callingConvention("sysv_abi"); } else version (GNU) { import gcc.attributes; @@ -15,35 +22,28 @@ version (linux) { } else { static assert(false, "Your compiler is not supported on your platform, please use LDC2 or GDC."); } -} - -version (Windows) { - version (X86) { - version = WindowsHacks; - } - version (X86_64) { - version = WindowsHacks; - } -} -version (WindowsHacks) { import std.traits; - pragma(inline, false) auto androidInvoke(T, G...)(T delegate_, G params) { - void* del = cast(void*) delegate_; + pragma(inline, false) auto androidInvoke(alias U)(Parameters!U params) { + pragma(inline, false) extern(C) ReturnType!U internal(typeof(params)) @naked @sysv { // HACK + // asm { + // "jmp *%0" :: "r" (del); + // } + return __asm!(typeof(return))("jmp *%rax", "={rax}"); + } - pragma(inline, false) extern(C) ReturnType!T internal(Parameters!T params, void* del) @naked @sysv { // HACK - asm { - "jmp *%0" :: "r" (del); - } + debug { + import slf4d; + getLogger().traceF!"calling %s"(__traits(identifier, U)); } - import slf4d; - getLogger().traceF!"Calling ? %x%s"(del, G.stringof); - import std.stdio; - stdout.flush(); - return internal(params, del); + __asm("mov $0, %rax", "{rax}", U); + return internal(params); } } else { + import std.meta; + alias sysv = AliasSeq!(); + pragma(inline, true) auto androidInvoke(T, G...)(T delegate_, G params) { return delegate_(params); } diff --git a/lib/provision/compat/macos.d b/lib/provision/compat/macos.d new file mode 100644 index 0000000..2a8f8c6 --- /dev/null +++ b/lib/provision/compat/macos.d @@ -0,0 +1,36 @@ +module provision.compat.macos; + +version(OSX): + +import core.stdc.errno; +import core.stdc.stdlib; +import core.stdc.string; +import core.sys.posix.fcntl; +import core.sys.posix.sys.stat; +import core.sys.posix.sys.time; +import core.sys.posix.unistd; + +template traceCall(alias U) { + import std.traits; + import slf4d; + auto ref traceCall(Parameters!U params) { + getLogger().traceF!"CALL // %s"(__traits(identifier, U)); + return U(params); + } +} + +alias __errno_location = traceCall!(errno); +alias strncpy = traceCall!(core.stdc.string.strncpy); +alias lstat = traceCall!(core.sys.posix.sys.stat.lstat); +alias fstat = traceCall!(core.sys.posix.sys.stat.fstat); +alias malloc = core.stdc.stdlib.malloc; +alias free = core.stdc.stdlib.free; +alias gettimeofday = traceCall!(core.sys.posix.sys.time.gettimeofday); +alias open = traceCall!(core.sys.posix.fcntl.open); +alias close = traceCall!(core.sys.posix.unistd.close); +alias read = traceCall!(core.sys.posix.unistd.read); +alias write = traceCall!(core.sys.posix.unistd.write); +alias mkdir = traceCall!(core.sys.posix.fcntl.mkdir); +alias chmod = traceCall!(core.sys.posix.fcntl.chmod); +alias ftruncate = traceCall!(core.sys.posix.unistd.ftruncate); +alias umask = traceCall!(core.sys.posix.sys.stat.umask); diff --git a/lib/provision/compat/windows.d b/lib/provision/compat/windows.d index ac4e18b..4e3789b 100644 --- a/lib/provision/compat/windows.d +++ b/lib/provision/compat/windows.d @@ -160,11 +160,11 @@ int lstat(const(char)* path, linux_stat* out_) { uint mode = octal!555; - if (stat_windows.st_mode & octal!11) { + if (stat_windows.st_mode & 0b11) { mode |= octal!200; } - if (stat_windows.st_mode & octal!4000) { + if (stat_windows.st_mode & 0x4000) { mode |= octal!40000; } diff --git a/lib/provision/symbols.d b/lib/provision/symbols.d index d24c603..40fd0e2 100644 --- a/lib/provision/symbols.d +++ b/lib/provision/symbols.d @@ -34,8 +34,8 @@ private @sysv extern (C) int emptyStub() { return 0; } -private @sysv extern (C) noreturn undefinedSymbol() { - throw new UndefinedSymbolException(); +package @sysv noreturn undefinedSymbol(immutable char* symbol) { + throw new UndefinedSymbolException(symbol.fromStringz()); } private @sysv extern (C) AndroidLibrary dlopenWrapper(const char* name) { @@ -161,5 +161,5 @@ package void* lookupSymbol(string str) { return wordlist[key].ptr; } } - return &undefinedSymbol; + return null; } diff --git a/retrieve_headers/app.d b/retrieve_headers/app.d index 2a81ed8..558286a 100644 --- a/retrieve_headers/app.d +++ b/retrieve_headers/app.d @@ -85,7 +85,12 @@ int main(string[] args) { auto otp = adi.requestOTP(-2); import std.datetime.systime; - auto time = Clock.currTime(); + version (Windows) { + import std.datetime.timezone; + auto time = Clock.currTime(UTC()); + } else { + auto time = Clock.currTime(); + } std.stdio.writeln( format!`{ From ebdace60f99aba30e4f31cdd7e7e05803256ff80 Mon Sep 17 00:00:00 2001 From: Dadoum Date: Mon, 12 Jun 2023 21:28:29 +0200 Subject: [PATCH 04/19] Hopefully fix Windows build --- .github/workflows/cmake-windows.yml | 2 +- dub.sdl | 2 +- lib/provision/compat/general.d | 4 +--- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/cmake-windows.yml b/.github/workflows/cmake-windows.yml index 8ac4deb..5492eb1 100644 --- a/.github/workflows/cmake-windows.yml +++ b/.github/workflows/cmake-windows.yml @@ -1,4 +1,4 @@ -name: x86_64 builds +name: Windows build on: push diff --git a/dub.sdl b/dub.sdl index dd2a496..d06e025 100644 --- a/dub.sdl +++ b/dub.sdl @@ -62,7 +62,7 @@ subPackage { configuration "static" { targetType "executable" - lflags "-lz" platform="ldc" + lflags "-lz" platform="linux-ldc" dflags "--link-defaultlib-shared=false" platform="ldc" dflags "-defaultlib=:libgphobos.a" platform="gdc" } diff --git a/lib/provision/compat/general.d b/lib/provision/compat/general.d index ac9d9b6..a1a13ee 100644 --- a/lib/provision/compat/general.d +++ b/lib/provision/compat/general.d @@ -44,7 +44,5 @@ version (WindowsHacks) { import std.meta; alias sysv = AliasSeq!(); - pragma(inline, true) auto androidInvoke(T, G...)(T delegate_, G params) { - return delegate_(params); - } + alias androidInvoke(alias U) = U; } From f196b2a7b5b56c6dbb79663de1fcafef640b4a77 Mon Sep 17 00:00:00 2001 From: Dadoum Date: Mon, 12 Jun 2023 22:52:25 +0200 Subject: [PATCH 05/19] Port mkcassette to Windows --- lib/provision/compat/windows.d | 10 +++++----- mkcassette/app.d | 9 ++++++++- toolchains/windows.cmake | 3 +++ 3 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 toolchains/windows.cmake diff --git a/lib/provision/compat/windows.d b/lib/provision/compat/windows.d index 4e3789b..9928006 100644 --- a/lib/provision/compat/windows.d +++ b/lib/provision/compat/windows.d @@ -24,11 +24,6 @@ private extern (C) { long tv_nsec; } - struct timeval { - size_t tv_sec; - size_t tv_usec; - } - struct linux_stat { ulong st_dev; ulong st_ino; @@ -57,6 +52,11 @@ private extern (C) { int _write(int fd, void* buf, uint count); } +struct timeval { + size_t tv_sec; + size_t tv_usec; +} + public import core.stdc.errno; public import core.stdc.stdlib; public import core.stdc.string; diff --git a/mkcassette/app.d b/mkcassette/app.d index fe09151..c951317 100644 --- a/mkcassette/app.d +++ b/mkcassette/app.d @@ -21,6 +21,7 @@ import slf4d; import provision; import provision.androidlibrary; +import provision.compat.windows; import provision.symbols; import constants; @@ -128,7 +129,13 @@ int main(string[] args) { targetTime = taskPool.workerLocalStorage(origTimeVal); // Initializing ADI and machine if it has not already been made. - Device device = new Device(configurationPath.buildPath("/dev/null")); + version (Windows) { + enum nullFilename = "NUL"; + } else { + enum nullFilename = "/dev/null"; + } + + Device device = new Device(nullFilename); { ADI adi = new ADI("lib/" ~ architectureIdentifier); adi.provisioningPath = configurationPath; diff --git a/toolchains/windows.cmake b/toolchains/windows.cmake new file mode 100644 index 0000000..bf7bd3f --- /dev/null +++ b/toolchains/windows.cmake @@ -0,0 +1,3 @@ +SET(CMAKE_SYSTEM_NAME Windows) +SET(CMAKE_D_COMPILER "ldc2;-mtriple=x86_64-windows-msvc") +SET(CMAKE_D_COMPILER "ldc2;-mtriple=x86_64-windows-msvc") \ No newline at end of file From ae61ee5c26b4e47ec6c078aca18e23339c3120fd Mon Sep 17 00:00:00 2001 From: Dadoum Date: Mon, 12 Jun 2023 22:57:08 +0200 Subject: [PATCH 06/19] Remove duplicate line in the Windows cmake file --- toolchains/windows.cmake | 1 - 1 file changed, 1 deletion(-) diff --git a/toolchains/windows.cmake b/toolchains/windows.cmake index bf7bd3f..31d07dc 100644 --- a/toolchains/windows.cmake +++ b/toolchains/windows.cmake @@ -1,3 +1,2 @@ SET(CMAKE_SYSTEM_NAME Windows) SET(CMAKE_D_COMPILER "ldc2;-mtriple=x86_64-windows-msvc") -SET(CMAKE_D_COMPILER "ldc2;-mtriple=x86_64-windows-msvc") \ No newline at end of file From 690bb798eced426eb29312fe405075de644bc8a8 Mon Sep 17 00:00:00 2001 From: Dadoum Date: Tue, 13 Jun 2023 08:24:57 +0200 Subject: [PATCH 07/19] Fix Linux support --- cmake/cmake-d | 2 +- lib/provision/compat/linux.d | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cmake/cmake-d b/cmake/cmake-d index cb455cf..d786867 160000 --- a/cmake/cmake-d +++ b/cmake/cmake-d @@ -1 +1 @@ -Subproject commit cb455cf3d818d6e6c41c3614d29cdd9a0793c711 +Subproject commit d786867f671057d2185a9a6b139018a7db8aa1e3 diff --git a/lib/provision/compat/linux.d b/lib/provision/compat/linux.d index a837cba..f870183 100644 --- a/lib/provision/compat/linux.d +++ b/lib/provision/compat/linux.d @@ -10,10 +10,12 @@ import core.sys.posix.sys.stat; import core.sys.posix.sys.time; import core.sys.posix.unistd; +import provision.compat.general; + template traceCall(alias U) { import std.traits; import slf4d; - auto ref traceCall(Parameters!U params) { + extern(C) auto ref traceCall(Parameters!U params) @sysv { getLogger().traceF!"CALL // %s"(__traits(identifier, U)); return U(params); } From 820096be41a4c05075739bb0c54dcbab7ad97e61 Mon Sep 17 00:00:00 2001 From: Dadoum Date: Sun, 30 Jul 2023 16:35:49 +0200 Subject: [PATCH 08/19] Use TRACE log level for everything a bit spammy --- lib/provision/compat/windows.d | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/lib/provision/compat/windows.d b/lib/provision/compat/windows.d index 9928006..3983620 100644 --- a/lib/provision/compat/windows.d +++ b/lib/provision/compat/windows.d @@ -98,7 +98,7 @@ void free(void* ptr) { } ref int __errno_location2() { - getLogger().debugF!"CALL // errno: %d"(errno()); + getLogger().traceF!"CALL // errno: %d"(errno()); errno = 0; return errno(); } @@ -106,36 +106,34 @@ ref int __errno_location2() { alias __errno_location = __errno_location2; char* strncpy(return scope char* s1, scope const char* s2, size_t n) { - getLogger().debugF!"CALL // strncpy 0x%x -(%d)-> 0x%x"(s1, /+ s1[0..n],+/ n, s2); + // getLogger().traceF!"CALL // strncpy 0x%x -(%d)-> 0x%x"(s1, /+ s1[0..n],+/ n, s2); return core.stdc.string.strncpy(s1, s2, n); } size_t umask(size_t s) { - getLogger().debug_("CALL // umask"); + getLogger().trace("CALL // umask"); return s; } size_t ftruncate(ulong handle, ulong length) { - getLogger().debug_("CALL // ftruncate"); + getLogger().trace("CALL // ftruncate"); return _chsize(handle, length); } int gettimeofday(timeval* tv, void* tz) { - getLogger().debug_("CALL // gettimeofday"); + getLogger().trace("CALL // gettimeofday"); auto time = Clock.currTime(); *tv = timeval(time.toUnixTime(), time.fracSecs.total!"usecs"); - getLogger().debugF!" -> gettimeofday %s"(*tv); - return 0; } int chmod(const(char)* path, int mode) { - getLogger().debug_("CALL // chmod"); + getLogger().trace("CALL // chmod"); return _chmod(path.toWindowsPath(), mode); } int mkdir(const(char)* path, int mode) { - getLogger().debug_("CALL // mkdir"); + getLogger().trace("CALL // mkdir"); return _mkdir(path.toWindowsPath(), mode); } @@ -192,13 +190,12 @@ int lstat(const(char)* path, linux_stat* out_) { 0, [0, 0, 0] ); - getLogger().traceF!"-> lstat %s"(*out_); return ret; } int open(const(char)* path, int oflag) { - getLogger().debug_("CALL // open"); + getLogger().trace("CALL // open"); int convertedOflag = 0x8000; // Binary mode @@ -218,17 +215,17 @@ int open(const(char)* path, int oflag) { } int close(int fd) { - getLogger().debug_("CALL // close"); + getLogger().trace("CALL // close"); return _close(fd); } int read(int fd, void* buf, uint count) { - getLogger().debug_("CALL // read"); + getLogger().trace("CALL // read"); return _read(fd, buf, count); } int write(int fd, void* buf, uint count) { - getLogger().debug_("CALL // write"); + getLogger().trace("CALL // write"); return _write(fd, buf, count); } @@ -271,7 +268,6 @@ int fstat(int fd, linux_stat* out_) { 0, [0, 0, 0] ); - getLogger().traceF!"-> fstat %s"(*out_); return ret; } From b4e1a689160644aadc7b1a179f3f74ba69470aa3 Mon Sep 17 00:00:00 2001 From: Dadoum Date: Sun, 30 Jul 2023 17:12:05 +0200 Subject: [PATCH 09/19] Add debug symbols to GH Actions --- .github/workflows/cmake-cross-compile.yml | 22 +++++++++++++++++----- .github/workflows/cmake-windows.yml | 7 +++++-- .github/workflows/cmake.yml | 20 ++++++++++++++++---- dub.sdl | 6 +++--- 4 files changed, 41 insertions(+), 14 deletions(-) diff --git a/.github/workflows/cmake-cross-compile.yml b/.github/workflows/cmake-cross-compile.yml index 39b1eb2..863a7e9 100644 --- a/.github/workflows/cmake-cross-compile.yml +++ b/.github/workflows/cmake-cross-compile.yml @@ -16,20 +16,26 @@ jobs: submodules: recursive - name: Install dependencies - run: sudo apt-get update && sudo apt-get install -y gdc-12-aarch64-linux-gnu dub libz-dev + run: | + sudo add-apt-repository ppa:ubuntu-toolchain-r/ppa + sudo apt-get update && sudo apt-get install -y gdc-13-aarch64-linux-gnu dub libz-dev - name: Build - run: dub build :anisette-server -b release --compiler=aarch64-linux-gnu-gdc-12 -c "static" + run: dub build :anisette-server -b release --compiler=aarch64-linux-gnu-gdc-13 -c "static" - name: Rename run: mv "${{github.workspace}}/bin/provision_anisette-server" "${{github.workspace}}/bin/anisette-server-aarch64" + - name: Put debug symbols in a separate file + run: eu-strip --strip-debug -f "${{github.workspace}}/bin/anisette-server-aarch64.dbg" "${{github.workspace}}/bin/anisette-server-aarch64" + - uses: actions/upload-artifact@v3 with: name: anisette-server-aarch64 path: | ${{github.workspace}}/bin/anisette-server-aarch64 - + ${{github.workspace}}/bin/anisette-server-aarch64.dbg + build-anisette-server-armv7: runs-on: ubuntu-22.04 @@ -39,16 +45,22 @@ jobs: submodules: recursive - name: Install dependencies - run: sudo apt-get update && sudo apt-get install -y gdc-12-arm-linux-gnueabihf dub libz-dev + run: | + sudo add-apt-repository ppa:ubuntu-toolchain-r/ppa + sudo apt-get update && sudo apt-get install -y gdc-13-arm-linux-gnueabihf dub libz-dev - name: Build - run: dub build :anisette-server -b release --compiler=arm-linux-gnueabihf-gdc-12 -c "static" + run: dub build :anisette-server -b release --compiler=arm-linux-gnueabihf-gdc-13 -c "static" - name: Rename run: mv "${{github.workspace}}/bin/provision_anisette-server" "${{github.workspace}}/bin/anisette-server-armv7" + - name: Put debug symbols in a separate file + run: eu-strip --strip-debug -f "${{github.workspace}}/bin/anisette-server-armv7.dbg" "${{github.workspace}}/bin/anisette-server-armv7" + - uses: actions/upload-artifact@v3 with: name: anisette-server-armv7 path: | ${{github.workspace}}/bin/anisette-server-armv7 + ${{github.workspace}}/bin/anisette-server-armv7.dbg diff --git a/.github/workflows/cmake-windows.yml b/.github/workflows/cmake-windows.yml index 5492eb1..738fd3d 100644 --- a/.github/workflows/cmake-windows.yml +++ b/.github/workflows/cmake-windows.yml @@ -20,13 +20,16 @@ jobs: compiler: ldc-latest - name: Build - run: dub build :anisette-server -b release -c "static" + run: dub build :anisette-server -b release-debug -c "static" - name: Rename - run: mv "${{github.workspace}}/bin/provision_anisette-server.exe" "${{github.workspace}}/bin/anisette-server-x86_64.exe" + run: | + mv "${{github.workspace}}/bin/provision_anisette-server.exe" "${{github.workspace}}/bin/anisette-server-x86_64.exe" + mv "${{github.workspace}}/bin/provision_anisette-server.pdb" "${{github.workspace}}/bin/anisette-server-x86_64.pdb" - uses: actions/upload-artifact@v3 with: name: anisette-server-x86_64 path: | ${{github.workspace}}/bin/anisette-server-x86_64.exe + ${{github.workspace}}/bin/anisette-server-x86_64.pdb diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 9325c3f..8d38d13 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -15,19 +15,25 @@ jobs: submodules: recursive - name: Install dependencies - run: sudo apt-get update && sudo apt-get install -y gdc-12 dub libz-dev + run: | + sudo add-apt-repository ppa:ubuntu-toolchain-r/ppa + sudo apt-get update && sudo apt-get install -y gdc-13 dub libz-dev elfutils - name: Build - run: dub build :anisette-server -b release --compiler=gdc-12 -c "static" + run: dub build :anisette-server -b release --compiler=gdc-13 -c "static" - name: Rename run: mv "${{github.workspace}}/bin/provision_anisette-server" "${{github.workspace}}/bin/anisette-server-x86_64" + - name: Put debug symbols in a separate file + run: eu-strip --strip-debug -f "${{github.workspace}}/bin/anisette-server-x86_64.dbg" "${{github.workspace}}/bin/anisette-server-x86_64" + - uses: actions/upload-artifact@v3 with: name: anisette-server-x86_64 path: | ${{github.workspace}}/bin/anisette-server-x86_64 + ${{github.workspace}}/bin/anisette-server-x86_64.dbg build-anisette-server-i686: runs-on: ubuntu-22.04 @@ -38,17 +44,23 @@ jobs: submodules: recursive - name: Install dependencies - run: sudo apt-get update && sudo apt-get install -y gdc-12-i686-linux-gnu dub libz-dev + run: | + sudo add-apt-repository ppa:ubuntu-toolchain-r/ppa + sudo apt-get update && sudo apt-get install -y gdc-13-i686-linux-gnu dub libz-dev - name: Build - run: dub build :anisette-server -b release --compiler=i686-linux-gnu-gdc-12 -c "static" + run: dub build :anisette-server -b release --compiler=i686-linux-gnu-gdc-13 -c "static" - name: Rename run: mv "${{github.workspace}}/bin/provision_anisette-server" "${{github.workspace}}/bin/anisette-server-i686" + - name: Put debug symbols in a separate file + run: eu-strip --strip-debug -f "${{github.workspace}}/bin/anisette-server-i686.dbg" "${{github.workspace}}/bin/anisette-server-i686" + - uses: actions/upload-artifact@v3 with: name: anisette-server-i686 path: | ${{github.workspace}}/bin/anisette-server-i686 + ${{github.workspace}}/bin/anisette-server-i686.dbg diff --git a/dub.sdl b/dub.sdl index 14c73af..81c1617 100644 --- a/dub.sdl +++ b/dub.sdl @@ -9,8 +9,8 @@ targetPath "bin" sourcePaths "lib" importPaths "lib" -dependency "requests" version="~>2.0.9" -dependency "slf4d" version="~>2.1.1" +dependency "requests" version="~>2" +dependency "slf4d" version="~>2" configuration "plist-d" { dependency "plist" version="~master" @@ -31,7 +31,7 @@ subPackage { sourcePaths "retrieve_headers" dependency "provision" version="*" - lflags "/usr/x86_64-w64-mingw32ucrt/sys-root/mingw/lib/libws2_32.a" "/usr/x86_64-w64-mingw32ucrt/sys-root/mingw/lib/libmincore.a" "/usr/x86_64-w64-mingw32ucrt/sys-root/mingw/lib/libwsock32.a" platform="gdc" + // lflags "/usr/x86_64-w64-mingw32ucrt/sys-root/mingw/lib/libws2_32.a" "/usr/x86_64-w64-mingw32ucrt/sys-root/mingw/lib/libmincore.a" "/usr/x86_64-w64-mingw32ucrt/sys-root/mingw/lib/libwsock32.a" platform="gdc" } subPackage { From 79c3e1e8d853d0ff66ba231ab94573cd422a5e36 Mon Sep 17 00:00:00 2001 From: Dadoum Date: Sun, 30 Jul 2023 19:25:48 +0200 Subject: [PATCH 10/19] Build on Ubuntu 23.04 --- .github/workflows/cmake-cross-compile.yml | 14 ++++++-------- .github/workflows/cmake.yml | 7 +++---- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/.github/workflows/cmake-cross-compile.yml b/.github/workflows/cmake-cross-compile.yml index 863a7e9..949bc84 100644 --- a/.github/workflows/cmake-cross-compile.yml +++ b/.github/workflows/cmake-cross-compile.yml @@ -8,7 +8,8 @@ env: jobs: build-anisette-server-aarch64: - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest + container: ubuntu:23.04 steps: - uses: actions/checkout@v3 @@ -16,9 +17,7 @@ jobs: submodules: recursive - name: Install dependencies - run: | - sudo add-apt-repository ppa:ubuntu-toolchain-r/ppa - sudo apt-get update && sudo apt-get install -y gdc-13-aarch64-linux-gnu dub libz-dev + run: sudo apt-get update && sudo apt-get install -y gdc-13-aarch64-linux-gnu dub libz-dev - name: Build run: dub build :anisette-server -b release --compiler=aarch64-linux-gnu-gdc-13 -c "static" @@ -37,7 +36,8 @@ jobs: ${{github.workspace}}/bin/anisette-server-aarch64.dbg build-anisette-server-armv7: - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest + container: ubuntu:23.04 steps: - uses: actions/checkout@v3 @@ -45,9 +45,7 @@ jobs: submodules: recursive - name: Install dependencies - run: | - sudo add-apt-repository ppa:ubuntu-toolchain-r/ppa - sudo apt-get update && sudo apt-get install -y gdc-13-arm-linux-gnueabihf dub libz-dev + run: sudo apt-get update && sudo apt-get install -y gdc-13-arm-linux-gnueabihf dub libz-dev - name: Build run: dub build :anisette-server -b release --compiler=arm-linux-gnueabihf-gdc-13 -c "static" diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 8d38d13..0562b64 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -36,7 +36,8 @@ jobs: ${{github.workspace}}/bin/anisette-server-x86_64.dbg build-anisette-server-i686: - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest + container: ubuntu:23.04 steps: - uses: actions/checkout@v3 @@ -44,9 +45,7 @@ jobs: submodules: recursive - name: Install dependencies - run: | - sudo add-apt-repository ppa:ubuntu-toolchain-r/ppa - sudo apt-get update && sudo apt-get install -y gdc-13-i686-linux-gnu dub libz-dev + run: sudo apt-get update && sudo apt-get install -y gdc-13-i686-linux-gnu dub libz-dev - name: Build run: dub build :anisette-server -b release --compiler=i686-linux-gnu-gdc-13 -c "static" From b6f367bc790011b9f2b6811ef14ead250a5a18d5 Mon Sep 17 00:00:00 2001 From: Dadoum Date: Sun, 30 Jul 2023 19:28:51 +0200 Subject: [PATCH 11/19] Fix GH Actions --- .github/workflows/cmake-cross-compile.yml | 12 ++++++------ .github/workflows/cmake.yml | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/cmake-cross-compile.yml b/.github/workflows/cmake-cross-compile.yml index 949bc84..bf24095 100644 --- a/.github/workflows/cmake-cross-compile.yml +++ b/.github/workflows/cmake-cross-compile.yml @@ -12,13 +12,13 @@ jobs: container: ubuntu:23.04 steps: + - name: Install dependencies + run: sudo apt-get update && sudo apt-get install -y gdc-13-aarch64-linux-gnu dub libz-dev + - uses: actions/checkout@v3 with: submodules: recursive - - name: Install dependencies - run: sudo apt-get update && sudo apt-get install -y gdc-13-aarch64-linux-gnu dub libz-dev - - name: Build run: dub build :anisette-server -b release --compiler=aarch64-linux-gnu-gdc-13 -c "static" @@ -40,13 +40,13 @@ jobs: container: ubuntu:23.04 steps: + - name: Install dependencies + run: sudo apt-get update && sudo apt-get install -y git gdc-13-arm-linux-gnueabihf dub libz-dev + - uses: actions/checkout@v3 with: submodules: recursive - - name: Install dependencies - run: sudo apt-get update && sudo apt-get install -y gdc-13-arm-linux-gnueabihf dub libz-dev - - name: Build run: dub build :anisette-server -b release --compiler=arm-linux-gnueabihf-gdc-13 -c "static" diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 0562b64..9273a4d 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -40,13 +40,13 @@ jobs: container: ubuntu:23.04 steps: + - name: Install dependencies + run: sudo apt-get update && sudo apt-get install -y gdc-13-i686-linux-gnu dub libz-dev + - uses: actions/checkout@v3 with: submodules: recursive - - name: Install dependencies - run: sudo apt-get update && sudo apt-get install -y gdc-13-i686-linux-gnu dub libz-dev - - name: Build run: dub build :anisette-server -b release --compiler=i686-linux-gnu-gdc-13 -c "static" From 1af504c6d4c3d504553ac63930c2c76f4572aac0 Mon Sep 17 00:00:00 2001 From: Dadoum Date: Sun, 30 Jul 2023 19:30:38 +0200 Subject: [PATCH 12/19] Fix GH Actions 2 --- .github/workflows/cmake-cross-compile.yml | 8 ++++++-- .github/workflows/cmake.yml | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cmake-cross-compile.yml b/.github/workflows/cmake-cross-compile.yml index bf24095..0b60d63 100644 --- a/.github/workflows/cmake-cross-compile.yml +++ b/.github/workflows/cmake-cross-compile.yml @@ -13,7 +13,9 @@ jobs: steps: - name: Install dependencies - run: sudo apt-get update && sudo apt-get install -y gdc-13-aarch64-linux-gnu dub libz-dev + run: | + apt-get update + apt-get install -y git gdc-13-aarch64-linux-gnu dub libz-dev - uses: actions/checkout@v3 with: @@ -41,7 +43,9 @@ jobs: steps: - name: Install dependencies - run: sudo apt-get update && sudo apt-get install -y git gdc-13-arm-linux-gnueabihf dub libz-dev + run: | + apt-get update + apt-get install -y git gdc-13-arm-linux-gnueabihf dub libz-dev - uses: actions/checkout@v3 with: diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 9273a4d..9367078 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -41,7 +41,9 @@ jobs: steps: - name: Install dependencies - run: sudo apt-get update && sudo apt-get install -y gdc-13-i686-linux-gnu dub libz-dev + run: | + apt-get update + apt-get install -y git gdc-13-i686-linux-gnu dub libz-dev - uses: actions/checkout@v3 with: From a7636348717149fc53bb64c7c948b17e04e72025 Mon Sep 17 00:00:00 2001 From: Dadoum Date: Sun, 30 Jul 2023 20:05:32 +0200 Subject: [PATCH 13/19] Cross-compilation on GitHub Actions Round 3 --- .github/workflows/cmake-cross-compile.yml | 8 ++++++++ .github/workflows/cmake.yml | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/.github/workflows/cmake-cross-compile.yml b/.github/workflows/cmake-cross-compile.yml index 0b60d63..6acd1c4 100644 --- a/.github/workflows/cmake-cross-compile.yml +++ b/.github/workflows/cmake-cross-compile.yml @@ -14,6 +14,10 @@ jobs: steps: - name: Install dependencies run: | + cat << EOF | tee /etc/apt/sources.list.d/gdc-backports.list + deb http://ppa.launchpad.net/ubuntu-toolchain-r/ppa/ubuntu jammy main + deb-src http://ppa.launchpad.net/ubuntu-toolchain-r/ppa/ubuntu jammy main + EOF apt-get update apt-get install -y git gdc-13-aarch64-linux-gnu dub libz-dev @@ -44,6 +48,10 @@ jobs: steps: - name: Install dependencies run: | + cat << EOF | tee /etc/apt/sources.list.d/gdc-backports.list + deb http://ppa.launchpad.net/ubuntu-toolchain-r/ppa/ubuntu jammy main + deb-src http://ppa.launchpad.net/ubuntu-toolchain-r/ppa/ubuntu jammy main + EOF apt-get update apt-get install -y git gdc-13-arm-linux-gnueabihf dub libz-dev diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 9367078..a94f342 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -42,6 +42,10 @@ jobs: steps: - name: Install dependencies run: | + cat << EOF | tee /etc/apt/sources.list.d/gdc-backports.list + deb http://ppa.launchpad.net/ubuntu-toolchain-r/ppa/ubuntu jammy main + deb-src http://ppa.launchpad.net/ubuntu-toolchain-r/ppa/ubuntu jammy main + EOF apt-get update apt-get install -y git gdc-13-i686-linux-gnu dub libz-dev From 7d28f6dadea7ee1747539e712856f5be705450af Mon Sep 17 00:00:00 2001 From: Dadoum Date: Sun, 30 Jul 2023 20:09:36 +0200 Subject: [PATCH 14/19] Cross-compilation on GitHub Actions Round 4 --- .github/workflows/cmake-cross-compile.yml | 2 ++ .github/workflows/cmake.yml | 1 + 2 files changed, 3 insertions(+) diff --git a/.github/workflows/cmake-cross-compile.yml b/.github/workflows/cmake-cross-compile.yml index 6acd1c4..94f8db6 100644 --- a/.github/workflows/cmake-cross-compile.yml +++ b/.github/workflows/cmake-cross-compile.yml @@ -18,6 +18,7 @@ jobs: deb http://ppa.launchpad.net/ubuntu-toolchain-r/ppa/ubuntu jammy main deb-src http://ppa.launchpad.net/ubuntu-toolchain-r/ppa/ubuntu jammy main EOF + apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 60C317803A41BA51845E371A1E9377A2BA9EF27F apt-get update apt-get install -y git gdc-13-aarch64-linux-gnu dub libz-dev @@ -52,6 +53,7 @@ jobs: deb http://ppa.launchpad.net/ubuntu-toolchain-r/ppa/ubuntu jammy main deb-src http://ppa.launchpad.net/ubuntu-toolchain-r/ppa/ubuntu jammy main EOF + apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 60C317803A41BA51845E371A1E9377A2BA9EF27F apt-get update apt-get install -y git gdc-13-arm-linux-gnueabihf dub libz-dev diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index a94f342..96b569e 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -46,6 +46,7 @@ jobs: deb http://ppa.launchpad.net/ubuntu-toolchain-r/ppa/ubuntu jammy main deb-src http://ppa.launchpad.net/ubuntu-toolchain-r/ppa/ubuntu jammy main EOF + apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 60C317803A41BA51845E371A1E9377A2BA9EF27F apt-get update apt-get install -y git gdc-13-i686-linux-gnu dub libz-dev From 2027ac8ffdaa985181e491a80b3c84aeb952a1b8 Mon Sep 17 00:00:00 2001 From: Dadoum Date: Sun, 30 Jul 2023 20:12:09 +0200 Subject: [PATCH 15/19] Cross-compilation on GitHub Actions Round 5 --- .github/workflows/cmake-cross-compile.yml | 16 +++++----------- .github/workflows/cmake.yml | 7 ++----- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/.github/workflows/cmake-cross-compile.yml b/.github/workflows/cmake-cross-compile.yml index 94f8db6..ab75fcc 100644 --- a/.github/workflows/cmake-cross-compile.yml +++ b/.github/workflows/cmake-cross-compile.yml @@ -14,12 +14,9 @@ jobs: steps: - name: Install dependencies run: | - cat << EOF | tee /etc/apt/sources.list.d/gdc-backports.list - deb http://ppa.launchpad.net/ubuntu-toolchain-r/ppa/ubuntu jammy main - deb-src http://ppa.launchpad.net/ubuntu-toolchain-r/ppa/ubuntu jammy main - EOF - apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 60C317803A41BA51845E371A1E9377A2BA9EF27F apt-get update + apt-get install -y software-properties-common + add-apt-repository ppa:ubuntu-toolchain-r/ppa apt-get install -y git gdc-13-aarch64-linux-gnu dub libz-dev - uses: actions/checkout@v3 @@ -49,12 +46,9 @@ jobs: steps: - name: Install dependencies run: | - cat << EOF | tee /etc/apt/sources.list.d/gdc-backports.list - deb http://ppa.launchpad.net/ubuntu-toolchain-r/ppa/ubuntu jammy main - deb-src http://ppa.launchpad.net/ubuntu-toolchain-r/ppa/ubuntu jammy main - EOF - apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 60C317803A41BA51845E371A1E9377A2BA9EF27F - apt-get update + apt-get update + apt-get install -y software-properties-common + add-apt-repository ppa:ubuntu-toolchain-r/ppa apt-get install -y git gdc-13-arm-linux-gnueabihf dub libz-dev - uses: actions/checkout@v3 diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 96b569e..33a0dc7 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -42,12 +42,9 @@ jobs: steps: - name: Install dependencies run: | - cat << EOF | tee /etc/apt/sources.list.d/gdc-backports.list - deb http://ppa.launchpad.net/ubuntu-toolchain-r/ppa/ubuntu jammy main - deb-src http://ppa.launchpad.net/ubuntu-toolchain-r/ppa/ubuntu jammy main - EOF - apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 60C317803A41BA51845E371A1E9377A2BA9EF27F apt-get update + apt-get install -y software-properties-common + add-apt-repository ppa:ubuntu-toolchain-r/ppa apt-get install -y git gdc-13-i686-linux-gnu dub libz-dev - uses: actions/checkout@v3 From d9ec21f43c85e8d149e6d5f3720eb6836b1cde60 Mon Sep 17 00:00:00 2001 From: Dadoum Date: Sun, 30 Jul 2023 20:19:31 +0200 Subject: [PATCH 16/19] Cross-compilation on GitHub Actions Round 6 (hopefully the final one) --- .github/workflows/cmake-cross-compile.yml | 16 ++++++++-------- .github/workflows/cmake.yml | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/cmake-cross-compile.yml b/.github/workflows/cmake-cross-compile.yml index ab75fcc..78b1f30 100644 --- a/.github/workflows/cmake-cross-compile.yml +++ b/.github/workflows/cmake-cross-compile.yml @@ -27,17 +27,17 @@ jobs: run: dub build :anisette-server -b release --compiler=aarch64-linux-gnu-gdc-13 -c "static" - name: Rename - run: mv "${{github.workspace}}/bin/provision_anisette-server" "${{github.workspace}}/bin/anisette-server-aarch64" + run: mv "bin/provision_anisette-server" "bin/anisette-server-aarch64" - name: Put debug symbols in a separate file - run: eu-strip --strip-debug -f "${{github.workspace}}/bin/anisette-server-aarch64.dbg" "${{github.workspace}}/bin/anisette-server-aarch64" + run: eu-strip --strip-debug -f "bin/anisette-server-aarch64.dbg" "bin/anisette-server-aarch64" - uses: actions/upload-artifact@v3 with: name: anisette-server-aarch64 path: | - ${{github.workspace}}/bin/anisette-server-aarch64 - ${{github.workspace}}/bin/anisette-server-aarch64.dbg + bin/anisette-server-aarch64 + bin/anisette-server-aarch64.dbg build-anisette-server-armv7: runs-on: ubuntu-latest @@ -59,14 +59,14 @@ jobs: run: dub build :anisette-server -b release --compiler=arm-linux-gnueabihf-gdc-13 -c "static" - name: Rename - run: mv "${{github.workspace}}/bin/provision_anisette-server" "${{github.workspace}}/bin/anisette-server-armv7" + run: mv "bin/provision_anisette-server" "bin/anisette-server-armv7" - name: Put debug symbols in a separate file - run: eu-strip --strip-debug -f "${{github.workspace}}/bin/anisette-server-armv7.dbg" "${{github.workspace}}/bin/anisette-server-armv7" + run: eu-strip --strip-debug -f "bin/anisette-server-armv7.dbg" "bin/anisette-server-armv7" - uses: actions/upload-artifact@v3 with: name: anisette-server-armv7 path: | - ${{github.workspace}}/bin/anisette-server-armv7 - ${{github.workspace}}/bin/anisette-server-armv7.dbg + bin/anisette-server-armv7 + bin/anisette-server-armv7.dbg diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 33a0dc7..420f480 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -55,15 +55,15 @@ jobs: run: dub build :anisette-server -b release --compiler=i686-linux-gnu-gdc-13 -c "static" - name: Rename - run: mv "${{github.workspace}}/bin/provision_anisette-server" "${{github.workspace}}/bin/anisette-server-i686" + run: mv "bin/provision_anisette-server" "bin/anisette-server-i686" - name: Put debug symbols in a separate file - run: eu-strip --strip-debug -f "${{github.workspace}}/bin/anisette-server-i686.dbg" "${{github.workspace}}/bin/anisette-server-i686" + run: eu-strip --strip-debug -f "bin/anisette-server-i686.dbg" "bin/anisette-server-i686" - uses: actions/upload-artifact@v3 with: name: anisette-server-i686 path: | - ${{github.workspace}}/bin/anisette-server-i686 - ${{github.workspace}}/bin/anisette-server-i686.dbg + bin/anisette-server-i686 + bin/anisette-server-i686.dbg From 01778239beb4cca52d4c896ed022e0ff54dd1cb4 Mon Sep 17 00:00:00 2001 From: Dadoum Date: Sun, 30 Jul 2023 20:24:03 +0200 Subject: [PATCH 17/19] Set-up correctly cross-compilation with latest GDC --- .github/workflows/cmake-cross-compile.yml | 4 ++-- .github/workflows/cmake.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cmake-cross-compile.yml b/.github/workflows/cmake-cross-compile.yml index 78b1f30..73efa4c 100644 --- a/.github/workflows/cmake-cross-compile.yml +++ b/.github/workflows/cmake-cross-compile.yml @@ -17,7 +17,7 @@ jobs: apt-get update apt-get install -y software-properties-common add-apt-repository ppa:ubuntu-toolchain-r/ppa - apt-get install -y git gdc-13-aarch64-linux-gnu dub libz-dev + apt-get install -y git gdc-13-aarch64-linux-gnu dub libz-dev elfutils - uses: actions/checkout@v3 with: @@ -49,7 +49,7 @@ jobs: apt-get update apt-get install -y software-properties-common add-apt-repository ppa:ubuntu-toolchain-r/ppa - apt-get install -y git gdc-13-arm-linux-gnueabihf dub libz-dev + apt-get install -y git gdc-13-arm-linux-gnueabihf dub libz-dev elfutils - uses: actions/checkout@v3 with: diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 420f480..1a54429 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -45,7 +45,7 @@ jobs: apt-get update apt-get install -y software-properties-common add-apt-repository ppa:ubuntu-toolchain-r/ppa - apt-get install -y git gdc-13-i686-linux-gnu dub libz-dev + apt-get install -y git gdc-13-i686-linux-gnu dub libz-dev elfutils - uses: actions/checkout@v3 with: From 03c458f548cb876e7c30a5b9d3a810e95512bb64 Mon Sep 17 00:00:00 2001 From: Dadoum Date: Sun, 30 Jul 2023 20:50:13 +0200 Subject: [PATCH 18/19] Install libraries in a different folder for each architecture --- .github/workflows/cmake.yml | 2 +- anisette_server/app.d | 2 +- dub.selections.json | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 1a54429..78f5dbd 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -1,4 +1,4 @@ -name: x86_64 builds +name: x86 builds on: push diff --git a/anisette_server/app.d b/anisette_server/app.d index 68dedbe..0d3a7c9 100644 --- a/anisette_server/app.d +++ b/anisette_server/app.d @@ -84,7 +84,7 @@ void main(string[] args) { file.mkdirRecurse(configurationPath); } - string libraryPath = configurationPath.buildPath("lib/"); + string libraryPath = configurationPath.buildPath("lib/").buildPath(architectureIdentifier ~ "/"); auto coreADIPath = libraryPath.buildPath("libCoreADI.so"); auto SSCPath = libraryPath.buildPath("libstoreservicescore.so"); diff --git a/dub.selections.json b/dub.selections.json index 779d5b2..fee4e3c 100644 --- a/dub.selections.json +++ b/dub.selections.json @@ -4,6 +4,8 @@ "automem": "0.6.9", "cachetools": "0.4.1", "dxml": "0.4.3", + "handy-httpd": "5.2.1", + "httparsed": "1.2.1", "plist": "~master", "plist-d": {"version":"d494cf3fe79a2bb20583173c0c8cf85ef33b719e","repository":"git+https://github.com/Dadoum/libplist-d.git"}, "requests": "2.0.9", From b8c41d405d203cda9b6b17e529cbb20aeec295c8 Mon Sep 17 00:00:00 2001 From: Dadoum Date: Sun, 30 Jul 2023 21:01:21 +0200 Subject: [PATCH 19/19] Bump version to 2.2.0 --- lib/provision/package.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/provision/package.d b/lib/provision/package.d index d781645..12a196b 100644 --- a/lib/provision/package.d +++ b/lib/provision/package.d @@ -1,4 +1,4 @@ module provision; -enum provisionVersion = "2.1.0"; +enum provisionVersion = "2.2.0"; public import provision.adi;