コード例 #1
0
ファイル: SparcRelocator.cs プロジェクト: relaxar/reko
        public override void RelocateEntry(Program program, ElfSymbol sym, ElfSection referringSection, Elf32_Rela rela)
        {
            if (loader.Sections.Count <= sym.SectionIndex)
                return; 
            if (sym.SectionIndex == 0)
                return;
            var symSection = loader.Sections[(int)sym.SectionIndex];
            uint S = (uint)sym.Value + symSection.Address.ToUInt32();
            int A = 0;
            int sh = 0;
            uint mask = ~0u;
            var addr = referringSection.Address + rela.r_offset;
            uint P = (uint)addr.ToLinear();
            uint PP = P;

            Debug.Print("  off:{0:X8} type:{1,-16} add:{3,-20} {4,3} {2} {5}",
                rela.r_offset,
                (SparcRt)(rela.r_info & 0xFF),
                sym.Name,
                rela.r_addend,
                (int)(rela.r_info >> 8),
                symSection.Name);

            var rt = (SparcRt)(rela.r_info & 0xFF);
            switch (rt)
            {
            case 0:
                return;
            case SparcRt.R_SPARC_HI22:
                A = rela.r_addend;
                sh = 10;
                P = 0;
                break;
            case SparcRt.R_SPARC_LO10:
                A = rela.r_addend;
                mask = 0x3FF;
                P = 0;
                break;
            case SparcRt.R_SPARC_WDISP30:
                A = rela.r_addend;
                P = ~P + 1;
                sh = 2;
                break;
            case SparcRt.R_SPARC_COPY:
                Debug.Print("Relocation type {0} not handled yet.", rt);
                return;
            default:
                throw new NotImplementedException(string.Format(
                    "SPARC ELF relocation type {0} not implemented yet.",
                    rt));
            }
            var relR = program.CreateImageReader(addr);
            var relW = program.CreateImageWriter(addr);

            var w = relR.ReadBeUInt32();
            w += ((uint)(S + A + P) >> sh) & mask;
            relW.WriteBeUInt32(w);
        }
コード例 #2
0
ファイル: x86Relocator.cs プロジェクト: relaxar/reko
 public override void RelocateEntry(Program program, ElfSymbol sym, ElfSection referringSection, Elf32_Rela rela)
 {
     if (loader.Sections.Count <= sym.SectionIndex)
         return;
     if (sym.SectionIndex == 0)
         return;
     var symSection = loader.Sections[(int)sym.SectionIndex];
     uint S = (uint)sym.Value + symSection.Address.ToUInt32();
     int A = 0;
     int sh = 0;
     uint mask = ~0u;
     var addr = referringSection.Address + rela.r_offset;
     uint P = (uint)addr.ToLinear();
     uint PP = P;
     var relR = program.CreateImageReader(addr);
     var relW = program.CreateImageWriter(addr);
     var rt = (i386Rt)(rela.r_info & 0xFF);
     switch (rt)
     {
     case i386Rt.R_386_NONE: //  just ignore (common)
         break;
     case i386Rt.R_386_32: // S + A
                           // Read the symTabIndex'th symbol.
         A = rela.r_addend;
         P = 0;
         break;
     case i386Rt.R_386_PC32: // S + A - P
         if (sym.Value == 0)
         {
             // This means that the symbol doesn't exist in this module, and is not accessed
             // through the PLT, i.e. it will be statically linked, e.g. strcmp. We have the
             // name of the symbol right here in the symbol table entry, but the only way
             // to communicate with the loader is through the target address of the call.
             // So we use some very improbable addresses (e.g. -1, -2, etc) and give them entries
             // in the symbol table
             //S = nextFakeLibAddr--; // Allocate a new fake address
             //loader.AddSymbol(S, sym.Name);
             //}
         }
         A = rela.r_addend;
         P = ~P + 1;
         break;
     case i386Rt.R_386_GLOB_DAT:
         // This relocation type is used to set a global offset table entry to the address of the
         // specified symbol. The special relocation type allows one to determine the
         // correspondence between symbols and global offset table entries.
         P = 0;
         break;
     default:
         throw new NotImplementedException(string.Format(
             "i386 ELF relocation type {0} not implemented yet.",
             rt));
     }
     var w = relR.ReadBeUInt32();
     w += ((uint)(S + A + P) >> sh) & mask;
     relW.WriteBeUInt32(w);
 }
コード例 #3
0
ファイル: ArmRelocator.cs プロジェクト: relaxar/reko
 public override void RelocateEntry(Program program, ElfSymbol symbol, ElfSection referringSection, Elf32_Rela rela)
 {
     throw new NotImplementedException();
 }
コード例 #4
0
ファイル: ElfRelocator.cs プロジェクト: relaxar/reko
 public abstract void RelocateEntry(Program program, ElfSymbol symbol, ElfSection referringSection, Elf32_Rela rela);
コード例 #5
0
ファイル: ArmRelocator.cs プロジェクト: Godzil/reko
 public override void RelocateEntry(ElfSymbol symbol, ElfSection referringSection, Elf32_Rela rela)
 {
     throw new NotImplementedException();
 }
コード例 #6
0
        public override void RelocateEntry(Program program, ElfSymbol symbol, ElfSection referringSection, Elf32_Rela rela)
        {
            switch ((PpcRt)(rela.r_info & 0xFF))
            {
            case PpcRt.R_PPC_GLOB_DAT:
            case PpcRt.R_PPC_COPY:
            case PpcRt.R_PPC_JMP_SLOT:
                break;

            default:
                throw new NotImplementedException();
            }
        }
コード例 #7
0
ファイル: PpcRelocator.cs プロジェクト: relaxar/reko
 public override void RelocateEntry(Program program, ElfSymbol symbol, ElfSection referringSection, Elf32_Rela rela)
 {
     switch ((PpcRt)(rela.r_info & 0xFF))
     {
     case PpcRt.R_PPC_GLOB_DAT:
     case PpcRt.R_PPC_COPY:
     case PpcRt.R_PPC_JMP_SLOT:
         break;
     default:
         throw new NotImplementedException();
     }
 }