Esempio n. 1
0
        // end of accessor methods

        public ArmElfReader(ArmFileInfo af)
        {
            this.af        = af;
            this.fileName  = af.FileName;
            SourceFileName = null;
            openFile();
        }
Esempio n. 2
0
 public ArmElfReader(ArmFileInfo af, FileStream fs)
 {
     this.af        = af;
     this.fileName  = af.FileName;
     SourceFileName = null;
     this.fs        = fs;
     fsOrigin       = fs.Position;
     openFile();
 }
	// placement for one main section type in one file
	private void performPlacement( SectionType st, ArmFileInfo fileInfo ) {
		fileInfo.SectionAddress[(int)st] = nextFreeAddress;
		int size = fileInfo.SectionSize[(int)st];
		// place the labels in this section only
		foreach( SyEntry sy in fileInfo.LocalSymTable.Values ) {
			if (sy.Kind != SymbolKind.Label) continue;
			if (sy.Section != st) continue;
			if (sy.Subsection != 0)
				throw new AsmException("internal error in performPlacement, 2");
			sy.SymValue += nextFreeAddress;
		}
		nextFreeAddress += size;
		nextFreeAddress = (int)(((uint)nextFreeAddress + 3) & 0xFFFFFFFC);
	}
Esempio n. 4
0
        // 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);
            }
        }
Esempio n. 5
0
        // 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);
            }
        }