Represents a linking request to the assembly linker.
 public void AddPatch(LinkRequest linkRequest)
 {
     lock (_lock)
     {
         LinkRequests.Add(linkRequest);
     }
 }
Exemple #2
0
        private void ApplyPatch(LinkRequest linkRequest)
        {
            ulong value = 0;

            if (linkRequest.LinkType == LinkType.Size)
            {
                value = linkRequest.ReferenceSymbol.Size;
            }
            else
            {
                value = linkRequest.ReferenceSymbol.VirtualAddress + (ulong)linkRequest.ReferenceOffset;

                if (linkRequest.LinkType == LinkType.AbsoluteAddress)
                {
                    // FIXME: Need a .reloc section with a relocation entry if the module is moved in virtual memory
                    // the runtime loader must patch this link request, we'll fail it until we can do relocations.
                    //throw new NotSupportedException(@".reloc section not supported.");
                }
                else
                {
                    // Change the absolute into a relative offset
                    value = value - (linkRequest.PatchSymbol.VirtualAddress + (ulong)linkRequest.PatchOffset);
                }
            }

            linkRequest.PatchSymbol.ApplyPatch(
                linkRequest.PatchOffset,
                value,
                GetPatchTypeSize(linkRequest.PatchType),
                Endianness
                );
        }
Exemple #3
0
 public void Link(LinkType linkType, PatchType patchType, LinkerSymbol patchSymbol, int patchOffset, int relativeBase, LinkerSymbol referenceSymbol, int referenceOffset)
 {
     lock (mylock)
     {
         var linkRequest = new LinkRequest(linkType, patchType, patchSymbol, patchOffset, relativeBase, referenceSymbol, referenceOffset);
         LinkRequests.Add(linkRequest);
     }
 }
Exemple #4
0
        private void ApplyPatch(LinkRequest linkRequest)
        {
            ulong value = 0;

            if (linkRequest.LinkType == LinkType.Size)
            {
                value = linkRequest.ReferenceSymbol.Size;
            }
            else
            {
                ulong targetAddress = linkRequest.ReferenceSymbol.VirtualAddress + (ulong)linkRequest.ReferenceOffset;

                if (linkRequest.LinkType == LinkType.AbsoluteAddress)
                {
                    // FIXME: Need a .reloc section with a relocation entry if the module is moved in virtual memory
                    // the runtime loader must patch this link request, we'll fail it until we can do relocations.
                    //throw new NotSupportedException(@".reloc section not supported.");
                }
                else
                {
                    // Change the absolute into a relative offset
                    targetAddress = targetAddress - (linkRequest.PatchSymbol.VirtualAddress + (ulong)linkRequest.PatchOffset);
                }

                targetAddress = targetAddress + (ulong)linkRequest.RelativeBase;

                value = Patch.GetResult(linkRequest.PatchType.Patches, (ulong)targetAddress);
            }

            ulong mask = Patch.GetFinalMask(linkRequest.PatchType.Patches);

            linkRequest.PatchSymbol.ApplyPatch(
                linkRequest.PatchOffset,
                value,
                mask,
                linkRequest.PatchType.Size,
                Endianness
                );
        }
Exemple #5
0
        private void ApplyPatch(LinkRequest linkRequest)
        {
            ulong value = 0;

            if (linkRequest.LinkType == LinkType.Size)
            {
                value = linkRequest.ReferenceSymbol.Size;
            }
            else
            {
                ulong targetAddress = linkRequest.ReferenceSymbol.VirtualAddress + (ulong)linkRequest.ReferenceOffset;

                if (linkRequest.LinkType == LinkType.AbsoluteAddress)
                {
                    // FIXME: Need a .reloc section with a relocation entry if the module is moved in virtual memory
                    // the runtime loader must patch this link request, we'll fail it until we can do relocations.
                    //throw new NotSupportedException(@".reloc section not supported.");
                }
                else
                {
                    // Change the absolute into a relative offset
                    targetAddress = targetAddress - (linkRequest.PatchSymbol.VirtualAddress + (ulong)linkRequest.PatchOffset);
                }

                targetAddress = targetAddress + (ulong)linkRequest.RelativeBase;

                value = Patch.GetResult(linkRequest.PatchType.Patches, (ulong)targetAddress);
            }

            ulong mask = Patch.GetFinalMask(linkRequest.PatchType.Patches);

            linkRequest.PatchSymbol.ApplyPatch(
                linkRequest.PatchOffset,
                value,
                mask,
                linkRequest.PatchType.Size,
                Endianness
            );
        }
Exemple #6
0
 public void Link(LinkType linkType, PatchType patchType, LinkerSymbol patchSymbol, int patchOffset, int relativeBase, LinkerSymbol referenceSymbol, int referenceOffset)
 {
     lock (mylock)
     {
         var linkRequest = new LinkRequest(linkType, patchType, patchSymbol, patchOffset, relativeBase, referenceSymbol, referenceOffset);
         //LinkRequests.Add(linkRequest);
         patchSymbol.AddPatch(linkRequest);
     }
 }
 public void AddPatch(LinkRequest linkRequest)
 {
     lock(this)
     {
         LinkRequests.Add(linkRequest);
     }
 }
Exemple #8
0
        private void ApplyPatch(LinkRequest linkRequest)
        {
            ulong value = 0;

            if (linkRequest.LinkType == LinkType.Size)
            {
                value = linkRequest.ReferenceSymbol.Size;
            }
            else
            {
                value = linkRequest.ReferenceSymbol.VirtualAddress + (ulong)linkRequest.ReferenceOffset;

                if (linkRequest.LinkType == LinkType.AbsoluteAddress)
                {
                    // FIXME: Need a .reloc section with a relocation entry if the module is moved in virtual memory
                    // the runtime loader must patch this link request, we'll fail it until we can do relocations.
                    //throw new NotSupportedException(@".reloc section not supported.");
                }
                else
                {
                    // Change the absolute into a relative offset
                    value = value - (linkRequest.PatchSymbol.VirtualAddress + (ulong)linkRequest.PatchOffset);
                }
            }

            linkRequest.PatchSymbol.ApplyPatch(
                linkRequest.PatchOffset,
                value,
                GetPatchTypeSize(linkRequest.PatchType),
                Endianness
            );
        }