Esempio n. 1
0
        public static SPIFLASHSection[] GetFLASHSections(ELFFile file)
        {
            List <SPIFLASHSection> sections = new List <SPIFLASHSection>();

            foreach (var sec in file.AllSections)
            {
                if (sec.VirtualAddress >= SPIFLASHBase && sec.VirtualAddress < SPIFLASHLimit)
                {
                    sections.Add(new SPIFLASHSection {
                        OffsetInFLASH = sec.VirtualAddress - SPIFLASHBase, Data = file.LoadSection(sec)
                    });
                }
            }
            return(sections.ToArray());
        }
Esempio n. 2
0
        private static void InsertSections(ELFFile file, bool esptoolSectionOrder, ESP8266BinaryImage image, bool ramSectionsOnly)
        {
            List <ELFFile.ParsedSection> sections = new List <ELFFile.ParsedSection>();

            if (esptoolSectionOrder)
            {
                foreach (var secN in new string[] { ".text", ".data", ".rodata" })
                {
                    sections.Add(file.FindSectionByName(secN));
                }
            }
            else
            {
                sections = file.AllSections;
            }

            foreach (var sec in sections)
            {
                if (!sec.HasData || !sec.PresentInMemory)
                {
                    if (sec.SectionName != ".rtc.text")
                    {
                        continue;
                    }
                }

                if (!ramSectionsOnly || (sec.VirtualAddress < SPIFLASHBase))
                {
                    var segment = new Segment {
                        Address = sec.VirtualAddress, Data = file.LoadSection(sec), Hint = sec.SectionName
                    };
                    int align = ((segment.Data.Length + 3) & ~3) - segment.Data.Length;
                    if (align > 0)
                    {
                        Array.Resize(ref segment.Data, segment.Data.Length + align);
                    }
                    image.Segments.Add(segment);
                }
            }
        }