Age | Commit message (Collapse) | Author |
|
|
|
|
|
|
|
Turns out that x86-64 aligns LOAD segments to 0x200000 bytes.
Given that the mapping starts at 0x400000, there is not much room to
expand... so there will be a need to add additional LOAD headers.
|
|
Also, remove that nameptr member from symbols. It just *had* to cause
trouble.
Symbols are simply appended to the target's symbol table, which means
that LOCAL symbols are not inserted at the beginning and we are thus
ignoring an ELF spec. Might change that in the future, it's good enough
for now and it's sure not to break anything with the old symbols.
The code currently assumes that the target *has* a symbol table. We'll
have to fix that, and also remove undefined and duplicate symbols.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Ideally, the filename of the original .o file being inserted would be
used as a prefix for the sections copied over. However for now that
prefix is simply "reladd".
|
|
|
|
|
|
|
|
The memory ELF model is now a tree structure:
ELF +--> PHDRs +--> PHDR +--> Section
| | +--> Section
| | ...
| | \--> Section
| |
| +--> PHDR +--> Section
| | ...
| ...
|
\--> Orphaned sections +--> Section
...
\--> Section
This effectively introduces semantics into the binary blob we are
editing, and allows us to re-layout its contents much more easily
while keeping as close as possible to what is assumed to be the
original semantics.
As a side-effect, a first meta-function had to be introduced
(elfu_mScnForall) in order to traverse all leaves of the tree.
Much old code has been removed given the leaner environment
available now, and automated insertion of .text and .data sections
from object files into executables now works. However nothing else
is inserted (such as string tables or .bss) and no relocation takes
place yet.
|
|
Orphaned sections are not (fully) included in any LOAD PHDR and can thus
be moved and stripped at will without changing the memory image of the
program.
|
|
|
|
|
|
|
|
|
|
|
|
Sections are now sorted by file offset and sh_link dependencies between
them as well as PHDR-SHDR dependencies are deduced as much as possible.
The downside is that while the output should still work just fine, 'make
check' fails to establish binary equivalence of input and output if the
section table is reordered. Thankfully, in normal GCC binaries it is
already ordered so we don't have to worry about this.
Unfortunately the ELF spec is very lax in this regard so we have to draw
a line ourselves.
|
|
|
|
|
|
|
|
This way we can just assume that stuff works later on and keep the code
clean and simple. It especially establishes that the file has a sane
format and is thus understandable and editable.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GNU binutils' readelf gets confused with symbol versions. More analysis
needed on that.
|
|
|
|
|
|
|
|
|
|
Uses elfedit to copy itself and ensure both versions are identical.
|
|
|
|
|
|
|
|
|