(section, p)
Specialized handler for the GLOBALS section to mark the initializer as code.
Specialized handler for the GLOBALS section to mark the initializer as code.
Specialized handler for the GLOBALS section to mark the initializer as code .
def load_globals_section(section, p):
    '''
    Specialized handler for the GLOBALS section to mark the initializer as code.
    '''
    ppayload = p + idawasm.common.offset_of(section.data, 'payload')
    pglobals = ppayload + idawasm.common.offset_of(section.data.payload, 'globals')
    pcur = pglobals
    for i, body in enumerate(section.data.payload.globals):
        gname = 'global_%X' % (i)
        # we need a target that people can rename.
        # so lets map `global_N` to the init expr field.
        # this will look like:
        #
        #     global_0        <---- named address we can reference
        #     global_0_init:  <---- fake label line
        #        i32.const    <---- init expression insns
        #        ret
        pinit = pcur + idawasm.common.offset_of(body, 'init')
        idc.MakeName(pinit, gname)
        idc.ExtLinA(pinit, 0, gname + '_init:')
        idc.MakeCode(pinit)

        pcur += idawasm.common.size_of(body)
def load_globals_section ( section , p ) : ppayload = p + idawasm . common . offset_of ( section . data , 'payload' ) pglobals = ppayload + idawasm . common . offset_of ( section . data . payload , 'globals' ) pcur = pglobals for i , body in enumerate ( section . data . payload . globals ) : gname = 'global_%X' % ( i ) # we need a target that people can rename. # so lets map `global_N` to the init expr field. # this will look like: # #     global_0        <---- named address we can reference #     global_0_init:  <---- fake label line #        i32.const    <---- init expression insns #        ret pinit = pcur + idawasm . common . offset_of ( body , 'init' ) idc . MakeName ( pinit , gname ) idc . ExtLinA ( pinit , 0 , gname + '_init:' ) idc . MakeCode ( pinit ) pcur += idawasm . common . size_of ( body )