Impact: fix vmlinux from 2.6.30

from 2.6.30 (?)
the new vmlinux with per_cpu and brk support will have more sections.

Elf file type is EXEC (Executable file)
Entry point 0x200000
There are 7 program headers, starting at offset 64

Program Headers:
  Type           Offset             VirtAddr           PhysAddr
                 FileSiz            MemSiz              Flags  Align
  LOAD           0x0000000000200000 0xffffffff80200000 0x0000000000200000
                 0x0000000000e46000 0x0000000000e46000  R E    200000
  LOAD           0x0000000001046000 0xffffffff81046000 0x0000000001046000
                 0x00000000001406e0 0x00000000001406e0  RWE    200000
  LOAD           0x0000000001200000 0xffffffffff600000 0x0000000001187000
                 0x0000000000000888 0x0000000000000888  RWE    200000
  LOAD           0x0000000001388000 0xffffffff81188000 0x0000000001188000
                 0x000000000008a086 0x000000000008a086  RWE    200000
  LOAD           0x0000000001600000 0x0000000000000000 0x0000000001213000
                 0x0000000000015e20 0x0000000000015e20  RWE    200000
  LOAD           0x0000000001629000 0xffffffff81229000 0x0000000001229000
                 0x0000000000000000 0x0000000000208000  RWE    200000
  NOTE           0x0000000000b3c7e8 0xffffffff80b3c7e8 0x0000000000b3c7e8
                 0x0000000000000024 0x0000000000000024         4

 Section to Segment mapping:
  Segment Sections...
   00     .text .notes __ex_table .rodata __bug_table .pci_fixup .builtin_fw __ksymtab __ksymtab_gpl __ksymtab_strings __init_rodata __param 
   01     .data .init.rodata .data.cacheline_aligned .data.read_mostly 
   02     .vsyscall_0 .vsyscall_fn .vsyscall_gtod_data .vsyscall_1 .vsyscall_2 .vgetcpu_mode .jiffies 
   03     .data.init_task .smp_locks .init.text .init.data .init.setup .initcall.init .con_initcall.init .x86_cpu_dev.init .altinstructions .altinstr_replacement .exit.text .init.ramfs 
   04     .data.percpu 
   05     .bss .brk 
   06     .notes 

So need to increase NR_SECTIONS.

also fix one typo about phys address mask.

Peter says: A similar fix was also implemented by Maciej Pijanka, so let's
commit this now, eh.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Acked-by: Ronald G. Minnich <rminnich@gmail.com>
Acked-by: Peter Stuge <peter@stuge.se>


git-svn-id: svn://svn.coreboot.org/coreboot/trunk@4377 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
This commit is contained in:
Yinghai Lu 2009-06-28 15:04:06 +00:00 committed by Peter Stuge
parent 3ddbfb8901
commit 3f57548625
1 changed files with 12 additions and 6 deletions

View File

@ -157,14 +157,16 @@ char *linux_i386_probe(char *kernel_buf, off_t kernel_size)
return result;
}
#define NR_SECTIONS 16
struct kernel_info
{
int phdrs;
void *kernel[4];
size_t filesz[4];
size_t memsz[4];
size_t paddr[4];
size_t vaddr[4];
void *kernel[NR_SECTIONS];
size_t filesz[NR_SECTIONS];
size_t memsz[NR_SECTIONS];
size_t paddr[NR_SECTIONS];
size_t vaddr[NR_SECTIONS];
size_t entry;
size_t switch_64;
char *version;
@ -182,6 +184,8 @@ static void parse_elf32_kernel(struct kernel_info *info, char *kernel_buf, size_
for(i = 0; i < le16_to_cpu(ehdr->e_phnum); i++) {
if (le32_to_cpu(phdr[i].p_type) != PT_LOAD)
continue;
if(phdrs == NR_SECTIONS)
die("NR_SECTIONS is too small\n");
info->kernel[phdrs] = kernel_buf + le32_to_cpu(phdr[i].p_offset);
info->filesz[phdrs] = le32_to_cpu(phdr[i].p_filesz);
info->memsz[phdrs] = le32_to_cpu(phdr[i].p_memsz);
@ -212,10 +216,12 @@ static void parse_elf64_kernel(struct kernel_info *info, char *kernel_buf, size_
for(i = 0; i < le16_to_cpu(ehdr->e_phnum); i++) {
if (le32_to_cpu(phdr[i].p_type) != PT_LOAD)
continue;
if(phdrs == NR_SECTIONS)
die("NR_SECTIONS is too small\n");
info->kernel[phdrs] = kernel_buf + le64_to_cpu(phdr[i].p_offset);
info->filesz[phdrs] = le64_to_cpu(phdr[i].p_filesz);
info->memsz[phdrs] = le64_to_cpu(phdr[i].p_memsz);
info->paddr[phdrs] = le64_to_cpu(phdr[i].p_paddr) & 0xffffff;
info->paddr[phdrs] = le64_to_cpu(phdr[i].p_paddr) & 0xfffffff;
info->vaddr[phdrs] = le64_to_cpu(phdr[i].p_vaddr);
phdrs++;
}