Re: [Etherboot-developers] Mknbi is the misbehaving when reloc'd
Brought to you by:
marty_connor,
stefanhajnoczi
|
From: Eric W B. <ebi...@ln...> - 2002-09-21 20:13:31
|
Marc Singer <el...@bu...> writes: > On Sat, Sep 21, 2002 at 01:01:40PM -0600, Eric W Biederman wrote: > > There are two ways to do PIC on x86. And I have played with and implemented > > both of them. > > > > 1) Use -fPIC when you compile and actually change all of the absolute > references > > > in your code to know about the current load address. See memtest86-3.0 > > for an implemenation. The more relocations the linker can resolve > > at link time the better. > > > > I was daunted by the need to do the fixups. I'm familiar with the > MIPS and 68K where PIC code is much simpler. In the general case fixups are needed. But yes x86 needs fixups more than some. The fixup code is fairly trivial (Once you strip it down to the essentials). For doing fixups x86 is one of the friendliest architectures. > > 2) Modify the code to use a protected mode code and data segment with base != > 0. > > > This is what I have done with etherboot. If you need to refer to an absolute > > > memory location you need a virt_to_phys/phys_to_virt set of calls. This > > technique is still compatible with the existing > > real_to_prot/prot_to_real stubs in mknbi. Except for the expense > > of modifying the code this method is not to bad. > > Are you doing this in the version of etherboot you are debugging? Yes in the development version 5.1.2+ > This occurred to me. In fact, I thought that it might be simplest to > use other segment registers to make it something built-in at compile > time. No performance penalty except for the extra segment prefix and > a possible segment register load. It could be macro-ized for some > cases, though I suspect it would be necessary to perform a copy in > many cases. For absolute references I just prefer pointer arithematic. Segment loads are expensive. But you very rarely if ever need absolute references. Eric |