|
@@ -570,6 +570,56 @@ TYPE ObjectFileFormat* = OBJECT (Formats.ObjectFileFormat)
|
|
|
context.error.String("no file specificed"); context.error.Ln
|
|
|
END;
|
|
|
END Show;
|
|
|
+
|
|
|
+ PROCEDURE MakeLibrary*(context: Commands.Context);
|
|
|
+ VAR
|
|
|
+ fileName: Files.FileName; file: Files.File; reader: Files.Reader; (*writer: Streams.Writer;*)
|
|
|
+ binary: BOOLEAN; poolMap, poolMapDummy: ObjectFile.PoolMap;
|
|
|
+ bs: BinaryCode.Section;
|
|
|
+ is: IntermediateCode.Section;
|
|
|
+ sectionList: Sections.SectionList;
|
|
|
+ section: ObjectFile.Section;
|
|
|
+ i: LONGINT;
|
|
|
+ dest: Files.FileName;
|
|
|
+ writer: Files.Writer;
|
|
|
+ name: ObjectFile.SegmentedName;
|
|
|
+ BEGIN
|
|
|
+ NEW(sectionList);
|
|
|
+ IF context.arg.GetString(dest) THEN
|
|
|
+ (*writer := Basic.GetWriter(Basic.GetDebugWriter(fileName));*)
|
|
|
+ WHILE context.arg.GetString(fileName) DO
|
|
|
+ file := Files.Old(fileName);
|
|
|
+ IF file # NIL THEN
|
|
|
+ NEW(reader,file,0);
|
|
|
+ ReadHeader(reader, binary, poolMap);
|
|
|
+ WHILE reader.Peek () # 0X DO
|
|
|
+ ObjectFile.InitSection(section);
|
|
|
+ ObjectFile.ReadSection (reader, section, binary, poolMap);
|
|
|
+ NEW(bs, SHORTINT(section.type) ,section.priority,section.unit,name, FALSE, FALSE);
|
|
|
+ bs.os := section;
|
|
|
+ NEW(is, SHORTINT(bs.os.type), SHORTINT(bs.os.priority), bs.os.identifier.name,NIL, FALSE);
|
|
|
+ is.SetResolved(bs);
|
|
|
+ sectionList.AddSection(is);
|
|
|
+
|
|
|
+
|
|
|
+ reader.SkipWhitespace;
|
|
|
+ END;
|
|
|
+ ELSE
|
|
|
+ context.error.String("file not found "); context.error.String(fileName); context.error.Ln
|
|
|
+ END;
|
|
|
+ END;
|
|
|
+ file := Files.New(dest);
|
|
|
+ Files.OpenWriter(writer, file, 0);
|
|
|
+ WriteHeader(writer, TRUE, sectionList, poolMapDummy, NIL);
|
|
|
+ FOR i := 0 TO sectionList.Length()-1 DO
|
|
|
+ is := sectionList.GetSection(i)(IntermediateCode.Section);
|
|
|
+ ObjectFile.WriteSection(writer, is.resolved.os, TRUE, poolMapDummy); (* binary *)
|
|
|
+ END;
|
|
|
+ writer.Update;
|
|
|
+ Files.Register(file);
|
|
|
+ END;
|
|
|
+ END MakeLibrary;
|
|
|
+
|
|
|
|
|
|
PROCEDURE Statistics*;
|
|
|
VAR iterator: Basic.IntIterator; stat: SectionStat; index: StringPool.Index; any: ANY;
|