Add scouts honor escape hatch for source embedding

This commit is contained in:
Justine Tunney 2020-06-15 19:01:28 -07:00
parent c91b3c5006
commit b4269930f7
547 changed files with 1516 additions and 944 deletions

View file

@ -18,7 +18,7 @@
02110-1301 USA
*/
#include "libc/macros.h"
.yoink __FILE__
.source __FILE__
.p2align 4
minmax_vector:

View file

@ -18,7 +18,7 @@
02110-1301 USA
*/
#include "libc/macros.h"
.yoink __FILE__
.source __FILE__
.init.start 400,_init_g_ntstartupinfo
ezlea g_ntstartupinfo,cx

View file

@ -18,7 +18,7 @@
02110-1301 USA
*/
#include "libc/macros.h"
.yoink __FILE__
.source __FILE__
.init.start 400,_init_g_ntsysteminfo
ezlea g_ntsysteminfo,cx

View file

@ -18,7 +18,7 @@
02110-1301 USA
*/
#include "libc/macros.h"
.yoink __FILE__
.source __FILE__
/ Obtains WIN32 magic path, e.g. GetTempPathA.
/

View file

@ -26,6 +26,7 @@
#include "libc/nexgen32e/hascharacter.h"
#include "libc/runtime/runtime.h"
#include "libc/str/str.h"
#include "libc/str/tpdecode.h"
#include "libc/sysv/consts/fileno.h"
#include "libc/sysv/errfuns.h"

View file

@ -23,6 +23,7 @@
#include "libc/macros.h"
#include "libc/mem/mem.h"
#include "libc/str/str.h"
#include "libc/str/tpdecode.h"
#include "libc/sysv/errfuns.h"
/**

View file

@ -40,4 +40,4 @@ kTmpPath:
call __getntsyspath
.init.end 300,_init_kTmpPath
.yoink __FILE__
.source __FILE__

View file

@ -23,6 +23,7 @@
#include "libc/calls/internal.h"
#include "libc/conv/conv.h"
#include "libc/str/str.h"
#include "libc/str/tpdecode.h"
#include "libc/sysv/errfuns.h"
/**

View file

@ -18,7 +18,7 @@
02110-1301 USA
*/
#include "libc/macros.h"
.yoink __FILE__
.source __FILE__
.init.start 300,_init_onntconsoleevent
ezlea onntconsoleevent$nt,cx

View file

@ -18,7 +18,7 @@
02110-1301 USA
*/
#include "libc/macros.h"
.yoink __FILE__
.source __FILE__
.init.start 300,_init_onwincrash
pushpop 1,%rcx

View file

@ -19,7 +19,7 @@
*/
#include "libc/dce.h"
#include "libc/macros.h"
.yoink __FILE__
.source __FILE__
/ Creates file descriptors for IPC.
/

View file

@ -18,7 +18,7 @@
02110-1301 USA
*/
#include "libc/macros.h"
.yoink __FILE__
.source __FILE__
/ Sets effective group ID.
/

View file

@ -18,7 +18,7 @@
02110-1301 USA
*/
#include "libc/macros.h"
.yoink __FILE__
.source __FILE__
/ Sets effective user ID.
/

View file

@ -19,7 +19,7 @@
*/
#include "libc/calls/internal.h"
#include "libc/macros.h"
.yoink __FILE__
.source __FILE__
/ System Five signal handler.
/

View file

@ -18,7 +18,7 @@
02110-1301 USA
*/
#include "libc/macros.h"
.yoink __FILE__
.source __FILE__
/ Directly calls ftruncate() impl on host o/s if available.
ftruncate$sysv:

View file

@ -18,7 +18,7 @@
02110-1301 USA
*/
#include "libc/macros.h"
.yoink __FILE__
.source __FILE__
/ Calls GetTempPathA() w/ different API.
/

View file

