GithubHelp home page GithubHelp logo

acodervic / tinycr Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kubo39/tinycr

0.0 0.0 0.0 14 KB

The challenge for creating a tiny binary in crystal.

Shell 27.41% Assembly 53.12% Crystal 19.46%

tinycr's Introduction

tinycr

$ ./build.sh
Crystal 0.31.0 [8d4715a59] (2019-09-23)

LLVM: 8.0.0
Default target: x86_64-unknown-linux-gnu

+ crystal build hello.cr --emit obj --prelude=empty --release --verbose
cc "${@}" -o '/home/kubo39/dev/crystal/tinycr/hello'  -rdynamic  -L/home/kubo39/.anyenv/envs/crenv/versions/0.31.0/bin/../lib/crystal/lib -L/usr/lib -L/usr/local/lib _main.o
+ objdump -dr hello.o

hello.o:     file format elf64-x86-64


Disassembly of section .text:

0000000000000000 <__crystal_main>:
   0:	c3                      retq
   1:	90                      nop
   2:	90                      nop
   3:	90                      nop
   4:	90                      nop
   5:	90                      nop
   6:	90                      nop
   7:	90                      nop
   8:	90                      nop
   9:	90                      nop
   a:	90                      nop
   b:	90                      nop
   c:	90                      nop
   d:	90                      nop
   e:	90                      nop
   f:	90                      nop

0000000000000010 <main>:
  10:	b8 01 00 00 00          mov    $0x1,%eax
  15:	bf 01 00 00 00          mov    $0x1,%edi
  1a:	be 08 00 40 00          mov    $0x400008,%esi
  1f:	ba 07 00 00 00          mov    $0x7,%edx
  24:	0f 05                   syscall
  26:	b8 3c 00 00 00          mov    $0x3c,%eax
  2b:	31 ff                   xor    %edi,%edi
  2d:	0f 05                   syscall
  2f:	31 c0                   xor    %eax,%eax
  31:	c3                      retq
+ ld hello.o -o hello --static -nostdlib --gc-sections -T script.ld
+ objcopy -j combined -O binary hello hello.bin
++ nm --format=posix hello
++ grep '\<main\>'
++ awk '{print $3}'
+ ENTRY=0000000000400070
+ nasm -f bin -o tinybin -D entry=0x0000000000400070 elf.s
+ chmod u+x tinybin
+ hexdump -C tinybin
00000000  7f 45 4c 46 02 01 01 00  48 65 6c 6c 6f 21 0a 00  |.ELF....Hello!..|
00000010  02 00 3e 00 01 00 00 00  70 00 40 00 00 00 00 00  |..>.....p.@.....|
00000020  38 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |8...............|
00000030  00 00 00 00 38 00 38 00  01 00 00 00 07 00 00 00  |....8.8.........|
00000040  00 00 00 00 00 00 00 00  00 00 40 00 00 00 00 00  |..........@.....|
00000050  00 00 40 00 00 00 00 00  92 00 00 00 00 00 00 00  |..@.............|
00000060  92 00 00 00 00 00 00 00  00 10 00 00 00 00 00 00  |................|
00000070  b8 01 00 00 00 bf 01 00  00 00 be 08 00 40 00 ba  |.............@..|
00000080  07 00 00 00 0f 05 b8 3c  00 00 00 31 ff 0f 05 31  |.......<...1...1|
00000090  c0 c3                                             |..|
00000092
+ wc -c
146
+ ./tinybin
Hello!

tinycr's People

Contributors

kubo39 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.