Beispiel #1
0
        private void ApplyPatch(LinkRequest linkRequest)
        {
            ulong value = 0;

            if (linkRequest.LinkType == LinkType.Size)
            {
                value = linkRequest.ReferenceSymbol.Size;
            }
            else
            {
                Debug.Assert(linkRequest.ReferenceSymbol.VirtualAddress != 0);
                Debug.Assert(linkRequest.PatchSymbol.VirtualAddress != 0);

                value = linkRequest.ReferenceSymbol.VirtualAddress + (ulong)linkRequest.ReferenceOffset;

                if (linkRequest.LinkType == LinkType.RelativeOffset)
                {
                    // Change the absolute into a relative offset
                    value -= (linkRequest.PatchSymbol.VirtualAddress + (ulong)linkRequest.PatchOffset);
                }
            }

            linkRequest.PatchSymbol.ApplyPatch(
                linkRequest.PatchOffset,
                0,
                GetPatchTypeSize(linkRequest.PatchType),
                Endianness
                );
        }
Beispiel #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 -= (linkRequest.PatchSymbol.VirtualAddress + (ulong)linkRequest.PatchOffset);
                }
            }

            linkRequest.PatchSymbol.ApplyPatch(
                linkRequest.PatchOffset,
                value,
                GetPatchTypeSize(linkRequest.PatchType),
                Endianness
                );
        }
 public void AddPatch(LinkRequest linkRequest)
 {
     lock (_lock)
     {
         LinkRequests.Add(linkRequest);
     }
 }
Beispiel #4
0
        public void Link(LinkType linkType, PatchType patchType, LinkerSymbol patchSymbol, long patchOffset, LinkerSymbol referenceSymbol, int referenceOffset)
        {
            var linkRequest = new LinkRequest(linkType, patchType, patchSymbol, (int)patchOffset, referenceSymbol, referenceOffset);

            lock (_lock)
            {
                patchSymbol.AddPatch(linkRequest);
            }
        }
Beispiel #5
0
        public void Link(LinkType linkType, PatchType patchType, LinkerSymbol patchSymbol, int patchOffset, LinkerSymbol referenceSymbol, int referenceOffset)
        {
            lock (mylock)
            {
                var linkRequest = new LinkRequest(linkType, patchType, patchSymbol, patchOffset, referenceSymbol, referenceOffset);

                patchSymbol.AddPatch(linkRequest);
            }
        }