This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Position independent CODE with position dependent DATA ?


> 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.

-- 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]