Note

The Funtoo Linux project has transitioned to "Hobby Mode" and this wiki is now read-only.

Difference between revisions of "Funtoo binfmt misc Qemu chroot Guide"

From Funtoo
Jump to navigation Jump to search
(Blanked the page)
Tag: Blanking
 
(15 intermediate revisions by the same user not shown)
Line 1: Line 1:
=''Funtoo binfmt_misc Qemu chroot Guide: aka (Frankenroot)''=
{{file|name=qemu-arm.c|lang=C|desc=qemu arm wrapper|body=
    /*
    * Call QEMU binary with additional "-cpu cortex-a53" argument.
    *
    * Copyright (c) 2018 sakaki <sakaki@deciban.com>
    * License: GPL v3.0+
    *
    * Based on code from the Gentoo Embedded Handbook
    * ("General/Compiling_with_qemu_user_chroot")
    */


    #include <string.h>
    #include <unistd.h>
    int main(int argc, char **argv, char **envp) {
        char *newargv[argc + 3];
        newargv[0] = argv[0];
        newargv[1] = "-cpu";
        newargv[2] = "cortex-a7";
        memcpy(&newargv[3], &argv[1], sizeof(*argv) * (argc -1));
        newargv[argc + 2] = NULL;
        return execve("/usr/local/bin/qemu-arm", newargv, envp);
    }
}}
{{file|name=masky.py|lang=python|desc=masky|body=
#!/usr/bin/python3
import sys
import struct
import string
import codecs
printable_chars = set(string.printable)
printable_chars = set()
def print_out_hexstring(hexstring):
    to_process = hexstring
    while len(to_process):
        ascii_value = chr(int(to_process[:2], 16))
        to_process = to_process[2:]
        if ascii_value in printable_chars:
            sys.stdout.write(ascii_value)
        else:
            sys.stdout.write("\\x" + "{0:02x}".format(ord(ascii_value)))
chunk_as_hexstring = ""
with open(sys.argv[1], 'rb') as f:
    for x in range(0,19):
      chunk_as_hexstring += f.read(1).hex()
mask_as_hexstring = "fffffffffffffffcfffffffffffffffffeffff"
mask = int(mask_as_hexstring, 16)
chunk = int(chunk_as_hexstring, 16)
out_as_hexstring = hex(chunk & mask)[2:]
sys.stdout.write(":arm:M::")
print_out_hexstring(out_as_hexstring)
sys.stdout.write(":")
print_out_hexstring(mask_as_hexstring)
sys.stdout.write(":/usr/local/bin/qemu-arm-wrapper:\n")
}}

Latest revision as of 04:08, February 19, 2019