@ -19,7 +19,7 @@
*/
#include "libc/dce.h"
#include "libc/macros.h"
.yoink __FILE__
.source __FILE__
/ Directly calls lseek() impl on host o/s if available.
lseek$sysv:

View file

@ -18,7 +18,7 @@
02110-1301 USA
*/
#include "libc/macros.h"
.yoink __FILE__
.source __FILE__
/ Directly calls mmap() on system five host o/s.
mmap$sysv:

View file

@ -19,7 +19,7 @@
*/
#include "libc/macros.h"
.text.windows
.yoink __FILE__
.source __FILE__
onntconsoleevent$nt:
ezlea onntconsoleevent,ax

View file

@ -19,7 +19,7 @@
*/
#include "libc/macros.h"
.text.windows
.yoink __FILE__
.source __FILE__
onwincrash$nt:
ezlea onwincrash,ax

View file

@ -18,7 +18,7 @@
02110-1301 USA
*/
#include "libc/macros.h"
.yoink __FILE__
.source __FILE__
/ Directly calls pread() impl on host o/s if available.
pread$sysv:

View file

@ -18,7 +18,7 @@
02110-1301 USA
*/
#include "libc/macros.h"
.yoink __FILE__
.source __FILE__
/ Directly calls preadv() impl on host o/s if available.
preadv$sysv:

View file

@ -18,7 +18,7 @@
02110-1301 USA
*/
#include "libc/macros.h"
.yoink __FILE__
.source __FILE__
/ Directly calls pwrite() impl on host o/s if available.
pwrite$sysv:

View file

@ -18,7 +18,7 @@
02110-1301 USA
*/
#include "libc/macros.h"
.yoink __FILE__
.source __FILE__
/ Directly calls pwritev() impl on host o/s if available.
pwritev$sysv:

View file

@ -18,7 +18,7 @@
02110-1301 USA
*/
#include "libc/macros.h"
.yoink __FILE__
.source __FILE__
/ Directly calls truncate() impl on host o/s if available.
truncate$sysv:

View file

@ -22,7 +22,7 @@
#include "libc/notice.inc"
#include "libc/runtime/internal.h"
.section .start,"ax",@progbits
.yoink __FILE__
.source __FILE__
/ System Five userspace program entrypoint.
/

View file

@ -19,7 +19,7 @@
*/
#include "libc/notice.inc"
#include "libc/macros.h"
.yoink __FILE__
.source __FILE__
/ Embeds ASCII names for errno constants into binary.
/

View file

@ -26,6 +26,8 @@
#include "libc/nexgen32e/tinystrlen.h"
#include "libc/str/internal.h"
#include "libc/str/str.h"
#include "libc/str/tpdecode.h"
#include "libc/str/tpencode.h"
#include "libc/unicode/unicode.h"
forceinline unsigned long tpiencode(wint_t wc) {

View file

@ -983,7 +983,7 @@ typedef uint64_t uintmax_t;
/**
* Pulls another module, by symbol, into linkage.
* The nop itself is discarded by the linker.
* @note nop is discarded by ape/ape.lds
*/
#define YOINK(SYMBOL) \
do { \
@ -996,11 +996,30 @@ typedef uint64_t uintmax_t;
: "X"(SYMBOL)); \
} while (0)
/**
* Pulls another module into linkage from top-level scope.
* @note nop is discarded by ape/ape.lds
*/
#define STATIC_YOINK(SYMBOLSTR) \
asm(".pushsection .yoink\n\tnop\t\"" SYMBOLSTR "\"\n\t.popsection")
/**
* Pulls source file into ZIP portion of binary.
* @see build/rules.mk which defines the wildcard build rule %.zip.o
*/
#ifndef IM_FEELING_NAUGHTY
#define STATIC_YOINK_SOURCE(PATH) STATIC_YOINK(PATH)
#else
#define STATIC_YOINK_SOURCE(PATH)
#endif
/**
* Pulls source code of object being compiled.
* @note automates better compliance with spirit of gpl terms
* @note headers need to call STATIC_YOINK_SOURCE() manually
*/
#ifdef __SAUCE__
STATIC_YOINK(__SAUCE__);
STATIC_YOINK_SOURCE(__SAUCE__); /* see build/definitions.mk */
#endif
#ifndef __cplusplus

