Beispiel #1
0
        public override void Relocate(Program program)
        {
            DumpRel32(loader);
            DumpRela32(loader);

            foreach (var relSection in loader.Sections)
            {
                if (relSection.Type == SectionHeaderType.SHT_REL)
                {
                    var sectionSymbols   = loader.Symbols[relSection.LinkedSection];
                    var referringSection = relSection.RelocatedSection;
                    var rdr = loader.CreateReader(relSection.FileOffset);
                    for (uint i = 0; i < relSection.EntryCount(); ++i)
                    {
                        var rel = Elf32_Rel.Read(rdr);
                        var sym = sectionSymbols[(int)(rel.r_info >> 8)];
                        RelocateEntry(program, sym, referringSection, rel);
                    }
                }
                else if (relSection.Type == SectionHeaderType.SHT_RELA)
                {
                    var sectionSymbols   = loader.Symbols[relSection.LinkedSection];
                    var referringSection = relSection.RelocatedSection;
                    var rdr = loader.CreateReader(relSection.FileOffset);
                    for (uint i = 0; i < relSection.EntryCount(); ++i)
                    {
                        var rela = Elf32_Rela.Read(rdr);
                        var sym  = sectionSymbols[(int)(rela.r_info >> 8)];
                        RelocateEntry(program, sym, referringSection, rela);
                    }
                }
            }
        }
Beispiel #2
0
 protected void DumpRel32(ElfLoader32 loader)
 {
     foreach (var section in loader.Sections.Where(s => s.Type == SectionHeaderType.SHT_REL))
     {
         Debug.Print("REL: offset {0:X} symbol section {1}, relocating in section {2}",
                     section.FileOffset,
                     section.LinkedSection.Name,
                     section.RelocatedSection.Name);
         var symbols = loader.Symbols[section.LinkedSection.FileOffset];
         var rdr     = loader.CreateReader(section.FileOffset);
         for (uint i = 0; i < section.EntryCount(); ++i)
         {
             var rel = Elf32_Rel.Read(rdr);
             Debug.Print("  off:{0:X8} type:{1,-16} {3,3} {2}",
                         rel.r_offset,
                         RelocationTypeToString(rel.r_info & 0xFF),
                         symbols[(int)(rel.r_info >> 8)].Name,
                         (int)(rel.r_info >> 8));
         }
     }
 }
Beispiel #3
0
 protected void DumpRel32(ElfLoader32 loader)
 {
     foreach (var section in loader.Sections.Where(s => s.Type == SectionHeaderType.SHT_REL))
     {
         ElfImageLoader.trace.Inform("REL: offset {0:X} symbol section {1}, relocating in section {2}",
                                     section.FileOffset,
                                     section.LinkedSection.Name,
                                     section.RelocatedSection.Name);
         loader.Symbols.TryGetValue(section.LinkedSection.FileOffset, out var symbols);
         var rdr = loader.CreateReader(section.FileOffset);
         for (uint i = 0; i < section.EntryCount(); ++i)
         {
             var rel = Elf32_Rel.Read(rdr);
             ElfImageLoader.trace.Verbose(
                 "  off:{0:X8} type:{1,-16} {3,3} {2}",
                 rel.r_offset,
                 RelocationTypeToString(rel.r_info & 0xFF),
                 symbols != null ? symbols[(int)(rel.r_info >> 8)].Name : "<nosym>",
                 (int)(rel.r_info >> 8));
         }
     }
 }