mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-02 17:28:30 +00:00
Decentralize Python native module linkage
We can now link even smaller Python binaries. For example, the hello.com program in the Python build directory is a compiled linked executable of hello.py which just prints hello world. Using decentralized sections, we can make that binary 1.9mb in size (noting that python.com is 6.3 megs!) This works for nontrivial programs too. For example, say we want an APE binary that's equivalent to python.com -m http.server. Our makefile now builds such a binary using the new launcher and it's only 3.2mb in size since Python sources get turned into ELF objects, which tell our linker that we need things like native hashing algorithm code.
This commit is contained in:
parent
dfa0359b50
commit
559b024e1d
129 changed files with 2798 additions and 13514 deletions
|
@ -13,5 +13,6 @@
|
|||
#define kNtFsctlSetSparse 0x000900C4u
|
||||
#define kNtFsctlSetZeroData 0x000980C8u
|
||||
#define kNtFsctlGetReparsePoint 0x000900a8u
|
||||
#define kNtFsctlSetReparsePoint 0x000900a4u
|
||||
|
||||
#endif /* COSMOPOLITAN_LIBC_NT_ENUM_FSCTL_H_ */
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define COSMOPOLITAN_LIBC_NT_EVENTS_H_
|
||||
#include "libc/nt/struct/msg.h"
|
||||
#include "libc/nt/struct/point.h"
|
||||
#include "libc/nt/struct/securityattributes.h"
|
||||
/* ░░░░
|
||||
▒▒▒░░░▒▒▒▒▒▒▒▓▓▓░
|
||||
▒▒▒▒░░░▒▒▒▒▒▒▓▓▓▓▓▓░
|
||||
|
@ -39,19 +40,28 @@ bool32 GetCursorPos(struct NtPoint *lpPoint);
|
|||
int64_t SendMessage(int64_t hWnd, uint32_t Msg, uint64_t wParam,
|
||||
int64_t lParam);
|
||||
|
||||
#define EVENTLOG_SUCCESS 0x00000000
|
||||
#define EVENTLOG_ERROR_TYPE 0x00000001
|
||||
#define EVENTLOG_WARNING_TYPE 0x00000002
|
||||
#define EVENTLOG_INFORMATION_TYPE 0x00000004
|
||||
#define EVENTLOG_AUDIT_SUCCESS 0x00000008
|
||||
#define EVENTLOG_AUDIT_FAILURE 0x00000010
|
||||
#define EVENTLOG_SUCCESS 0x00000000
|
||||
#define EVENTLOG_ERROR_TYPE 0x00000001
|
||||
#define EVENTLOG_WARNING_TYPE 0x00000002
|
||||
#define EVENTLOG_INFORMATION_TYPE 0x00000004
|
||||
#define EVENTLOG_AUDIT_SUCCESS 0x00000008
|
||||
#define EVENTLOG_AUDIT_FAILURE 0x00000010
|
||||
|
||||
int32_t ReportEventA(int64_t handle, uint16_t wType, uint16_t wCategory,
|
||||
uint32_t dwEventID, const char *lpUserId, uint16_t wNumStrings,
|
||||
uint32_t dwDataSize, const char **lpStrings, void **lpRawData);
|
||||
int64_t RegisterEventSourceA(const char *lpUNCServerName, const char *lpSourceName);
|
||||
uint32_t dwEventID, const char *lpUserId,
|
||||
uint16_t wNumStrings, uint32_t dwDataSize,
|
||||
const char **lpStrings, void **lpRawData);
|
||||
int64_t RegisterEventSourceA(const char *lpUNCServerName,
|
||||
const char *lpSourceName);
|
||||
int32_t DeregisterEventSource(uint64_t handle);
|
||||
|
||||
int64_t CreateEvent(struct NtSecurityAttributes *lpEventAttributes,
|
||||
bool32 bManualReset, bool32 bInitialState,
|
||||
const char16_t *lpName);
|
||||
int64_t CreateEventEx(struct NtSecurityAttributes *lpEventAttributes,
|
||||
const char16_t *lpName, uint32_t dwFlags,
|
||||
uint32_t dwDesiredAccess);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_NT_EVENTS_H_ */
|
||||
|
|
|
@ -211,6 +211,12 @@ uint32_t GetFinalPathNameByHandle(int64_t hFile, char16_t *out_path,
|
|||
uint32_t GetFullPathName(const char16_t *lpFileName, uint32_t nBufferLength,
|
||||
char16_t *lpBuffer, char16_t **lpFilePart);
|
||||
|
||||
bool32 GetOverlappedResult(int64_t hFile, struct NtOverlapped *lpOverlapped,
|
||||
uint32_t *lpNumberOfBytesTransferred, bool32 bWait);
|
||||
bool32 GetOverlappedResultEx(int64_t hFile, struct NtOverlapped *lpOverlapped,
|
||||
uint32_t *lpNumberOfBytesTransferred,
|
||||
uint32_t dwMilliseconds, bool32 bAlertable);
|
||||
|
||||
#if ShouldUseMsabiAttribute()
|
||||
#include "libc/nt/thunk/files.inc"
|
||||
#endif /* ShouldUseMsabiAttribute() */
|
||||
|
|
|
@ -68,19 +68,19 @@ bool32 CallNamedPipe(const char16_t *lpNamedPipeName, void *lpInBuffer,
|
|||
uint32_t nOutBufferSize, uint32_t *lpBytesRead,
|
||||
uint32_t nTimeOut);
|
||||
|
||||
bool32 ConnectNamedPipe(int64_t *hNamedPipe, struct NtOverlapped *lpOverlapped);
|
||||
bool32 ConnectNamedPipe(int64_t hNamedPipe, struct NtOverlapped *lpOverlapped);
|
||||
bool32 WaitNamedPipe(const char16_t *lpNamedPipeName, uint32_t nTimeOut);
|
||||
bool32 DisconnectNamedPipe(int64_t *hNamedPipe);
|
||||
bool32 DisconnectNamedPipe(int64_t hNamedPipe);
|
||||
|
||||
bool32 SetNamedPipeHandleState(int64_t *hNamedPipe, uint32_t *lpMode,
|
||||
bool32 SetNamedPipeHandleState(int64_t hNamedPipe, uint32_t *lpMode,
|
||||
uint32_t *lpMaxCollectionCount,
|
||||
uint32_t *lpCollectDataTimeout);
|
||||
|
||||
bool32 PeekNamedPipe(int64_t *hNamedPipe, void *lpBuffer, uint32_t nBufferSize,
|
||||
bool32 PeekNamedPipe(int64_t hNamedPipe, void *lpBuffer, uint32_t nBufferSize,
|
||||
uint32_t *lpBytesRead, uint32_t *lpTotalBytesAvail,
|
||||
uint32_t *lpBytesLeftThisMessage);
|
||||
|
||||
bool32 TransactNamedPipe(int64_t *hNamedPipe, void *lpInBuffer,
|
||||
bool32 TransactNamedPipe(int64_t hNamedPipe, void *lpInBuffer,
|
||||
uint32_t nInBufferSize, void *lpOutBuffer,
|
||||
uint32_t nOutBufferSize, uint32_t *lpBytesRead,
|
||||
struct NtOverlapped *lpOverlapped);
|
||||
|
|
|
@ -1,2 +1,12 @@
|
|||
.include "o/libc/nt/codegen.inc"
|
||||
.imp kernel32,__imp_CreateEventA,CreateEventA,0
|
||||
|
||||
.text.windows
|
||||
CreateEventA:
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
mov __imp_CreateEventA(%rip),%rax
|
||||
jmp __sysv2nt
|
||||
.endfn CreateEventA,globl
|
||||
.previous
|
||||
|
|
|
@ -1,2 +1,12 @@
|
|||
.include "o/libc/nt/codegen.inc"
|
||||
.imp kernel32,__imp_CreateEventExA,CreateEventExA,0
|
||||
|
||||
.text.windows
|
||||
CreateEventExA:
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
mov __imp_CreateEventExA(%rip),%rax
|
||||
jmp __sysv2nt
|
||||
.endfn CreateEventExA,globl
|
||||
.previous
|
||||
|
|
|
@ -1,2 +1,12 @@
|
|||
.include "o/libc/nt/codegen.inc"
|
||||
.imp kernel32,__imp_CreateEventExW,CreateEventExW,0
|
||||
|
||||
.text.windows
|
||||
CreateEventEx:
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
mov __imp_CreateEventExW(%rip),%rax
|
||||
jmp __sysv2nt
|
||||
.endfn CreateEventEx,globl
|
||||
.previous
|
||||
|
|
|
@ -1,2 +1,12 @@
|
|||
.include "o/libc/nt/codegen.inc"
|
||||
.imp kernel32,__imp_CreateEventW,CreateEventW,0
|
||||
|
||||
.text.windows
|
||||
CreateEvent:
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
mov __imp_CreateEventW(%rip),%rax
|
||||
jmp __sysv2nt
|
||||
.endfn CreateEvent,globl
|
||||
.previous
|
||||
|
|
|
@ -1,2 +1,12 @@
|
|||
.include "o/libc/nt/codegen.inc"
|
||||
.imp kernel32,__imp_GetOverlappedResult,GetOverlappedResult,0
|
||||
|
||||
.text.windows
|
||||
GetOverlappedResult:
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
mov __imp_GetOverlappedResult(%rip),%rax
|
||||
jmp __sysv2nt
|
||||
.endfn GetOverlappedResult,globl
|
||||
.previous
|
||||
|
|
|
@ -1,2 +1,12 @@
|
|||
.include "o/libc/nt/codegen.inc"
|
||||
.imp kernel32,__imp_GetOverlappedResultEx,GetOverlappedResultEx,0
|
||||
|
||||
.text.windows
|
||||
GetOverlappedResultEx:
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
mov __imp_GetOverlappedResultEx(%rip),%rax
|
||||
jmp __sysv2nt6
|
||||
.endfn GetOverlappedResultEx,globl
|
||||
.previous
|
||||
|
|
|
@ -587,10 +587,10 @@ imp 'CreateEllipticRgnIndirect' CreateEllipticRgnIndirect gdi32 1074
|
|||
imp 'CreateEnclave' CreateEnclave KernelBase 180
|
||||
imp 'CreateEnhMetaFileA' CreateEnhMetaFileA gdi32 1075
|
||||
imp 'CreateEnhMetaFile' CreateEnhMetaFileW gdi32 1076
|
||||
imp 'CreateEventA' CreateEventA kernel32 0 # KernelBase
|
||||
imp 'CreateEventExA' CreateEventExA kernel32 0 # KernelBase
|
||||
imp 'CreateEventEx' CreateEventExW kernel32 0 # KernelBase
|
||||
imp 'CreateEvent' CreateEventW kernel32 0 # KernelBase
|
||||
imp 'CreateEventA' CreateEventA kernel32 0 4 # KernelBase
|
||||
imp 'CreateEventExA' CreateEventExA kernel32 0 4 # KernelBase
|
||||
imp 'CreateEventEx' CreateEventExW kernel32 0 4 # KernelBase
|
||||
imp 'CreateEvent' CreateEventW kernel32 0 4 # KernelBase
|
||||
imp 'CreateFiber' CreateFiber kernel32 0 # KernelBase
|
||||
imp 'CreateFiberEx' CreateFiberEx kernel32 0 # KernelBase
|
||||
imp 'CreateFile' CreateFileW kernel32 0 7 # KernelBase
|
||||
|
@ -2384,8 +2384,8 @@ imp 'GetOsSafeBootMode' GetOsSafeBootMode KernelBase 626
|
|||
imp 'GetOutlineTextMetricsA' GetOutlineTextMetricsA gdi32 1685
|
||||
imp 'GetOutlineTextMetrics' GetOutlineTextMetricsW gdi32 1686
|
||||
imp 'GetOverlappedAccessResults' GetOverlappedAccessResults advapi32 1348
|
||||
imp 'GetOverlappedResult' GetOverlappedResult kernel32 0 # KernelBase
|
||||
imp 'GetOverlappedResultEx' GetOverlappedResultEx kernel32 0 # KernelBase
|
||||
imp 'GetOverlappedResult' GetOverlappedResult kernel32 0 4 # KernelBase
|
||||
imp 'GetOverlappedResultEx' GetOverlappedResultEx kernel32 0 5 # KernelBase
|
||||
imp 'GetPackageApplicationContext' GetPackageApplicationContext KernelBase 629
|
||||
imp 'GetPackageApplicationIds' GetPackageApplicationIds kernel32 0 # KernelBase
|
||||
imp 'GetPackageApplicationProperty' GetPackageApplicationProperty KernelBase 631
|
||||
|
|
|
@ -55,7 +55,7 @@ bool32 GetThreadIOPendingFlag(int64_t hThread, bool32 *lpIOIsPending);
|
|||
|
||||
bool32 CancelSynchronousIo(int64_t hThread);
|
||||
bool32 CancelIo(int64_t hFile);
|
||||
bool32 CancelIoEx(int64_t hFile, struct NtOverlapped opt_lpOverlapped);
|
||||
bool32 CancelIoEx(int64_t hFile, struct NtOverlapped *opt_lpOverlapped);
|
||||
|
||||
#if ShouldUseMsabiAttribute()
|
||||
#include "libc/nt/thunk/thread.inc"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue