https://github.com/0xade1a1de/assemblyline
A C library and binary for generating machine code of x86_64 assembly language and executing on the fly without invoking another compiler, assembler or linker.
Science Score: 36.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
✓Committers with academic emails
2 of 9 committers (22.2%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (15.0%) to scientific vocabulary
Keywords
Repository
A C library and binary for generating machine code of x86_64 assembly language and executing on the fly without invoking another compiler, assembler or linker.
Basic Info
- Host: GitHub
- Owner: 0xADE1A1DE
- License: apache-2.0
- Language: Assembly
- Default Branch: main
- Homepage: https://0xade1a1de.github.io/AssemblyLine
- Size: 507 KB
Statistics
- Stars: 193
- Watchers: 5
- Forks: 29
- Open Issues: 3
- Releases: 18
Topics
Metadata Files
README.md
AssemblyLine
An ultra-lightweight C library and binary for generating machine code of x86_64 assembly language and executing on the fly without invoking another compiler, assembler or linker.
- Easy to use C library
libassemblyline. - Print or run assembly code with our cli tool
asmline(see tools/README.md) - Support for MMX, SSE2, AVX, and AVX2 instruction sets.
- Supports Scaled Index addressing mode (SIB) with the following syntax:
[base + index*scale +\- offset],[base + scale*index +\- offset]
[scale*index +\- offset],[constant] - Supports pointer: byte, word, dword, and qword
- Supports multi-length nop instructions (by using
nop{2..11}as the instruction)
see test/nop.asm for more information - Supports jump instructions without labels: short, long, and far
- Memory chunk alignment by using nop-padding.
- Command line completion (zsh, bash) for
asmline - Different modes for assembling instructions.
NASM: binary output will match that of nasm as closely as possible (default for SIB).
STRICT: binary output will be in an 'as is' state in respect to the instruction.
SMART: instructions could be manipulated to ensure binary output matches nasm (default).
See tools/README.md Different Modes of Assembly section for more information man-pages forasmlineandlibassemblyline- High instruction compatibility and easy to add new instructions (see src/README.md, and /src/instructions.c for a list of supported instructions.
How to Install
We have packages in the AUR.
Otherwise clone this repo or get a stable release tarball.
bash
$ ./autogen.sh # when `git clone`d
$ ./configure && \
make && \
sudo make install
Usage
$ cc your_program.c -lassemblylineto use the library and compile a C program using assemblyline$ echo -e "mov rax, 0xADE1A1DE\nret" | asmline -rto use our asmline-cli tool
(Will print 'the value is 0xade1a1de')
Jumpstart library
Full code example:
```c
include // all assemblyline functions
include // uint8_t
include // printf
include // mmap
int main() { const int buffersize = 300; // bytes uint8t *mybuffer = mmap(NULL, sizeof(uint8t) * buffersize, PROTREAD | PROTWRITE | PROTEXEC, MAPANONYMOUS | MAP_PRIVATE, -1, 0);
assemblylinet al = asmcreateinstance(mybuffer, buffersize);
asmassemblestr(al, "mov rax, 0x0\nadd rax, 0x2; adds two"); asmassemblestr(al, "sub rax, 0x1; subs one\nret");
int (*func)() = asmgetcode(al);
int result = func(); printf("The result is: %d\n", result); // prints "The result is: 1\n"
asmdestroyinstance(al); munmap(mybuffer, buffer_size); } ```
Lets dissect the example (and give alternatives):
- Include the required header files and preprocessors
c #include <assemblyline.h> // all assemblyline functions #include <stdint.h> // uint8_t #include <stdio.h> // printf #include <sys/mman.h> // mmap - Allocate an executable buffer of sufficient size (> 20 bytes) using mmap
c // the machine code will be written to this location const int buffer_size = 300; // bytes uint8_t *mybuffer = mmap(NULL, sizeof(uint8_t) * buffer_size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); Create an instance of assemblyline_t and attach
mybuffer(orNULL, 0for internal memory allocation) ```c // manual memory allocation assemblylinet al = asmcreateinstance(mybuffer, buffersize);// assemblyline-managed memory allocation assemblylinet al = asmcreate_instance(NULL, 0); ```
Assemble a file or string containing. The machine code will be written to
mybuffer(or the internal buffer). Call those functions sequentially; subsequent new machine code will be appended at the end of the last instruction. Separate instructions with\n.c asm_assemble_file(al, "./path/to/x64_file.asm"); asm_assemble_str(al, "mov rax, 0x0\nadd rax, 0x2; adds two"); asm_assemble_str(al, "sub rax, 0x1; subs one\nret");Get the start address of the buffer containing the start of the assembly program ```c void (*func)() = asmgetcode(al);
// call the function int result = func(); ```
Free all memory associated with assembyline (an external buffer is not freed)
c asm_destroy_instance(al); munmap(mybuffer, buffer_size);
Note: for more information see /src/assemblyline.h or run $ man libassemblyline for more information
Jumpstart Cli-tool: asmline
The general usage is asmline [OPTIONS]... FILE. asmline --help for all options.
asm
; jump.asm
mov rcx, 0x123
jmp 0x4
add rcx, 1
mov rax, rcx
ret
Use -p for printing ASCII-hex to stdout
bash
$ asmline -p jump.asm
b9 23 01 00 00
eb 04
48 83 c1 01
48 89 c8
c3
Or pipe directly into it, use -r to run the code:
```bash
$ echo -n 'mov rax, 0xC0FFEE\nret' | asmline -pr
b8 ee ff c0 00
c3
the value is 0xc0ffee
```
See tools/README.md for more info.
Adding new instructions
To add support for new instructions see src/README.md for more info.
Test files
$ make check to run all test suites (repo must be cloned for this to work)
- To run only one test suite
TESTS=seto.asm make -e check, then check./test/seto.log - Or run the
./al_nasm_compare.sh seto.asmin thetestdirectory - Adding a new test: add the test file e.g.
sub.asmto the directory and addsub.asmto theTESTS-variable in./Makefile.amthen run$ make clean check. Finally, addMakefile.amandsub.asmto git.
Contributing
We welcome any kind of contribution. Feel free to open issues if something is broken or you'd need feature. Or open up a PR if you've enhanced AssemblyLine already and want to see it here.
Acknowledgements
Authors:
- Chitchanok Chuengsatiansup (University of Adelaide)
- Daniel Genkin (Georgia Tech)
- Joel Kuepper (University of Adelaide)
- Markus Wagner (University of Adelaide)
- David Wu (University of Adelaide)
- Yuval Yarom (University of Adelaide)
This project was supported by:
- The Air Force Office of Scientific Research (AFOSR) under award number FA9550-20-1-0425
- An ARC Discovery Early Career Researcher Award (project number DE200101577)
- An ARC Discovery Project (project number DP210102670)
- The Blavatnik ICRC at Tel-Aviv University
- Data61, CSIRO
- the Defense Advanced Research Projects Agency (DARPA) and Air Force Research Laboratory (AFRL) under contracts FA8750-19-C-0531 and HR001120C0087
- the National Science Foundation under grant CNS-1954712
- Gifts from AMD, Google, and Intel
Owner
- Name: 0xADE1A1DE
- Login: 0xADE1A1DE
- Kind: organization
- Repositories: 5
- Profile: https://github.com/0xADE1A1DE
GitHub Events
Total
- Release event: 1
- Watch event: 11
- Push event: 4
- Pull request review event: 1
- Pull request event: 3
- Fork event: 3
- Create event: 2
Last Year
- Release event: 1
- Watch event: 11
- Push event: 4
- Pull request review event: 1
- Pull request event: 3
- Fork event: 3
- Create event: 2
Committers
Last synced: 9 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| daviduwu9 | d****u@h****m | 72 |
| Joel | r****v@g****m | 62 |
| daviduwu9 | 6****9 | 41 |
| javali7 | j****7 | 7 |
| David Wu | a****5@s****u | 4 |
| Moritz Lipp | m****l@m****e | 3 |
| sabrinamanickam | s****1@g****m | 2 |
| Neo-Outis | 5****s | 1 |
| Jasper Quirk | j****k@a****u | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 7
- Total pull requests: 17
- Average time to close issues: 8 days
- Average time to close pull requests: 16 days
- Total issue authors: 5
- Total pull request authors: 7
- Average comments per issue: 2.0
- Average comments per pull request: 1.76
- Merged pull requests: 11
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 4
- Average time to close issues: N/A
- Average time to close pull requests: about 1 month
- Issue authors: 0
- Pull request authors: 2
- Average comments per issue: 0
- Average comments per pull request: 0.0
- Merged pull requests: 4
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- dderjoel (3)
- niansa (1)
- andybui01 (1)
- hugsy (1)
- czastack (1)
Pull Request Authors
- dderjoel (5)
- daviduwu9 (4)
- sabrinamanickam (2)
- JasQuirk (2)
- mlq (2)
- Neo-Outis (1)
- hugsy (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
- Total downloads: unknown
- Total dependent packages: 0
- Total dependent repositories: 1
- Total versions: 18
github actions: 0xADE1A1DE/AssemblyLine
Will install dependencies to build AssemblyLine, build and install AssemblyLine.
- Homepage: https://0xade1a1de.github.io/AssemblyLine
- License: apache-2.0
-
Latest release: v1.4.0
published about 1 year ago
Rankings
Dependencies
- actions/checkout v3 composite
- actions/checkout v2 composite
- actions/checkout v3 composite
- cpp-linter/cpp-linter-action v1.4.3 composite
- jidicula/clang-format-action v4.6.2 composite
- actions/checkout v3 composite