Skip to contentSkip to conversation

x86_64 imporatant information

DISCUSSION Ruslan Nikolaev 2 participants 3 messages Aug 20, 2005 – Aug 21, 2005

lore
Share & tools
lore
#0 lore raw

In my previous post I forgot to say about the most imporatant reason to use negative addresses.

Take a look on the following information:

---------------------------------
/usr/src/linux/vmlinux: file format elf64-x86-64
Sections:

Idx Name          Size      VMA               LMA               File off  Algn
  0 .text         00368c04  ffffffff80100000  ffffffff80100000  00100000  2**6

CONTENTS, ALLOC, LOAD, READONLY, CODE
1 __ex_table 00005470 ffffffff80468c10 ffffffff80468c10 00468c10 2**3
CONTENTS, ALLOC, LOAD, READONLY, DATA
2 .rodata 000582ea ffffffff8046e080 ffffffff8046e080 0046e080 2**5
CONTENTS, ALLOC, LOAD, READONLY, DATA
3 .pci_fixup 000007b0 ffffffff804c6370 ffffffff804c6370 004c6370 2**4
CONTENTS, ALLOC, LOAD, DATA
...
----------------------

It seems that VMA and LMA addresses are the same for Linux ELF under x86_64. I never interested such information for x86 and don't know how it will be for x86.

I think it's just because we need to use special memory model "-mcmodel=kernel" that's designed especially for kernel. Does we have problems when LMA != VMA and using this memory model? I can't find such information...

From x86_64 ABI:
------------------------

The AMD64 architecture usually does not allow to encode arbitrary 64-bit constants

as immediate operand of the instruction. Most instructions accept 32-bit

immediates that are sign extended to the 64-bit ones. Additionally the 32-bit operations

with register destinations implicitly perform zero extension making loads

of 64-bit immediates with upper half set to 0 even cheaper.

Additionally the branch instructions accept 32-bit immediate operands that

are sign extended and used to adjust instruction pointer. Similarly an instruction

pointer relative addressing mode exists for data accesses with equivalent limitations.

---------------------------------
Start your day with Yahoo! - make it your home page

#1 lore raw
Quoted 4 lines · Ruslan Nikolaev

I think it's just because we need to use special memory model "-mcmodel=kernel" that's designed especially for kernel. Does we have problems when LMA != VMA and using this memory model? I can't find such information...

You have already gotten the answer by yourself. You should specify a different address for LMA. This is called "physical address" in ELF.

Okuji

#2 lore raw

thank you

Hi!

Thank you. Yes I know that LMA and VMA can be specified differently. The main reason I asked about it is using "-mcmodel=kernel" memory model. But it seems to be not a problem. I'll try to do with different LMA and VMA.

Thank you for your answers.

Quoted 4 lines · Ruslan Nikolaev

I think it's just because we need to use special memory model "-mcmodel=kernel" that's designed especially for kernel. Does we have problems when LMA != VMA and using this memory model? I can't find such information...

You have already gotten the answer by yourself. You should specify a different address for LMA. This is called "physical address" in ELF.

Okuji

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

---------------------------------
Start your day with Yahoo! - make it your home page