[Dwarf-Discuss] How best to represent multiple programs in a single file...

Relph, Richard Richard.Relph at amd.com
Tue Jan 4 08:28:42 PST 2011


Michael,
    Thanks for the reply. Below, answers to your questions...

> A couple questions:
> 
> How is this ELF executable file organized?
>
> How are these "multiple programs" represented in the executable file?
Each kernel's "text" is concatenated and placed in the same section and entries are made in the ELF symbol table to note the offset in to that section for each kernel. But only ONE kernel is ever loaded at a time and the loaded kernel's text is always located starting at 0. So if we have N kernels, we have N address 0, N address 1, and so on.

> How are these "separately loaded kernels" selected and loaded?
At execution time, the host program will access the entire ELF file and then load each kernel as needed... sort of like a DLL being identified and then entries in the DLL being invoked as needed... except that in our case, "relocation" or loading occurs as each kernel is invoked, not when the ELF is identified, which (I think) is the crux of the problem.

> DWARF doesn't depend on any particular program structure.  There is
> no requirement to have a main() function or a single entry point.
Understood. But is there an implied requirement that a given instruction location map to no more than one 'source line'? That is, after the (fixed length) bootstrap code, we have at location x different functions depending on which kernel has been invoked. I don't see how to represent this one-to-many mapping in a single instance of, say, the line number program.

> It would seem that the DWARF data for your program, with multiple
> "kernels", should describe them  correctly.  Of course, when the ELF
> file is modified to strip out code, you need to make the corresponding
> changes to the DWARF data as well.
Understood. Given an original source program, it's "full" representation as code, and the corresponding DWARF, I can produce for each individual kernel it's 'stripped' code and DWARF for that. And I know how to concatenate the stripped code for each kernel in to a the form that our system expects so that each kernel can be loaded and executed separately. But I don't know how to store the DWARF for each kernel in a single ELF file so that the standard tools can still be useful.

Thanks,
Richard


More information about the Dwarf-Discuss mailing list