0% found this document useful (0 votes)
13 views2 pages

Understanding Code Relocation Process

Relocation in computer science involves replacing symbolic references with actual memory addresses before program execution, typically handled by the linker during compilation or by a relocating loader at runtime. The process consists of merging object code sections and adjusting addresses to ensure they point to the correct runtime locations. A relocation table may be included in the object code header to facilitate these adjustments, with specific rules governing valid fixups based on architecture and executable models.

Uploaded by

Dheeraj Tamrakar
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views2 pages

Understanding Code Relocation Process

Relocation in computer science involves replacing symbolic references with actual memory addresses before program execution, typically handled by the linker during compilation or by a relocating loader at runtime. The process consists of merging object code sections and adjusting addresses to ensure they point to the correct runtime locations. A relocation table may be included in the object code header to facilitate these adjustments, with specific rules governing valid fixups based on architecture and executable models.

Uploaded by

Dheeraj Tamrakar
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Relocation (computer science) - Wikipedia, the free encyclopedia [Link]

org/wiki/Relocatable_code

From Wikipedia, the free encyclopedia


(Redirected from Relocatable code)

In computer science, relocation is the process of replacing symbolic references or names of libraries with
actual usable addresses in memory before running a program. It is typically done by the linker during
compilation (at compile time), although it can be done at runtime by a relocating loader. Compilers or
assemblers typically generate the executable with zero as the lower-most starting address. Before the
execution of object code, these addresses should be adjusted so that they denote the correct runtime
addresses.

Relocation is typically done in two steps:

1. Each object code has various sections like code, data, .bss etc. To combine all the objects to a single
executable, the linker merges all sections of similar type into a single section of that type. The linker
then assigns runtime addresses to each section and each symbol. At this point, the code (functions)
and data (global variables) will have unique runtime addresses.
2. Each section refers to one or more symbols which should be modified so that they point to the correct
runtime addresses.

A fixup table -- a relocation table -- can also be provided in the header of the object code file. Each "fixup"
is a pointer to an address in the object code that must be changed when the loader relocates the program.
Fixups are designed to support relocation of the program as a complete unit. In some cases, each fixup in the
table is itself relative to a base address of zero, so the fixups themselves must be changed as the loader
moves through the table.[1] In some architectures, compilers, and executable models, a fixup that crosses
certain boundaries (such as a segment boundary) or that does not lie on a word boundary is illegal and
flagged as an error by the linker.[2]

Linker (computing)
Library (computing)
Object file
Prebinding
Relocation table
Static library
Self-relocation
Position-independent code

1. ^ John R. Levine (October 1999). "Chapter 3: Object Files". Linkers and Loaders. Morgan-Kauffman.
ISBN 1-55860-496-0.
2. ^ "Borland article #15961: Coping with 'Fixup Overflow' messages" ([Link]
/web/20070324041806/[Link] . Archived from the
original ([Link] on 2007-03-24. [Link]
/web/20070324041806/[Link] Retrieved 2007-01-15.

Retrieved from "[Link]


Categories: Computer libraries | Computer library stubs

1 of 2 1/6/2011 12:28 AM
Relocation (computer science) - Wikipedia, the free encyclopedia [Link]

This page was last modified on 1 October 2010 at 20:38.


Text is available under the Creative Commons Attribution-ShareAlike License; additional terms may
apply. See Terms of Use for details.
Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc., a non-profit organization.

2 of 2 1/6/2011 12:28 AM

You might also like