Пример #1
0
        protected void EmitRelocationAddend(LinkerSection linkerSection, Section section)
        {
            int count = 0;

            foreach (var symbol in linkerSection.Symbols)
            {
                foreach (var patch in symbol.LinkRequests)
                {
                    if (patch.ReferenceOffset == 0)
                    {
                        continue;
                    }

                    if (patch.LinkType == LinkType.Size)
                    {
                        continue;
                    }

                    var relocationAddendEntry = new RelocationAddendEntry()
                    {
                        RelocationType = ConvertType(patch.LinkType, linker.MachineType),
                        Symbol         = symbolTableOffset[symbol],
                        Offset         = (ulong)patch.PatchOffset,
                        Addend         = (ulong)patch.ReferenceOffset,
                    };

                    relocationAddendEntry.Write(linkerFormatType, writer);

                    count++;
                }
            }

            section.Size = (uint)(count * RelocationAddendEntry.GetEntrySize(linkerFormatType));
        }
Пример #2
0
 /// <summary>
 /// Lays the symbols out according to their offset in the section.
 /// </summary>
 protected virtual void LayoutSymbols()
 {
     // Adjust the symbol addresses
     foreach (LinkerSymbol symbol in this.linker.Symbols)
     {
         LinkerSection ls = linker.GetSection(symbol.Section);
         symbol.Offset         = ls.Offset + symbol.SectionAddress;
         symbol.VirtualAddress = new IntPtr(ls.VirtualAddress.ToInt64() + symbol.SectionAddress);
     }
 }
Пример #3
0
        /// <summary>
        /// Performs stage specific processing on the compiler context.
        /// </summary>
        public override void Run()
        {
            // Adjust the symbol addresses
            // __grover, 01/02/2009: Copied from ObjectFileLayoutStage
            foreach (LinkerSymbol symbol in Symbols)
            {
                LinkerSection ls = GetSection(symbol.Section);
                symbol.Offset         = ls.Offset + symbol.SectionAddress;
                symbol.VirtualAddress = new IntPtr(ls.VirtualAddress.ToInt64() + symbol.SectionAddress);
            }

            // Now run the linker
            base.Run();
        }