jagomart
digital resources
picture1_Programming Concepts Pdf 189359 | P11 Item Download 2023-02-03 10-55-18


 127x       Filetype PDF       File size 0.49 MB       Source: ipsitransactions.org


File: Programming Concepts Pdf 189359 | P11 Item Download 2023-02-03 10-55-18
a linker for sic xe hypothetical computer kisek nejc abstract the article describes the de multiple object code sections together loader sign and implementation of a linker for the that ...

icon picture PDF Filetype PDF | Posted on 03 Feb 2023 | 2 years ago
Partial capture of text on file.
                   A Linker for SIC/XE Hypothetical Computer
                                                                        ˇ
                                                                      Kisek, Nejc
                       Abstract:    The article describes the de-               multiple object code sections together; loader,
                   sign and implementation of a linker for the                  that inserts the object code in the correct part
                   SIC/XE hypothetical computer, described in                   of computer’s memory; compiler, that converts
                   Leland Beck’s book System Software. Linker                   a high level programming language into assem-
                   was developed as a part of SicTools collection               bly code and an operating system, that con-
                   consisting of system software tools for the same             trols resources, communicates with the hard-
                   hypothetical computer. We start by introduc-                 ware and overlooks user applications.
                   ing SIC/XE and existing tools for working with                   SicTools [6] is a collection of system soft-
                   it, followed by a few concepts behind the link-
                   ing process. Then we describe the implemented                ware utilities for SIC/XE that includes an as-
                   linker, list its functionalities and describe how            sembler, a simulator and a linker. It was devel-
                   to use it. We focus on using the linker as a li-             oped for enhancing practical demonstrations in
                   brary in another program, but we also give some              a system software course at University of Ljubl-
                   instructions on using it on its own. Finally, to             jana’s Faculty of Computer and Information sci-
                   better illustrate the process of linking, we also            ence. It is used at several faculties around the
                   show a simple example.                                       world, mainly at courses following the Beck’s
                                                                                book.     The included assembler allows us to
                       Index Terms: linker, SIC/XE, SicTools, sys-              translate assembly code into object files, fol-
                   tem software                                                 lowing specifications from the System Software
                                                                                book. The simulator features a graphical inter-
                                  1.   Introduction                             face, an overview of CPU registers and entire
                                                                                memory. It can run at different frequencies and
                      IC/XE (Simplified Instructional Computer                   supports breakpoints or step by step execution.
                   Swith Extra Equipment) is a hypothetical                     Additionally, it can simulate a graphical or a
                   processor from Leland Beck’s textbook System                 textual screen and can interact with standard
                   Software [1]. The book uses it to show how as-               input/output or external files.
                   semblers, linkers, loaders, compilers and other                  The linker utility was added to SicTools as
                   parts of system software work. The main pur-                 part of a bachelor’s degree thesis [4] following
                   poseofthisprocessor is to have a minimal set of              the specifications from Beck’s book [1]. We
                   features that most real processors have, without             also used concepts from [5] and followed the
                   extra functionalities or simplifications. Because             approach to generation of ideas as documented
                   of that, concepts for working with SIC/XE are                in [7].
                   also useful when working with real processors.                   In the following section we describe the
                       System software is software that supports                main concepts behind linking. In Section 3 we
                   the use and operation of other programs and                  list the features of our linker implementation.
                   the computer itself. A few examples of such                  Then we present an overview of how each part
                   programs are assembler, that converts assembly               of the library can be used in Section 4 and how
                   language into object code; linker, that connects             the linker can be used as a standalone program
                                                                                in Section 5. In Section 6 we show a simple ex-
                       Manuscript received Jul, 2017 and accepted for the       ample of linking and then conclude with some
                   journal in Nov, 2017.                                        ideas for future work.
                       Nejc Kisek, Faculty of Computer and Informa-
                               ˇ
                   tion Science, University of Ljubljana, Slovenia (e-mail:
                   nk4741@student.uni-lj.si).
                                   2.   Linking                           contain the code itself; M Records that describe
                 Linking is a process of combining multiple ob-           how addresses in the code should be modified
                 ject files to create the whole program. Object            during linking or loading; D Records that define
                 files are comprised of multiple control sections,         which symbols in the section should be exter-
                 which are independent parts of the program,              nal; R Records that refer to symbols from other
                 but can be connected with a system of refer-             sections and a final E Record marking the end
                 ences. A symbol (variable) inside one section            of a section.
                 can be seen by other sections if we define it as              During the linking, D and R records tell the
                 an external symbol. Other sections can refer to          linker which sections contain external symbol
                 symbols defined in this way and use them. In              references and their definitions, while M records
                 Figure 1 we can see how a program in multiple            specify which addresses in the code belong to
                 assembly files is processed before we can run it.         a reference and should be modified.
                                                                                    3.   Implemented Linker
                                                                          The main functionality of the implemented
                                                                          linker is linking multiple object files into a sin-
                                                                          gle one and resolving any references that ex-
                                                                          ist between them.      In a typical scenario, we
                                                                          have several object files comprised of multiple
                                                                          control sections with references between them
                                                                          as an input to the liker, which then outputs
                                                                          a single .obj file containing only one control
                                                                          section with all references resolved. If this is
                                                                          not exactly what we want to achieve, the im-
                             Figure 1: Linking process                    plemented linker has a few extra options that
                                                                          change how the linking process works.
                     During the process, linker first assigns an           Partial linking.     This option can be used,
                 address to each section and checks which sec-            when we want to link multiple control sections
                 tions contain externally defined symbols. After           where not all references can be resolved – some
                 that, it parses all the sections and replaces any        of them may refer to definitions that are not
                 references with actual addresses from previous           present in any control section.      If we enable
                 step. Finally, linker combines all sections into         partial linking, the linker output will still be just
                 one and writes it to a file.                              one object file with one control section, but it
                     Thereareafewdetailsthatwedidnotmen-                  will also include refer and modify records for
                 tion, for example that addresses in SIC/XE can           each reference without a define record in any
                 be absolute or relative. Absolute addresses re-          of the output files. This is useful, when we do
                 fer to a specific point in memory and is not              not have all the object files of a program, but
                 supported in our linker implementation, since            we want to link just the ones we already have.
                 sections can not be moved to an arbitrary place
                 in the memory. Relative addresses are adjusted           Preserving external definitions.         This is an
                 by the loader just before the program is run,            option that keeps the define records in the out-
                 based on where in memory the code was placed.            put object file after resolving the references. It
                 Linker handles different types of relative ad-            can be used for debugging, but we might also
                 dresses in a slightly different way, to ensure the        use it for further linking the object file.
                 loader will still understand them after they are             Let us demonstrate with an example. We
                 in the same section.                                     would like to link object files containing refer-
                     SIC/XE object files contain different types            ences A, B and C, but we only have files with
                 of records: H Record that contains name ad-              definitions of A and B available and have to use
                 dress and length of the section; T Records that
                partial linking option to skip C. When we get      puts the section to a text file and returns the
                the object file for C it might include its own      File class pointing to it.
                references to A and B. If we want to link it
                with our partially linked program, we will have
                to include the files for A and B again, which
                will lead to duplicated code. The preserving ex-
                ternal definitions option during the first partial
                linking allows the original A and B to be used
                in the second linking as well, without relinking
                the whole program or duplicating code.
                Modifying Sections.    Reordering and modi-
                fying sections can be done in two ways. Usually
                wejustwanttospecifythesectionthatneedsto
                befirst(wheretheprogramshouldstart), which
                can be done using the main section option.             Figure 2: Linker classes and methods
                When more modifications are needed, we can
                also change the order of other sections manu-
                ally as well as rename or delete them. This can    Specifying Options.    We can control the
                be done programatically when using the linker      linking process  with   variables inside the
                library or with the commandline or graphical       Options class. Most of them we mentioned in
                interface included in SicTools.                    the previous chapter: attributes force, keep
                                                                   and verbose of boolean type represent the
                Verbose Mode Thisisanoptionusedforde-              partial linking, preserving definitions and ver-
                bugging and prints all actions that happen dur-    bose mode options, respectively, while the at-
                ing the linking to standard output.                tribute main of type String specifies the name
                                                                   of the section that should be first in the re-
                           4.  Linker Library                      sulting output. In addition to that, we have
                                                                   outputPath and outputName that are used by
                Thelinker is implemented as a Java library that    the Writer utility and represent the full path to
                can be used via the Linker class. Files, classes,  and the name of the output file. There are also
                methods and operations involved in linking are     graphical and editing attributes of boolean
                illustrated on the diagram in Figure 2.            type that are used by the included linker tool.
                   The Linker constructor receives a list of       Modifying Sections.    If we want to change
                filenames for the object files we want to link       the order of sections, modify them or change
                and an Options class that defines any addi-         the references used in them, we can perform
                tional options mentioned in the previous chap-     the linking in smaller separate steps instead of
                ter. If we do not need to reorder any sec-         using the link method.
                tions, we can just call the link method, which        After creating the Linker object, we call
                will read all specified files and link the sec-      its parse method, which will read the input
                tions. The method will return the result in the    files and return a Sections object. It contains
                form of a single Section class. Section class      the name of the whole program and the list of
                stores information about the control section it-   Section objects, each representing one control
                self (name, start address and length) and all      section that was found in the input files. The
                the records that the section contains.             order of sections in the list represents how they
                   A section can be written to an object file,      will be ordered in the linked program.
                with the Writer class. Its constructor takes          Sections class also has methods for mod-
                Section and Options classes as arguments           ifying containing sections, references or defini-
                and implements a method write, which out-          tions: rename, move or remove for sections
                 and renameRef, renameDef or removeRef,                   there are checkboxes and input fields. Object
                 removeDef for references. When renaming we               files are added via the Add .obj button and
                 need to make sure all names are at most six              are displayed on the central list, where they can
                 characters long, that section names are unique           also be reordered.
                 and that definition names are unique within
                 each section.    Renaming a reference with an
                 already used name will combine them into one
                 (their M records will use the same symbol).
                     We can finalise the linking with the
                 passAndCombine method in the Linker
                 class. It accepts the modified Sections as an
                 argument, performs the linking and outputs a
                 single Section object. The result is a finished              Figure 3: The graphical standalone linker
                 linked section, similar to the result of the link
                 method, and can be written to a file with the                 The tool includes a section editor (graphi-
                 Writer utility in the same way as mentioned              cal or in a terminal), which is launched if user
                 in the beginning of this chapter. In fact, the           selected the -e option and allows user to move,
                 link method internally just calls parse and              rename or remove sections, definitions or refer-
                 passAndCombine one after another, without                ences using the Sections methods, mentioned
                 modifying the Sections object.                           in the previous chapter.
                     5.  Using the Standalone Linker                                        6.  Example
                 Linker can be launched from the menu in the              Complete code for the program used in the fol-
                 SicTools simulator or as a standalone program            lowing example is available in the SicDemos
                 with java -cp sictools.jar sic.Link fol-                 GitHub repository [2] under the name Link -
                 lowed by option flags and paths to input files.            Factorial.   The example links five object files
                 Available flags:                                          into one program that calculates the factorial
                                                                          of numbers 1 to 10.       Each part of the pro-
                    • -h displays instructions,                           gram is written in a separate file to better
                    • -o followed by a filename specifies the               demonstrate the linking process: stack.obj
                        output file,                                       contains routines for working with the stack,
                                                                          print.objcontains the code for displaying the
                    • -g launches the graphical version of the            result, fact.obj contains the factorial func-
                        standalone linker,                                tion, main.obj connects all the parts together
                                                                          andending.objmarkstheendoftheprogram.
                    • -f, -k and -v enable partial linking, pre-
                        serving external definitions and verbose              Hmain 0000000000F3
                        mode options respectively,                           R end fact print resultstinit
                                                                             T0000001E011 00000 4B1 00000 0100010F1 00000
                    • -m followed by a section name specifies                 T00001E154B1 00000 031 00000 4B1 00000 3F2FDB
                        which section should be first in the linked           M 000001 05+ end
                        program,                                             M 000005 05+ stinit
                    • -e will launch the section editor after                M 00000C 05+ result
                        reading the input files.                              M 00001F 05+ fact
                                                                             M 000023 05+ result
                     Thegraphical interface is shown in Figure 3             M 000027 05+ print
                 and has the same options presented in a slightly            E000000
                 different way – instead of commandline flags                  Figure 4: Part of the object file main.obj
The words contained in this file might help you see if this file matches what you are looking for:

...A linker for sic xe hypothetical computer kisek nejc abstract the article describes de multiple object code sections together loader sign and implementation of that inserts in correct part described s memory compiler converts leland beck book system software high level programming language into assem was developed as sictools collection bly an operating con consisting tools same trols resources communicates with hard we start by introduc ware overlooks user applications ing existing working is soft it followed few concepts behind link process then describe implemented utilities includes list its functionalities how sembler simulator devel to use focus on using li oped enhancing practical demonstrations brary another program but also give some course at university ljubl instructions own finally jana faculty information sci better illustrate linking ence used several faculties around show simple example world mainly courses following included assembler allows us index terms sys translate...

no reviews yet
Please Login to review.