View file

@ -19,7 +19,7 @@
*/
#include "libc/log/log.h"
#include "libc/macros.h"
.yoink __FILE__
.source __FILE__
.bss
.align 4

View file

@ -18,7 +18,7 @@
02110-1301 USA
*/
#include "libc/macros.h"
.yoink __FILE__
.source __FILE__
/ These function names make it a bit more obvious which signal
/ caused the crash, particularly in the GDB GUI. They're coded

View file

@ -19,7 +19,7 @@
*/
#include "libc/macros.h"
.text.unlikely
.yoink __FILE__
.source __FILE__
/ Code-size saving thunk for CHECK_EQ() in NDEBUG mode.
__check_fail_eq:

View file

@ -19,7 +19,7 @@
*/
#include "libc/macros.h"
.text.unlikely
.yoink __FILE__
.source __FILE__
/ Code-size saving thunk for CHECK_GE() in NDEBUG mode.
__check_fail_ge:

View file

@ -19,7 +19,7 @@
*/
#include "libc/macros.h"
.text.unlikely
.yoink __FILE__
.source __FILE__
/ Code-size saving thunk for CHECK_GT() in NDEBUG mode.
__check_fail_gt:

View file

@ -19,7 +19,7 @@
*/
#include "libc/macros.h"
.text.unlikely
.yoink __FILE__
.source __FILE__
/ Code-size saving thunk for CHECK_LE() in NDEBUG mode.
__check_fail_le:

View file

@ -19,7 +19,7 @@
*/
#include "libc/macros.h"
.text.unlikely
.yoink __FILE__
.source __FILE__
/ Code-size saving thunk for CHECK_LT() in NDEBUG mode.
__check_fail_lt:

View file

@ -18,7 +18,7 @@
02110-1301 USA
*/
#include "libc/macros.h"
.yoink __FILE__
.source __FILE__
__check_fail_ndebug:
push %rbp

View file

@ -19,7 +19,7 @@
*/
#include "libc/macros.h"
.text.unlikely
.yoink __FILE__
.source __FILE__
/ Code-size saving thunk for CHECK_NE() in NDEBUG mode.
__check_fail_ne:

View file

@ -19,7 +19,7 @@
*/
#include "libc/macros.h"
.text.unlikely
.yoink __FILE__
.source __FILE__
__ubsan_default_options:
ret

View file

@ -87,6 +87,17 @@
ret
.endm
/ Pulls source code file into ZIP portion of binary.
/
/ @param symbol is quoted path relative to root e.g. __FILE__
/ @see see libc/zipos/zipcentraldir.S
/ @see see libc/integral/c.inc
.macro .source symbol:req
#ifndef IM_FEELING_NAUGHTY
.yoink "\symbol"
#endif
.endm
/ Inserts profiling hook in prologue if cc wants it.
/
/ Cosmopolitan does this in a slightly different way from normal

View file

@ -35,4 +35,4 @@ fesetround:
pop %rcx
ret
.endfn fesetround,globl,hidden
.yoink __FILE__
.source __FILE__

View file

@ -17,7 +17,7 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/macros.inc"
#include "libc/macros.h"
feraiseexcept:
and $0x3f,%edi
@ -27,4 +27,4 @@ feraiseexcept:
xor %eax,%eax
ret
.endfn feraiseexcept,globl
.yoink __FILE__
.source __FILE__

View file

@ -36,4 +36,4 @@ fesetenv:
add $40,%rsp
ret
.endfn fesetenv,globl
.yoink __FILE__
.source __FILE__

