qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] Re: [PATCH 02/40] elf: Add notes implementation


From: Alexander Graf
Subject: [Qemu-devel] Re: [PATCH 02/40] elf: Add notes implementation
Date: Mon, 1 Nov 2010 15:48:46 -0400

On 01.11.2010, at 15:43, Paolo Bonzini wrote:

> On 11/01/2010 07:52 PM, Alexander Graf wrote:
>>>> @@ -237,6 +242,8 @@ static uint64_t elf_default_translate(void *opaque, 
>>>> uint64_t addr)
>>>>  ElfHandlers elf_default_handlers = {
>>>>      .translate_fn = elf_default_translate,
>>>>      .translate_opaque = NULL,
>>>> +    .note_fn = elf_default_note,
>>>> +    .note_opaque = NULL,
>>> 
>>> Don't you have to add the definition to every user of translate_fn?
>>> 
>>> Maybe it's better to guard calls through the pointers with an if.
>> 
>> All users either pass NULL as translate (which means they default to
>> elf_default_translate) or initialize their structure with the values in
>> elf_default_translate :)
> 
> But do the MIPS users initialize note_fn?

They should:


@@ -106,8 +106,10 @@ static int64_t load_kernel (CPUState *env)
    ram_addr_t initrd_offset;
    uint32_t *prom_buf;
    long prom_size;
+    ElfHandlers handlers = elf_default_handlers;

-    if (load_elf(loaderparams.kernel_filename, cpu_mips_kseg0_to_phys, NULL,
+    handlers.translate_fn = cpu_mips_kseg0_to_phys;
+    if (load_elf(loaderparams.kernel_filename, &handlers,
                 (uint64_t *)&kernel_entry, (uint64_t *)&kernel_low,
                 (uint64_t *)&kernel_high, 0, ELF_MACHINE, 1) < 0) {
        fprintf(stderr, "qemu: could not load kernel '%s'\n",


Unless my C foo is really bad, this means that handlers is initialized with the 
contents of elf_default_handlers :). And that's how every caller works.


Alex




reply via email to

[Prev in Thread] Current Thread [Next in Thread]