コード例 #1
0
ファイル: owfile.c プロジェクト: Azarien/open-watcom-v2
static void doReloc( owl_section_handle section, owl_reloc_info *reloc ) {
//************************************************************************

    owl_offset          displacement;
    owl_offset          old_loc;
    unsigned_32         data;
    unsigned_32         bit_mask;

    displacement = OWLRelocTargetDisp( section, reloc->location, reloc->symbol->offset );
    bit_mask = OWLRelocBitMask( section->file, reloc );
    // OWLBufferPatch( section->buffer, reloc->location, displacement, bitMask );
    old_loc = OWLBufferTell( section->buffer );
    OWLBufferSeek( section->buffer, reloc->location );
    OWLBufferRead( section->buffer, reloc->location, (char *)&data, 4 );
    if( section->file->format == OWL_FORMAT_COFF &&
        section->file->info->cpu == OWL_CPU_PPC &&
        reloc->type == OWL_RELOC_JUMP_REL ) {
        // ugly kludge for the MOTOROLA PPC linker
        displacement += reloc->location;
    }
    if( section->file->format == OWL_FORMAT_ELF &&
        section->file->info->cpu == OWL_CPU_INTEL &&
        reloc->type == OWL_RELOC_BRANCH_REL ) {
        // ugly kludge for 386 ELF objects
        displacement += 4;
    }
    data = (data&~bit_mask)|(((displacement&bit_mask)+(data&bit_mask))&bit_mask);
    OWLBufferWrite( section->buffer, (char *)&data, 4 );
    OWLBufferSeek( section->buffer, old_loc );
    _ClientFree( section->file, reloc );
    section->num_relocs -= 1;
}
コード例 #2
0
ファイル: owcoff.c プロジェクト: ABratovic/open-watcom-v2
static void calcLineNumSymbolIndices( owl_file_handle file ) {
//************************************************************

    owl_symbol_handle   sym;

    for( sym = file->symbol_table->head; sym != NULL; sym = sym->next ) {
        if( sym->flags & OWL_SYM_DEAD ) continue;
        if( sym->type != OWL_TYPE_FUNCTION ) continue;
        if( _FuncHasDebugInfo( sym ) ) {
            // Symbol has some sort of debugging info
            //      - patch up index in first linenum record
            assert( sym->section != NULL );
            assert( sym->section->linenum_buffer != NULL );
            OWLBufferSeek( sym->section->linenum_buffer, sym->x.func->linenum_offset );
            OWLBufferWrite( sym->section->linenum_buffer, (const char *)&sym->index, sizeof( sym->index ) );
        }
    }
}