• Nenhum resultado encontrado

Translating and Starting a Program

N/A
N/A
Protected

Academic year: 2023

Share "Translating and Starting a Program"

Copied!
6
0
0

Texto

(1)

#1 : Program Execution

Computer Architecture 2021/2022 Computer Architecture 2021/2022

Ricardo Rocha

Computer Science Department, Faculty of Sciences, University of Porto

(2)

Translating and Starting a Program

We can consider four hierarchical steps when transforming a C program in a file on disk into a process running on a computer:

Compiler transforms the high-level language program to an assembly language program, a symbolic form of what the machine understands

Assembler turns the assembly language program into an object file, which includes machine code, data, and information needed to execute the program

Linker combines independently object files and resolves all undefined labels into an executable file

Loader places an executable file in main memory so that it is ready to execute

(3)

Object Files

The object file for UNIX systems typically contains six distinct pieces:

Object file header describes the size and position of the other 5 pieces

Text segment contains the machine language code

Static data segment contains data allocated for the life of the program

Relocation information identifies instructions and data words that depend on absolute addresses when the program is loaded into memory

absolute addresses when the program is loaded into memory

Symbol table contains the remaining labels that are not defined, such as global definitions and external references

Debugging information contains a concise description of how the modules were compiled so that a debugger can associate machine instructions with C source files and make data structures readable

(4)

Linking Object Files

The linker uses the relocation information and symbol table in each object module to resolve all undefined labels.

Such references occur in

branch/jump instructions and branch/jump instructions and data addresses

The linker produces an

executable file that has the same format as an object file, except that it contains no

unresolved references or relocation information

(5)

Dynamic Linking

Static linking has a few disadvantages:

The library becomes part of the executable code and, if a new library version is released, the statically linked program keeps using the old version

It loads all routines in the library even if those calls are not executed

These disadvantages lead to dynamically linked libraries (DLLs) where These disadvantages lead to dynamically linked libraries (DLLs) where each library routine is loaded only when it is needed:

Initially, the main routine is loaded into memory and executed

When a routine calls another routine, the calling routine first checks to see whether the other routine has been loaded and, if not, a relocatable linking loader is called to load the desired routine into memory

A stub is included in the binary program for each library routine reference that

(6)

Dynamic Linking

Indirection table

Stub: loads routine ID Stub: loads routine ID

and jumps to linker/loader Linker/loader code

DLL code

Referências

Documentos relacionados

personality of great sociability. The fact that he originated from one of the most prominent Minahasan kin groups, and that he was affiliated with some other notable families,

assumption that, collective judgment, when properly organized, can reveal a better opinion than the one of a single person.. 2017 The research was developed in two stages. The

ƒ Com o apoio das Base de Dados de Clientes pretende-se construir relações lucrativas e duradouras, ao comunicar com o cliente certo, utilizando o produto certo, com a

(4) studies of manpower needs of medical and health personnel at all levels against the background of social and economic development and of population dynamics;

To instruct the Director to present to the X Meeting of the Directing Council the Proposed Program and Budget of the Pan American Sanitary Organization for the year 1958, as

To transmit to the Directing Council, as the Pro- posed Program and Budget of the Executive Committee, pur- suant to Chapter IV, Article 12-C, of the Constitution of the

An epidemiology training program for a specific country must take into account the health problems and available resources of that country.. Critical to the program

in 1988-1989, the 1990-1991 proposal includes program increases of _507,800 which, excep t for a small program increase of _33,600 in Caribbean Program.. Coordination, is the