4 ms·
Count me as being not a fan of ELF. One can have e_phoff or e_shoff or both... or I suppose neither. Because you can have both, they can conflict. If you have
by burfog 8y ago
Count me as being not a fan of ELF.
One can have e_phoff or e_shoff or both... or I suppose neither. Because you can have both, they can conflict. If you have e_phoff, then within that there is the issue of p_vaddr and p_paddr. You could have one or the other or both, or I suppose neither. They can thus conflict. The various flags associated with these things can also conflict.
This comes up often with boot loaders and kernels. There are versions of Linux that are described by p_vaddr, p_paddr, and sh_addr. Sometimes one or another has an offset added/subtracted, or is zero, or is simply missing or worse.
None of the above even makes sense once you add ASLR. I have no idea how that is expressed, but I'm pretty certain it is a gross hack. There just isn't a proper way to express such a thing.
Needlessly, there are two types of symbols. They could conflict. Better formats just use a flag bit.
BTW, when I hand-generate ELF files, I hit bugs in BFD. I recall hitting one that relates to string tables, with BFD refusing to accept an index of 0. I had to add a useless NUL byte.
- gumby 8y agoI'm not really sure what your point is; program and section headers are different things. ASLR is, relatively speaking, a recent invention (when compared to ELF). ELF describes memory layout, so if you want to randomize it you pretty much have to do your relocation at runtime...which you can do except for the entry point, but I suppose you could make an extension to relocate even that. For that one small thing I think you could propose a revision to the ELF spec. And I'm sure there are still bugs in bfd! But with ELF being pretty pervasive these days that 30 year-old (just noticed that: 1989-2019) software is less useful than it used to be. But feel free to send in a bug fix if you can't have a string table index of 0 (it would surprise me if that bug really exists, but stranger things have happened...)
- burfog 8y agoProgram and section headers are different things only because ELF makes it so, and this is a bad design. The same mostly goes for having both physical and virtual addresses. Has there ever even existed a loader that would generate page tables according to that? There should have been one kind of address, and possibly header flags to indicate allowable MMU states. If there is no such bug, then you can stop wasting that byte at the beginning of the string tables.