Example #1
0
    def test_simple_filling(self):
        cf = CFile(self.fname, "tagy")
        cf.push_line("simple line\n")
        cf.flush()

        with file(self.fname, 'r') as f:
            self.assertIn(self.bcomment, f)
            self.assertIn("simple line\n", f)
            self.assertIn(self.ecomment, f)
Example #2
0
def main():
    """"The main entry point for symbol parsing."""

    parser = argparse.ArgumentParser(description=LIBSYMBOL_DESCRIPTION)
    parser.add_argument('objs', metavar="OBJS",  nargs="+", help="Object files in the order they are placed to be placed in memory.")
    parser.add_argument('--offset', '-o', help="Object offset, by default 0", type=int, default=0)
    parser.add_argument('--nm', '-n', help="nm executable. By default 'nm'", default='nm')
    parser.add_argument('--gas-header', '-g',
                        help="The header file to insert the names of the symbols which when gas \
encounters will change the jump opcode to absolute jump. The tag used \
is 'external symbols'. By default this is '%s'" % DEFAULT_GAS_HEADER,
                        default=DEFAULT_GAS_HEADER)
    parser.add_argument('--no-gas', help="Dont touch gas headers at all.", action='store_true')

    parser.add_argument('--ld-map', '-l',
                            help="Linker symbol map file. This file is to be passed to the linker when \
linking a NemaWeaver executable using the -R option. Default is '%s'." % DEFAULT_LD_MAP,
                            default=DEFAULT_LD_MAP)
    parser.add_argument('-c', '--clean', help="Clear symbols from gas header file. This will be the only action taken.", action='store_true')

    args = parser.parse_args(sys.argv[1:])

    if args.clean == True:
        print "Clearing everything in %s..." % args.gas_header
        cf = CFile(args.gas_header, "external symbols")
        cf.push_line("\n")
        cf.flush()
        return

    with open(args.ld_map, 'w') as ld_map_file:
        print "Writing ld symbol map to file '%s'." % args.ld_map
        ld_map_file.write( symbol_map(args.objs, offset=args.offset, nm_executable=args.nm) )


    if not args.no_gas:
        print "Writing the symbol names for cfile in '%s'." % args.gas_header

        cf = CFile(args.gas_header, "external symbols")
        for o in aligned_objects(args.objs, offset=args.offset, nm_executable=args.nm):
            o.format_symbols("\"%(name)s\", \\")
            cf.push_line(str(o))
            cf.flush()
Example #3
0
    def test_simple_filling(self):
        cf = CFile(self.fname, "tagy")
        cf.push_line("simple line\n")
        cf.flush()

        with file(self.fname, 'r') as f:
            self.assertIn(self.bcomment, f)
            self.assertIn("simple line\n", f)
            self.assertIn(self.ecomment, f)
Example #4
0
#!/usr/bin/python
"""Fills opcodes in scavenger-opcm.h"""

from pyrametros import CFile, parse_file

# Open a file to edit
f = CFile('scavenger-opcm.h', 'instruction names')

for i in grid[1:]:
    # Create dictionary style rows. Note that numbers are striped from header keys.
    dictionary = parce_file("testtable.txt")

    # Put a line in the file
    f.push_line(dictionary['opcode']+"_opcode,\n")

# Dont forget to flush
f.flush()
Example #5
0
#!/usr/bin/python
"""Fills opcodes in scavenger-opcm.h"""

from pyrametros import CFile, parse_file

# Open a file to edit
f = CFile('scavenger-opcm.h', 'instruction names')

for i in grid[1:]:
    # Create dictionary style rows. Note that numbers are striped from header keys.
    dictionary = parce_file("testtable.txt")

    # Put a line in the file
    f.push_line(dictionary['opcode'] + "_opcode,\n")

# Dont forget to flush
f.flush()