entry-plain.P1pp (956B)
1 # P1/entry-plain.P1pp — executable entry stub for catm-style links. 2 # 3 # P1's program-entry contract (docs/P1.md §Program Entry) delivers 4 # argc in a0 and argv in a1 at :p1_main. Under cc.scm's standard 5 # convention :main has the same shape, so a bare %call(&main) forwards 6 # both unchanged (%call doesn't clobber a0/a1). main builds its own 7 # frame on top. 8 # 9 # %fn size = 0: this stub has no locals and no overflow outgoing args 10 # (only 2 register-passed args). %enter on every arch independently 11 # allocates a 16-byte slot for saved-lr / saved-old-sp on top of the 12 # user-requested size, so a 0-size frame still has the saves it needs. 13 # 14 # Cat this fragment in exactly once at the head of a catm chain to 15 # supply :p1_main, and pair with P1/elf-end.P1pp at the tail. Library 16 # TUs (built with cc.scm --lib=PFX) suppress the auto-emitted entry 17 # stub, which is what makes adding this fragment safe (no collision). 18 19 %fn(p1_main, 0, { 20 %call(&main) 21 })