/// <summary> /// Allocate the space required by SHN_COMMON symbols into a /// synthesized section called ".reko.common", and which will /// be placed into its own segment later. /// </summary> private void CollectCommonSymbolsIntoSection() { var rekoCommon = new ElfSection { Name = ".reko.common", Number = (uint)loader.Sections.Count, Type = SectionHeaderType.SHT_NOBITS, Flags = ElfLoader.SHF_WRITE | ElfLoader.SHF_ALLOC | ElfLoader.SHF_REKOCOMMON, FileOffset = 0, Size = 0, }; foreach (var sym in loader.GetAllSymbols().Where(s => s.SectionIndex == 0xFFF2)) { rekoCommon.Size = Align(rekoCommon.Size, sym.Value); sym.Value = (uint)rekoCommon.Size; sym.SectionIndex = (uint)loader.Sections.Count; rekoCommon.Size += sym.Size; } if (rekoCommon.Size > 0) { loader.Sections.Add(rekoCommon); } }