View file

@ -29,4 +29,4 @@ fetestexcept:
and %edi,%eax
ret
.endfn fetestexcept,globl
.yoink __FILE__
.source __FILE__

View file

@ -18,7 +18,7 @@
02110-1301 USA
*/
#include "libc/macros.h"
.yoink __FILE__
.source __FILE__
.initbss 800,_init_calloc
hook$calloc:

View file

@ -19,7 +19,7 @@
*/
#include "libc/macros.h"
#include "libc/notice.inc"
.yoink __FILE__
.source __FILE__
/ Allocates n * itemsize bytes, initialized to zero.
/

View file

@ -18,7 +18,7 @@
02110-1301 USA
*/
#include "libc/macros.h"
.yoink __FILE__
.source __FILE__
/ Frees memory the C++ way.
/

View file

@ -18,7 +18,7 @@
02110-1301 USA
*/
#include "libc/macros.h"
.yoink __FILE__
.source __FILE__
.initbss 800,_init_free
hook$free:

View file

@ -18,7 +18,7 @@
02110-1301 USA
*/
#include "libc/macros.h"
.yoink __FILE__
.source __FILE__
/ Free memory returned by malloc() & co.
/

View file

@ -18,7 +18,7 @@
02110-1301 USA
*/
#include "libc/macros.h"
.yoink __FILE__
.source __FILE__
/ Allocates memory the C++ way.
/

View file

@ -18,7 +18,7 @@
02110-1301 USA
*/
#include "libc/macros.h"
.yoink __FILE__
.source __FILE__
.initbss 800,_init_malloc
hook$malloc:

View file

@ -18,7 +18,7 @@
02110-1301 USA
*/
#include "libc/macros.h"
.yoink __FILE__
.source __FILE__
/ Allocates uninitialized memory.
/

View file

@ -19,7 +19,7 @@
*/
#include "libc/macros.h"
#include "libc/notice.inc"
.yoink __FILE__
.source __FILE__
/ Returns the number of bytes you can actually use in
/ an allocated chunk, which may be more than you requested

View file

@ -18,7 +18,7 @@
02110-1301 USA
*/
#include "libc/macros.h"
.yoink __FILE__
.source __FILE__
/ Allocates aligned memory the C++ way.
/

View file

@ -18,7 +18,7 @@
02110-1301 USA
*/
#include "libc/macros.h"
.yoink __FILE__
.source __FILE__
.initbss 800,_init_memalign
hook$memalign:

View file

@ -19,7 +19,7 @@
*/
#include "libc/macros.h"
#include "libc/notice.inc"
.yoink __FILE__
.source __FILE__
/ Allocates aligned memory.
/

View file

@ -18,7 +18,7 @@
02110-1301 USA
*/
#include "libc/macros.h"
.yoink __FILE__
.source __FILE__
/ Allocates aligned memory the POSIX way.
/

View file

@ -19,7 +19,7 @@
*/
#include "libc/macros.h"
#include "libc/notice.inc"
.yoink __FILE__
.source __FILE__
/ Equivalent to valloc(minimum-page-that-holds(n)), that is,
/ round up n to nearest PAGESIZE.

View file

@ -18,7 +18,7 @@
02110-1301 USA
*/
#include "libc/macros.h"
.yoink __FILE__
.source __FILE__
.initbss 800,_init_realloc
hook$realloc:

View file

@ -19,7 +19,7 @@
*/
#include "libc/macros.h"
#include "libc/notice.inc"
.yoink __FILE__
.source __FILE__
/ Allocates / resizes / frees memory, e.g.
/

View file

