Re: [Etherboot-developers] Mknbi is the misbehaving when reloc'd
Brought to you by:
marty_connor,
stefanhajnoczi
|
From: Marc S. <el...@bu...> - 2002-09-21 20:05:42
|
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. > 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? 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. Cheers. |