Giter Site home page Giter Site logo

0xade1a1de / assemblyline Goto Github PK

View Code? Open in Web Editor NEW
182.0 182.0 25.0 516 KB

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.

Home Page: https://0xade1a1de.github.io/AssemblyLine

License: Apache License 2.0

Makefile 0.38% M4 0.10% C 9.03% Shell 0.30% Assembly 90.18%
assembler assembly c x86 x86-64

assemblyline's People

Contributors

davidywu9 avatar dderjoel avatar javali7 avatar mlq avatar neo-outis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

assemblyline's Issues

Cannot move immediate to memory address

The Intel manual has opcodes for moving immediate values into memory, however, but it seems as though AssemblyLine currently only supports registers when MOV'ing (i.e. "mov [addr], imm" is not supported).

When moving an immediate into an address pointed to by a register, however, AssemblyLine quietly continues execution.

int value = 0;
assemble_str(al, "mov r8, &value\n"); // Put address of "value" into r8
assemble_str(al, "mov [r8], 1\n"); // is outputted as "mov r8, 1" by AssemblyLine
.
.
.

// Run above code
func();

printf("Value is %d\n, value); // 0

The current work around is to mov the immediate into a register, and moving that into memory address:

assemble_str(al, "mov r8, &value\n"); // Put address of "value" into r8
assemble_str(al, "mov r9, 1\n");
assemble_str(al, "mov [r8], r9\n");

Crash when assembling code

Hey, here is the code I am trying to assemble:

push rax
push rcx
push rdx
push r8
push r9
push r10
mov rcx, 0x637ea511
mov rdx, 0x637ea4d1
mov r8, 0x637ea4f1
mov r9, 0x0
push 0x0
push 0x0
mov r10, 0x61813ff0
call r10
pop rcx
pop rcx
pop r10
pop r9
pop r8
pop rdx
pop rcx
pop rax
ret

And here is the stacktrace:

frame #0: 0x00007ffff7178968 libc.so.6`__strtok_r + 24
frame #1: 0x00007ffff75fe72c libAssemblyLine.so`check_operand_type(instr_buffer=0x00007fffffffc340, all_opd="0x637ea511", opd_pos=1) at tokenizer.c:175:9
frame #2: 0x00007ffff75fe8d9 libAssemblyLine.so`operand_tok(instr_buffer=0x00007fffffffc340, opds="0x637ea511", opd_pos=1) at tokenizer.c:209:3
frame #3: 0x00007ffff75fe930 libAssemblyLine.so`operand_tok(instr_buffer=0x00007fffffffc340, opds="rcx", opd_pos=0) at tokenizer.c:216:12
frame #4: 0x00007ffff75fe9c1 libAssemblyLine.so`instr_tok(instr_buffer=0x00007fffffffc340, comp_instr="mov") at tokenizer.c:229:12
frame #5: 0x00007ffff75fc232 libAssemblyLine.so`line_to_instr(instr_data=0x00007fffffffc340, filtered_asm_str="mov") at parser.c:55:3
frame #6: 0x00007ffff75fca9a libAssemblyLine.so`str_to_instr(instr_data=0x00007fffffffc340, unfiltered_str="mov rcx, 0x637ea511\nmov rdx, 0x637ea4d1\nmov r8, 0x637ea4f1\nmov r9, 0x0\npush 0x0\npush 0x0\nmov r10, 0x61813ff0\ncall r10\npop rcx\npop rcx\npop r10\npop r9\npop r8\npop rdx\npop rcx\npop rax\nret\n", read_len=0x00007fffffffc430) at parser.c:173:12
frame #7: 0x00007ffff75fcfe5 libAssemblyLine.so`assemble_all(al=0x00007fffe829a4d0, str="push rax\npush rcx\npush rdx\npush r8\npush r9\npush r10\nmov rcx, 0x637ea511\nmov rdx, 0x637ea4d1\nmov r8, 0x637ea4f1\nmov r9, 0x0\npush 0x0\npush 0x0\nmov r10, 0x61813ff0\ncall r10\npop rcx\npop rcx\npop r10\npop r9\npop r8\npop rdx\npop rcx\npop rax\nret\n", dest=0x0000000000000000) at parser.c:307:5
frame #8: 0x00007ffff75fa309 libAssemblyLine.so`asm_assemble_str(al=0x00007fffe829a4d0, assembly_str="push rax\npush rcx\npush rdx\npush r8\npush r9\npush r10\nmov rcx, 0x637ea511\nmov rdx, 0x637ea4d1\nmov r8, 0x637ea4f1\nmov r9, 0x0\npush 0x0\npush 0x0\nmov r10, 0x61813ff0\ncall r10\npop rcx\npop rcx\npop r10\npop r9\npop r8\npop rdx\npop rcx\npop rax\nret\n") at assemblyline.c:118:16

Tuxifan ;-)

Feature Request: ignore lines starting with `.` or `.cfi_*`

labels in assembly start with . and some special labels for debugging start with .cfi currently, as Assemblyline does not support jumps, I would still appreciate, if assemblyline could just ignore those labels, instead of erroring out.

Works fine:

$ echo -e "nop\n\nnop" |asmline -p
90 
90

And I'd like to see the same output with labels, but it currently tries to parse it as an instruction.

$ echo -e "nop\n.cfi_abc\nnop" |asmline -p
90 
assembyline: unsupported or illegal instruction: cfi_abc
failed to assemble instruction: .cfi_abc

Use asmline instead of asm_to_stdout for checks

We should use asmline -p for the checks to avoid the need to clean before check with make clean check.
This involves multiple steps:

  • We need to link tools/asmline dynamically (refer #3 )
  • Make use ../tools/asmline -p in tests/al_nasm_compare.sh
  • In the tests/Makefile.am have a dependency, such that if the source code changed the library gets rebuild, and the check is done with the latest version of the sourcecode.

Repo contribution

Hi! Thanks for your really great project!

I've been looking for something exactly like that for a while for a project of mine , and so I've forked and added a few improvements such as:

  • full Windows support
  • transition from autoconf to cmake as build system generator
  • integration to GH Actions for CI purposes
  • added a proper coding style + automatic code formatting
  • a few minor bugs fixed here and there (including a nasty one in tokenizer.c)

All my work is here but in case some (or all) of those features might interest you I'm happy to PR. Let me know!

Cheers

dynamically link asmline

We should link asmline to libassemblyline.so.
We can check that by running ldd tools/asmline after make clean all. It should say show something like libassemblyline.so.0 => /usr/lib/libassemblyline.so.0 (0x00007f44cd827000) (or with the correct version)

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.