[{"data":1,"prerenderedAt":323},["ShallowReactive",2],{"project-8974024":3},{"id":4,"name":5,"line":6,"line_source":7,"title":8,"url":9,"domain":10,"maker":11,"posted_at":12,"year":13,"points":14,"comments":15,"rank_in_year":16,"shown_in_year":17,"top":18,"tier":19,"category":20,"subcategory":21,"format":22,"keywords":23,"reception":29,"sentiment":30,"stance_mix":31,"scored_comments":36,"aspects":37,"strip":44,"post_text":45,"what":46,"said":81,"maker_in_thread":123,"shape":131,"grid":135,"attempts":283,"same_week":284,"maker_shows":39,"maker_hidden":315,"reader_version":316,"card":317},"8974024","rt0","A minimal C runtime for Linux i386 and x86_64 in 87 SLOC of C","title","Show HN: A minimal C runtime for Linux i386 and x86_64 in 87 SLOC of C","https:\u002F\u002Fgithub.com\u002Flpsantil\u002Frt0","github.com","oso2k",1422647445,2015,172,54,110,2565,5,"notable","languages","c runtime startup code","library",[24,25,26,27,28],"c runtime","crt0","static linking","linux syscalls","libc alternative","mixed",0.222,{"positive":32,"neutral":33,"mixed":34,"critical":35},6,7,1,3,17,{"execution":38,"idea":40,"performance":42,"docs":43},{"positive":39,"critical":35},2,{"positive":35,"critical":41},0,{"positive":34,"critical":41},{"positive":41,"critical":41},[18,41,35,41,18,18,35,41,18,35,41,34,34,41,34,41,41,41,41,41,41,41,41,41,41,41,41,41,41,35,41,18,18,41,41,41,41,41,41,35],null,{"problem":47,"audience":45,"pricing":45,"motivation":59,"time_to_build":45,"stack":66,"openness":78,"stage":79,"team_size":80},{"value":48,"source":49,"evidence":50},"Pulling in a full libc for small statically linked Linux programs adds unneeded code and size","inferred",[51,55],{"id":52,"by":53,"text":54},"8974678","kentonv","I like this a lot more than I should. :) Somehow I've always found system calls far more pleasant to use than \"section 3\" C library interfaces, and it makes me sad that I'm…",{"id":56,"by":57,"text":58},"8975661","ChuckMcM","libc is C's \"standard\" library. It has a lot of stuff in it that some programs, especially small single purpose ones, don't need. So when a very simple program is linked into an…",{"value":60,"source":61,"evidence":62},"Dislike of libc API design; wants a minimal startup and syscall layer instead","maker",[63],{"id":64,"by":11,"text":65},"8975835","Thanks for this Ryan. I'll reference this gist too. I remember starting with something like this early on (w\u002Fo your sysdef) but wanted argc, argv, envp and to separate syscall*…",[67,72],{"value":68,"source":61,"evidence":69},"C",[70],{"id":71},"post",{"value":73,"source":49,"evidence":74},"x86 assembly",[75],{"id":76,"by":11,"text":77},"8976417","What do you mean 00_start.c is too hacked on x86_64? As for efficiency of _start, `objdump -d lib\u002F00_start.o` yields ``` 0000000000000000 \u003C_start>: 0: 48 89 e5 mov %rsp,%rbp 3:…","open_source","prototype","solo",{"praise":82,"objections":92,"requests":103,"questions":104,"alternatives":112},[83],{"value":84,"source":85,"evidence":86},"Minimal size and clean approach to startup code","commenter",[87,88],{"id":52,"by":53,"text":54},{"id":89,"by":90,"text":91},"8974192","mmastrac","Nice! As part of some work that I was doing ages ago, I had to build myself a custom libc to statically link executables that would run on Android and WebOS since they are both…",[93],{"value":94,"source":85,"evidence":95},"_start and __init argv\u002Fenvp handling was wrong on x86_64 and i386, now being fixed",[96,100],{"id":97,"by":98,"text":99},"8976355","rian","00_start.c is too hacked on x86_64. it'll work but you're getting a less efficient binary since gcc has to assume _start is called like a normal C function (e.g. it creates a…",{"id":101,"by":98,"text":102},"8977712","it only works because you're skipping over environment variables: ``` char **argv = &stack; char **envp = __environ = argv + ( 1 * sizeof( void* ) ); ``` let's say argv = 0x8,…",[],[105],{"value":106,"source":85,"evidence":107},"What does the inline register asm line do",[108],{"id":109,"by":110,"text":111},"8976224","chappar","I am not familiar with embedded asm. Can someone explan what the following line does? \"register long r10 __asm__( \"r10\" ) = a3\"",[113],{"value":114,"source":85,"evidence":115},"Static linking with gcc -nostdlib and tiny ELF tricks; asmutils; diet libc; musl",[116,120],{"id":117,"by":118,"text":119},"8975209","lunixbochs","For x86_64 Linux only, here's a single-file crt0 (with arbitrary syscalls working from C-land): https:\u002F\u002Fgist.github.com\u002Flunixbochs\u002F462ee21c3353c56b910f Build with `gcc -std=c99…",{"id":121,"by":118,"text":122},"8975589","Pros: - Portable (as long as you don't need dlopen\u002Fdlsym). If you do need to dlopen other libraries, you can run into issues on ARM mobile with mixed soft\u002Fhardfp calling…",{"comments":124,"answered":39,"key":125},9,[126,127,128],{"id":64,"text":65},{"id":76,"text":77},{"id":129,"text":130},"8977580","Point taken. I'll fix up the clobbers and noreturns. And you're right about me having issues with calculating envp. There's multiple examples of envp=argv+argc+1. But when I…",{"commenters":132,"max_depth":33,"maker_replies":124,"first_comment_mins":133,"lifespan_hours":134},35,25,552,[136,138,142,144,148,149,151,155,158,161,165,169,173,175,178,180,182,184,185,186,188,190,193,196,199,202,205,208,210,213,216,219,222,224,227,231,234,236,239,242,245,249,250,253,256,258,262,265,267,269,271,273,275,279],[117,41,18,137,118,41],"maker\u002Fpositive\u002Fexecution",[139,41,41,140,141,41],"8975445","commenter\u002Fneutral\u002Fidea","acqq",[121,41,35,143,118,41],"project\u002Fneutral\u002Fidea",[145,41,35,146,147,41],"8976335","project\u002Fneutral\u002Fperformance","mmozeiko",[64,41,41,137,11,34],[52,34,18,150,53,41],"project\u002Fpositive\u002Fidea",[152,34,35,153,154,41],"8975346","project\u002Fneutral\u002Fexecution","joelwilliamson",[156,34,18,150,157,41],"8975370","userbinator",[159,34,35,146,160,41],"8975509","frozenport",[162,34,41,163,164,41],"8975715","other\u002Fneutral\u002Fnone","fra",[166,34,35,167,168,41],"8975684","project\u002Fmixed\u002Fidea","cbd1984",[170,34,18,171,172,41],"8976122","project\u002Fpositive\u002Fperformance","justin66",[174,34,35,143,141,41],"8976380",[176,34,41,163,177,41],"8976725","maxerickson",[97,39,34,179,98,41],"maker\u002Fcritical\u002Fexecution",[76,39,41,181,11,34],"maker\u002Fneutral\u002Fexecution",[183,39,34,179,98,41],"8976619",[129,39,41,137,11,34],[101,39,34,179,98,41],[187,39,41,137,11,34],"8986038",[89,35,41,189,90,41],"commenter\u002Fpositive\u002Fidea",[191,35,41,163,192,41],"8974349","jeffreyrogers",[194,35,41,163,195,41],"8974370","jacquesm",[197,35,41,163,198,41],"8974752","joosters",[200,35,41,163,201,41],"8974861","coliveira",[203,35,41,163,204,41],"8975549","gjm11",[206,35,41,207,11,34],"8974658","commenter\u002Fneutral\u002Fnone",[209,35,41,207,90,41],"8974909",[211,35,41,163,212,41],"8976189","hyc_symas",[214,215,41,150,11,34],"8974640",4,[217,18,41,163,218,41],"8974785","__gcmurphy",[220,32,41,163,221,41],"8975668","olalonde",[109,33,41,223,110,41],"other\u002Fneutral\u002Fdocs",[225,33,41,223,226,41],"8976948","tjgq",[228,229,41,223,230,41],"8975397",8,"pc2g4d",[232,229,41,223,233,41],"8975403","NhanH",[235,229,41,223,230,41],"8975414",[237,229,41,223,238,41],"8975454","colechristensen",[240,229,41,241,11,34],"8975865","maker\u002Fneutral\u002Fdocs",[243,124,35,153,244,41],"8976133","pjmlp",[246,247,41,163,248,41],"8975645",10,"brudgers",[56,247,18,150,57,41],[251,247,41,252,11,34],"8975851","maker\u002Fneutral\u002Fidea",[254,247,18,137,255,41],"8975902","hornd",[257,247,41,207,11,34],"8975936",[259,260,41,163,261,41],"8977645",11,"101914",[263,260,41,163,264,41],"9001277","DougMerritt",[266,260,41,163,261,41],"9014885",[268,260,41,163,264,41],"9018034",[270,260,41,163,261,41],"9028171",[272,260,41,163,264,41],"9035149",[274,260,41,163,261,41],"9090604",[276,277,41,163,278,41],"8977031",12,"jestinjoy1",[280,277,35,281,282,41],"8977284","project\u002Fneutral\u002Fdocs","cnvogel",[],[285,290,295,300,305,310],{"id":286,"name":287,"points":288,"category":289},"8990584","Matterhorn",298,"web_saas",{"id":291,"name":292,"points":293,"category":294},"8971953","Primrose",203,"dev_tools",{"id":296,"name":297,"points":298,"category":299},"8966928","PolyGen App",108,"creative",{"id":301,"name":302,"points":303,"category":304},"8968786","twitch-analytics",92,"data",{"id":306,"name":307,"points":308,"category":309},"8992543","Leada",81,"learning_science",{"id":311,"name":312,"points":313,"category":314},"8987602","strips",78,"ai",false,"v2",{"id":318,"name":5,"line":6,"ai":315,"cat":20,"year":13,"points":14,"comments":15,"rec":29,"s":319,"top":18,"kw":320,"maker":11,"domain":10,"tier":19,"attempts":41,"strip":321,"url":9,"mix":322,"praise":84,"objection":94,"sub":21},8974024,0.22,[24,25,26,27,28],"5030553053011010000000000000030550000003",[32,33,34,35],1794036527816]