def read_map_file(file_name):
    """
    reads a map file generated by TI's ARM compiler. the function expects a file of a form similar to:
    .
    .
    .
    GLOBAL SYMBOLS: SORTED BY Symbol Address

    address   name
    -------   ----
    00000000  __TI_static_base__
    00000000  g_pfnVectors
    00000200  __STACK_SIZE
    00000209  _Z10set_pinoutv
    .
    .
    .
    ffffffff  __c_args__
    ffffffff  binit

    [85 symbols]


    """
    map_file = open(file_name).readlines()
    [i] = [i for i, x in enumerate(map_file) if "GLOBAL SYMBOLS: SORTED BY Symbol Address" in x]
    i += 4  # skip the lines separating the header from the start of the list
    map_dict = {}
    for line in map_file[i:]:
        if line[0] == '\n' or line[0] == '[':
            break
        addr, symbol = line.split()
        map_dict[int(addr, 16)] = symbol
    return map_dict