Ejemplo n.º 1
0
        protected void EmitRelocation(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 relocationEntry = new RelocationEntry()
                    {
                        RelocationType = ConvertType(patch.LinkType, linker.MachineType),
                        Symbol         = symbolTableOffset[symbol],
                        Offset         = (ulong)patch.PatchOffset,
                    };

                    relocationEntry.Write(linkerFormatType, writer);
                    count++;
                }

                section.Size = (uint)(count * RelocationEntry.GetEntrySize(linkerFormatType));
            }
        }
Ejemplo n.º 2
0
        protected void CreateRelocationSection(SectionKind kind, bool addend)
        {
            var relocationSection = new Section()
            {
                Name             = (addend ? ".rela" : ".rel") + LinkerSectionNames[(int)kind],
                Type             = addend ? SectionType.RelocationA : SectionType.Relocation,
                Link             = symbolSection,
                Info             = GetSection(kind),
                AddressAlignment = linker.SectionAlignment,
                EntrySize        = addend ? RelocationAddendEntry.GetEntrySize(linkerFormatType) : RelocationEntry.GetEntrySize(linkerFormatType),
                EmitMethod       = WriteRelocationSection
            };

            AddSection(relocationSection);

            relocationSection.AddDependency(symbolSection);
            relocationSection.AddDependency(GetSection(kind));
        }