@ -19,7 +19,7 @@
*/
#include "libc/macros.h"
#include "libc/notice.inc"
.yoink __FILE__
.source __FILE__
/ Resizes the space allocated for p to size n, only if this can be
/ done without moving p (i.e., only if there is adjacent space

View file

@ -19,7 +19,7 @@
*/
#include "libc/macros.h"
#include "libc/notice.inc"
.yoink __FILE__
.source __FILE__
/ Equivalent to memalign(PAGESIZE, n).
/

View file

@ -36,4 +36,4 @@ __atomic_is_lock_free:
cmovnz %ecx,%eax
.leafepilogue
.endfn __atomic_is_lock_free,globl,hidden
.yoink __FILE__
.source __FILE__

View file

@ -30,4 +30,4 @@
/ @return 0 if equal or nonzero
bcmp: jmp *hook$memcmp(%rip)
.endfn bcmp,globl
.yoink __FILE__
.source __FILE__

View file

@ -28,5 +28,5 @@
/ @param rdx is number of bytes
bcopy: jmp memmove
.endfn bcopy,globl
.yoink __FILE__
.yoink __FILE__
.source __FILE__
.source __FILE__

View file

@ -40,4 +40,4 @@ bsf: .leafprologue
bsf %edi,%eax
.leafepilogue
.endfn bsf,globl
.yoink __FILE__
.source __FILE__

View file

@ -41,4 +41,4 @@ bsfl: .leafprologue
.leafepilogue
.endfn bsfl,globl
.alias bsfl,bsfll
.yoink __FILE__
.source __FILE__

View file

@ -40,4 +40,4 @@ bsr: .leafprologue
bsr %edi,%eax
.leafepilogue
.endfn bsr,globl
.yoink __FILE__
.source __FILE__

View file

@ -41,4 +41,4 @@ bsrl: .leafprologue
.leafepilogue
.endfn bsrl,globl
.alias bsrl,bsrll
.yoink __FILE__
.source __FILE__

View file

@ -44,4 +44,4 @@ bsrmax: .leafprologue
2: add $64,%eax
jmp 1b
.endfn bsrmax,globl
.yoink __FILE__
.source __FILE__

View file

@ -32,4 +32,4 @@ bzero: mov %rsi,%rdx
xor %esi,%esi
jmp _memset
.endfn bzero,globl
.yoink __FILE__
.source __FILE__

View file

@ -130,4 +130,4 @@ cescapectab:
add $(8-.Lcescapectab.ro.size%8),%rsi
.endif
.init.end 300,_init_cescapec
.yoink __FILE__
.source __FILE__

View file

@ -32,4 +32,4 @@ clamp1: .leafprologue
.Lmax: .rept 4
.float 0.99609375
.endr
.yoink __FILE__
.source __FILE__

View file

@ -40,4 +40,4 @@ cmpsb: .leafprologue
.Lneg1: .long -1
.endobj .Lneg1
.previous
.yoink __FILE__
.source __FILE__

View file

@ -40,4 +40,4 @@ cmpsl: .leafprologue
.Lneg1: .long -1
.endobj .Lneg1
.previous
.yoink __FILE__
.source __FILE__

View file

@ -40,4 +40,4 @@ cmpsq: .leafprologue
.Lneg1: .long -1
.endobj .Lneg1
.previous
.yoink __FILE__
.source __FILE__

View file

@ -40,4 +40,4 @@ cmpsw: .leafprologue
.Lneg1: .long -1
.endobj .Lneg1
.previous
.yoink __FILE__
.source __FILE__

View file

@ -40,4 +40,4 @@ cmpub: .leafprologue
.Lneg1: .long -1
.endobj .Lneg1
.previous
.yoink __FILE__
.source __FILE__

View file

@ -40,4 +40,4 @@ cmpul: .leafprologue
.Lneg1: .long -1
.endobj .Lneg1
.previous
.yoink __FILE__
.source __FILE__

View file

@ -40,4 +40,4 @@ cmpuq: .leafprologue
.Lneg1: .long -1
.endobj .Lneg1
.previous
.yoink __FILE__
.source __FILE__

View file

@ -40,4 +40,4 @@ cmpuw: .leafprologue
.Lneg1: .long -1
.endobj .Lneg1
.previous
.yoink __FILE__
.source __FILE__

View file

@ -260,4 +260,4 @@ crc32$pclmul:
4194304 7.025 7.059 7.030 462
8388607 7.082 6.980 6.997 464
8388608 7.051 6.985 6.999 464 */
.yoink __FILE__
.source __FILE__

View file

@ -27,4 +27,4 @@
crc32: movslq %edx,%rdx
jmp crc32_z
.endfn crc32,globl
.yoink __FILE__
.source __FILE__

View file

@ -43,4 +43,4 @@ crc32c: .quad 0
#endif
stosq
.init.end 300,_init_crc32c
.yoink __FILE__
.source __FILE__

View file

@ -69,4 +69,4 @@ crc32init:
leave
ret
.endfn crc32init,globl
.yoink __FILE__
.source __FILE__

View file

@ -98,4 +98,4 @@ ctypep: pop %rsi
and %esi,%eax
ret
.endfn ctypep
.yoink __FILE__
.source __FILE__

View file

@ -116,4 +116,4 @@ div10: .leafprologue
pop %rbx
.leafepilogue
.endfn div10,globl,hidden
.yoink __FILE__
.source __FILE__

View file

@ -29,4 +29,4 @@ div1000000000int64:
jmp tinydivsi
.globl tinydivsi
.endfn div1000000000int64,globl
.yoink __FILE__
.source __FILE__

View file

@ -28,4 +28,4 @@ div1000000int64:
movabs $0x431bde82d7b634db,%rdx
jmp tinydivsi
.endfn div1000000int64,globl
.yoink __FILE__
.source __FILE__

View file

@ -28,4 +28,4 @@ div1000int64:
movabs $0x20c49ba5e353f7cf,%rdx
jmp tinydivsi
.endfn div1000int64,globl
.yoink __FILE__
.source __FILE__

View file

@ -28,4 +28,4 @@ div10int64:
movabs $0x6666666666666667,%rdx
jmp tinydivsi
.endfn div10int64,globl
.yoink __FILE__
.source __FILE__

View file

@ -30,4 +30,4 @@ environ:.quad 0
.init.start 300,_init_environ
mov %r14,environ(%rip)
.init.end 300,_init_environ
.yoink __FILE__
.source __FILE__

View file

@ -47,4 +47,4 @@ explicit_bzero:
xorps %xmm5,%xmm5
.leafepilogue
.endfn explicit_bzero,globl
.yoink __FILE__
.source __FILE__

View file

@ -44,4 +44,4 @@ ffs: .leafprologue
inc %eax
.leafepilogue
.endfn ffs,globl
.yoink __FILE__
.source __FILE__

View file

@ -45,4 +45,4 @@ ffsl: .leafprologue
.leafepilogue
.endfn ffsl,globl
.alias ffsl,ffsll
.yoink __FILE__
.source __FILE__

View file

@ -29,4 +29,4 @@ g_argv: .quad 0
mov %r13,%rax
stosq
.init.end 300,_init_g_argv
.yoink __FILE__
.source __FILE__

View file

@ -28,4 +28,4 @@ g_auxv: .quad 0
mov %r15,%rax
stosq
.init.end 300,_init_g_auxv
.yoink __FILE__
.source __FILE__

View file

@ -20,4 +20,4 @@
#include "libc/macros.h"
.comm g_runstate,4
.yoink __FILE__
.source __FILE__

View file

@ -88,4 +88,4 @@ __garbage:
stosq
pop %rdi
.init.end 100,_init_garbage
.yoink __FILE__
.source __FILE__

View file

@ -59,4 +59,4 @@ gclongjmp:
pop %rdi
jmp 0b
.endfn gclongjmp,globl
.yoink __FILE__
.source __FILE__

Some files were not shown because too many files have changed in this diff Show more