kerncraft/kernel.py
def assemble_to_object(self, in_filename, verbose=False):
        """
        Assemble *in_filename* assembly into *out_filename* object.

        If *iaca_marked* is set to true, markers are inserted around the block with most packed
        instructions or (if no packed instr. were found) the largest block and modified file is
        saved to *in_file*.

        *asm_block* controls how the to-be-marked block is chosen. "auto" (default) results in
        the largest block, "manual" results in interactive and a number in the according block.

        *pointer_increment* is the number of bytes the pointer is incremented after the loop or
           - 'auto': automatic detection, RuntimeError is raised in case of failure
           - 'auto_with_manual_fallback': automatic detection, fallback to manual input
           - 'manual': prompt user

        Returns two-tuple (filepointer, filename) to temp binary file.
        """
        # Build file name
        file_base_name = os.path.splitext(os.path.basename(in_filename))[0]
        out_filename, already_exists = self._get_intermediate_file(file_base_name + '.o',
                                                                   binary=True,
                                                                   fp=False)
        if already_exists:
            # Do not use caching, because pointer_increment or asm_block selection may be different
            pass
        compiler, compiler_args = self._machine.get_compiler()

        # Compile to object file
        compiler_args.append('-c')

        cmd = [compiler] + [
            in_filename] + \
              compiler_args + ['-o', out_filename]

        if verbose:
            print('Executing (assemble_to_object): ', ' '.join(cmd))

        try:
            # Assemble all to a binary
            subprocess.check_output(cmd)
        except subprocess.CalledProcessError as e:
            print("Assembly failed:", e, file=sys.stderr)
            sys.exit(1)

        return out_filename
def assemble_to_object(self, in_filename, verbose=False):
        """
        Assemble *in_filename* assembly into *out_filename* object.

        If *iaca_marked* is set to true, markers are inserted around the block with most packed
        instructions or (if no packed instr. were found) the largest block and modified file is
        saved to *in_file*.

        *asm_block* controls how the to-be-marked block is chosen. "auto" (default) results in
        the largest block, "manual" results in interactive and a number in the according block.

        *pointer_increment* is the number of bytes the pointer is incremented after the loop or
           - 'auto': automatic detection, RuntimeError is raised in case of failure
           - 'auto_with_manual_fallback': automatic detection, fallback to manual input
           - 'manual': prompt user

        Returns two-tuple (filepointer, filename) to temp binary file.
        """
        # Build file name
        file_base_name = os.path.splitext(os.path.basename(in_filename))[0]
        out_filename, already_exists = self._get_intermediate_file(file_base_name + '.o',
                                                                   binary=True,
                                                                   fp=False)
        if already_exists:
            # Do not use caching, because pointer_increment or asm_block selection may be different
            pass
        compiler, compiler_args = self._machine.get_compiler()

        # Compile to object file
        compiler_args.append('-c')

        cmd = [compiler] + [
            in_filename] + \
              compiler_args + ['-o', out_filename]

        if verbose:
            print('Executing (assemble_to_object): ', ' '.join(cmd))

        try:
            # Assemble all to a binary
            subprocess.check_output(cmd)
        except subprocess.CalledProcessError as e:
            print("Assembly failed:", e, file=sys.stderr)
            sys.exit(1)

        return out_filename
Assemble *in_filename* assembly into *out_filename* object.

        If *iaca_marked* is set to true, markers are inserted around the block with most packed
        instructions or (if no packed instr. were found) the largest block and modified file is
        saved to *in_file*.

        *asm_block* controls how the to-be-marked block is chosen. "auto" (default) results in
        the largest block, "manual" results in interactive and a number in the according block.

        *pointer_increment* is the number of bytes the pointer is incremented after the loop or
           - 'auto': automatic detection, RuntimeError is raised in case of failure
           - 'auto_with_manual_fallback': automatic detection, fallback to manual input
           - 'manual': prompt user

        Returns two-tuple (filepointer, filename) to temp binary file.