Transcript Document
Ştefan Stăncescu
PART I
SISTEM UTILITIES
LECTURE 4.1
LINK_LOAD
1
LINK-LOAD
Absolute loader
Loading of an object file (asembled with a
assembler, compiler, etc.)
=> object file prepare and transfer
in machine memory
Absolute loader
when loading is direct, without preparing
at address specified in the
object file format specified address
(Simple systems, embedded processors)
2
LINK-LOAD
Absolute loader
3
LINK-LOAD
Relocatability
Relocatability ability, for an object file
loaded (with minimum modifications) at
any address in memory
of being able to work well.
1. For linking
more obj. file in a single compact obj. file
2. For dynamic memory management
4
LINK-LOAD
Relocatable object file format
Address modifier M separate section
Name
No. crt. byte
Modifier
1
Field semantic
Field character „M”
2-3
Modification size
4-35
Relative location addresses in
object file format “C” section,
which are needed to be modified
before link-load for relocatability
5
LINK-LOAD
Relocatable object file format
Relocation mask in section “C”
Name
No. crt. byte
Field semantic
Content
16
Object field code, character „C”
17-18
Current stripe starting address
19-20
Current stripe length
21-36
Code length / 8 = relocation mask length
37-164
Assembled object code
(128 bytes as example),
165-576
Repeat n(=3 times as example) the 17164 zone
6
LINK-LOAD
References
References symbolic names in link process,
names transmitted between object files - modules
defined in one single object module
used in many (any other object modules).
EXTERN references symbolic names
defined in another object module than
the object module in which they are used.
PUBLIC references symbolic names
defined in current object module but able to be used in
another object modules
7
LINK-LOAD
Relocatable object file format
PUBLIC references
Name
No. crt. byte
Field semantic
PUBLIC
1
PUBLIC field code, character „D”,
2-9
PUBLIC symbolic name identifier
10-13
Relative address PUBLIC symbol name, in the
originating object code
14-73
Repeat 2-13 positions, for any other PUBLIC
name symbols (5 as example)
8
LINK-LOAD
Relocatable object file format
EXTERN references
Name
No. crt. byte
Field semantic
EXTERN
1
EXTERN field code, character „E”,
2-9
EXTERN symbolic name identifier
10-44
Repeat 2-9 positions, for any other
EXTERN name symbols (5 as
example)
9
LINK-LOAD
Linking
Link-editing or, shortly, linking, is
the modify address process
for a relocatable object file,
in view to join another object files,
with the aim to constitute a compact object file.
The corresponding system utility is the link-editor
(linker).
Following a link, the obtained linked object file is
relocatable and
may be linked further to another object files
10
LINK-LOAD
Linking
Address expression calculus in source files issue:
for arithmetic expressions with relative addresses
the calculus must gives an relative address result
that must not depend of real address location of
the linked object file, loaded in real memory at
an address determined at the load time.
Not all arithmetic expressions are equally permitted
A correct expression must have only invariants at
loading time, (no + or * or /, only -) as in,
LUNGIME_ZONA EQU END_ZONA – START_ZONA
11
LINK-LOAD
Static link
Static link generate a new relocatable object file,
compact and remanent, to be loaded in any place
in memory, established by the operating system
before each run.
Static link efficiency – when stable, repetitive
general conditions and products in the process
development at each run
In such case, link time is only used at first run, others
are for free.
12
LINK-LOAD
Dynamic link
Dynamic link
postpone link work until
the last moment before each run,
only needed object files are chosen and linked
taking in account about program run state
determined by current processing values
obtained from current input data.
The memory space is optimized,
spares, not needed object files are
not linked, nor loaded in the memory
13
LINK-LOAD
Linker and loader
14
LINK-LOAD
Link-loader
15
LINK-LOAD
LINK EDITOR - EXEMPLE
LINK- EDITOR DATA STRUCTURES
ESTAB - table with
module names associated with address locations in the final object file,
EXTERN and PUBLIC references names,
for PUBLIC references, their addresses in the final linked module.
PROGADR - address register for linked program module load address;
CSADR
- current module first code address register with
the reference address for all relative addresses of the
current object module in linking process.
CSLTH
- current module length register.
EXECADR - execution address register with starting program address.
16
LINK-LOAD
EDITOR DE LEGATURI - EXEMPLU - PAS I
17
LINK-LOAD
EDITOR DE LEGATURI - EXEMPLU - PAS II
18