// searches the library for unresolved symbols // the result is true if new symbols were added private bool searchLibrary(string currFileName) { if (AssemblerErrors.ErrorReports.Count > 0) { return(false); // don't bother searching if there were errors } bool result = false; using (ArmElfLibReader archive = new ArmElfLibReader(currFileName)) { IList <ArmFileInfo> newLibMembers = new List <ArmFileInfo>(); bool progress = true; while (progress) { progress = false; IList <string> defined = new List <string>(); // copy the list of externals so that we can modify it inside the loop string[] externs = new string[externSymbols.Keys.Count]; externSymbols.Keys.CopyTo(externs, 0); foreach (string sy in externs) { if (globalSymbols.ContainsKey(sy)) { defined.Add(sy); continue; } string fn; FileStream member = archive.GetLibraryFile(sy, out fn); if (member == null) { continue; } defined.Add(sy); ArmFileInfo fileInfo = new ObjFileInfo(member, currFileName, fn, globalSymbols, externSymbols); newLibMembers.Add(fileInfo); fileInfo.Pass = pass; fileInfo.StartPass(); // this call might change externSymbols progress = true; result = true; } foreach (string sy in defined) { externSymbols.Remove(sy); } } foreach (ArmFileInfo af in newLibMembers) { FileInfoTable.Add(af); fileList.Add(af.FileName); } } return(result); }
// perform next pass over the i-th file in the list private void processFile(int i) { string currFileName = fileList[i]; if (currFileName == null) { Debug.WriteLine("error? -- missing file name"); return; } if (!File.Exists(currFileName)) { throw new AsmException("Cannot access file " + currFileName); } ArmFileInfo fileInfo = FileInfoTable[i]; switch (getSuffix(currFileName)) { case ".s": // process ARM assembly language file by invoking the CodeSourcery version // of Gnu's as program, translating it into a .o file -- then the .o file // is handled in the same way as any .o file bool asmOK = true; if (pass == 1) { string objFileName = mapSrcToTempObj(currFileName); asmOK = runAssembler(currFileName, objFileName); if (asmOK) { fileInfo = new ObjFromAsmFileInfo(objFileName, currFileName, listing, symTabListing, globalSymbols, externSymbols); } else { fileInfo = new AsmFileInfo(currFileName, globalSymbols, externSymbols); } FileInfoTable[i] = fileInfo; listing.Clear(); symTabListing.Clear(); } else { fileInfo.ProgramSpace = ap; } if (fileInfo.Pass < pass && asmOK) { fileInfo.Pass = pass; fileInfo.StartPass(); } break; case ".o": // object code file case ".o)": // member of a library archive // process ELF format object code file if (fileInfo == null) { fileInfo = new ObjFileInfo(currFileName, globalSymbols, externSymbols); FileInfoTable[i] = fileInfo; } if (pass == 2) { fileInfo.ProgramSpace = ap; } if (fileInfo.Pass < pass) { fileInfo.Pass = pass; fileInfo.StartPass(); } break; case ".a": // accept a Gnu format archive file containing ELF object code members if (fileInfo == null) { searchLibrary(currFileName); } else { throw new AsmException( "unexpected library file in pass 2: {0}", currFileName); } break; default: throw new AsmException("unsupported file type ({0})", currFileName); } }
// perform next pass over the i-th file in the list private void processFile(int i) { string currFileName = fileList[i]; if (currFileName == null) { Debug.WriteLine("error? -- missing file name"); return; } // Bill M. was here. We do NOT want to check for the existence of the files here. // As libraries are scanned the file list increases, and the names of the fuctions // from the library is added to the filename. Thus, bring in "printf" or something // and you get "libc.a(printf.o)" which does not exist. // if (!File.Exists(currFileName)) // throw new AsmException("Cannot access the file named \"" + currFileName + "\""); ArmFileInfo fileInfo = FileInfoTable[i]; switch (getSuffix(currFileName)) { case ".s": // process ARM assembly language file by invoking the CodeSourcery version // of Gnu's as program, translating it into a .o file -- then the .o file // is handled in the same way as any .o file bool asmOK = true; if (pass == 1) { string objFileName = mapSrcToTempObj(currFileName); asmOK = runAssembler(currFileName, objFileName); if (asmOK) { fileInfo = new ObjFromAsmFileInfo(objFileName, currFileName, listing, symTabListing, globalSymbols, externSymbols); } else { fileInfo = new AsmFileInfo(currFileName, globalSymbols, externSymbols); } FileInfoTable[i] = fileInfo; listing.Clear(); symTabListing.Clear(); } else { fileInfo.ProgramSpace = ap; } if (fileInfo.Pass < pass && asmOK) { fileInfo.Pass = pass; fileInfo.StartPass(); } break; case ".o": // object code file case ".o)": // member of a library archive // process ELF format object code file if (fileInfo == null) { fileInfo = new ObjFileInfo(currFileName, globalSymbols, externSymbols); FileInfoTable[i] = fileInfo; } if (pass == 2) { fileInfo.ProgramSpace = ap; } if (fileInfo.Pass < pass) { fileInfo.Pass = pass; fileInfo.StartPass(); } break; case ".a": // accept a Gnu format archive file containing ELF object code members if (fileInfo == null) { searchLibrary(currFileName); } else { throw new AsmException( "unexpected library file in pass 2: {0}", currFileName); } break; default: throw new AsmException("unsupported file type ({0})", currFileName); } }