public void linkStage1() { foreach (LinkedSymbol s in symbols) { LinkedSectionPart p = findPart(file.symbolSection(s.index)); if (p != null) // We only process symbols which are actually defined (with a location) { s.part = p; s.address = p.startAddress + file.symbolOffset(s.index); // TODO: Only do this if actually flagged as global! // TODO: Check if already listed? if (linker.globals.ContainsKey(s.name())) { Console.WriteLine("Symbol '" + s.name() + "' has already been defined (elsewhere?)"); //throw new LinkerException(file, "Symbol '" + s.name() + "' has already been defined (elsewhere?)"); } else { Console.WriteLine("Symbol '" + s.name() + "' is a new one though"); linker.globals.Add(s.name(), s); } } } }
public LinkedSectionPart add(LinkedLibrary library, uint sectionNumber) { LinkedSectionPart s = new LinkedSectionPart(); s.section = this; s.library = library; s.librarySection = sectionNumber; while ((size % alignment) != 0) { size++; } s.startAddress = offset + size; s.size = library.file.sectionVirtualSize(sectionNumber); size += s.size; parts.Add(s); ulong foffset = library.file.sectionFileOffset(sectionNumber); ulong fsize = library.file.sectionFileSize(sectionNumber); for (ulong i = 0; i < fsize; i++) { linker.target.setU8(s.startAddress + i, library.file.memory.getU8(foffset + i, false)); } for (ulong j = fsize; j < s.size; j++) { linker.target.setU8(s.startAddress + j, 0); // Clear any remaining "virtual" (reserved) memory with zeroes } return(s); }
public LinkedSectionPart add(LinkedSectionPart s) { parts.Add(s); return(s); }