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); }
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); }
public override void RelocateEntry(Program program, ElfSymbol symbol, ElfSection referringSection, Elf32_Rela rela) { throw new NotImplementedException(); }
public abstract void RelocateEntry(Program program, ElfSymbol symbol, ElfSection referringSection, Elf32_Rela rela);
public override void RelocateEntry(Program program, ElfSymbol symbol, ElfSection referringSection, Elf32_Rela rela) { //$TODO: need a ELF PIC MIPS image to do this. return; }
public override void RelocateEntry(Program program, ElfSymbol symbol, ElfSection referringSection, Elf32_Rela rela) { return; }
public override void RelocateEntry(Program program, ElfSymbol symbol, ElfSection referringSection, Elf32_Rela rela) { return; throw new NotImplementedException(); }
public override void RelocateEntry(Program program, ElfSymbol symbol, ElfSection referringSection, Elf32_Rela rela) { throw new NotImplementedException(); /* * S (when used on its own) is the address of the symbol * A is the addend for the relocation. * P is the address of the place being relocated (derived from r_offset). * Pa is the adjusted address of the place being reloc * ated, defined as (P & 0xFFFFFFFC). * T is 1 if the target symbol S has type STT_FUNC and the symbol addresses a Thumb instruction; it is 0 * otherwise. * B(S) is the addressing origin of the output segment defining the symbol S. The origin is not required to be * the base address of the segment. This value must always be word-aligned. * * GOT_ORG is the addressing origin of the Global Offset Table (the indirection table for imported data * addresses). This value must always be word-aligned. See §4.6.1.8, Proxy generating relocations. * GOT(S) is the address of the GOT entry for the symbol S. * Table * 0 R_ARM_NONE Static Miscellaneous * 1 R_ARM_PC24 Deprecated ARM ((S + A) | T) - P * 2 R_ARM_ABS32 Static Data ((S + A) | T) * 3 R_ARM_REL32 Static Data ((S + A) | T) – P * 4 R_ARM_LDR_PC_G0 Static ARM S + A – P * 5 R_ARM_ABS16 Static Data S + A * 6 R_ARM_ABS12 Static ARM S + A * 7 R_ARM_THM_ABS5 Static Thumb16 S + A * 8 R_ARM_ABS8 Static Data S + A * 9 R_ARM_SBREL32 Static Data ((S + A) | T) – B(S) */ }