This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Position independent CODE with position dependent DATA ?
- From: John Reiser <jreiser at bitwagon dot com>
- To: "binutils at sourceware dot org >> Binutils" <binutils at sourceware dot org>
- Date: Wed, 07 Jul 2010 07:34:31 -0700
- Subject: Re: Position independent CODE with position dependent DATA ?
- References: <AANLkTiklLAtVndLrWvD4_iUJ7S1TtD3rAZ6rAEyHMfQ3@mail.gmail.com>
> Without entering into details, we *need* to declare the DATA sections
> (bss, data...) to be position dependent, i.e to fall at a fixed
> address regardless of CODE position, thus not PC-relative (unlike PIC
> is doing as default).
Have you considered using the MEMORY command of a linker script,
which allows placing a segment at a fixed address? Compile as PIC,
load with a linker script that places the ORIGIN of the DATA segment
at a numerical constant address. See "info ld".
Otherwise (or in general):
Who chooses the fixed address, and when?
Is the fixed address a constant that is known before compilation begins?
Is the fixed address the same for ALL programs, or can it vary as long
as it is the same for each instance [revision] of a given program?
Consider loading twice. Load once to get the sizes and a load map.
Write a utility program that reads the sizes and addresses and .o files,
and generates new .o files with symbols that are ABS instead of .data.
Then load a second time to generate the final program.
--