centaur.git
9 years agoREADME.md: x86-32/64 support master
norly [Mon, 8 Jul 2013 15:58:48 +0000 (16:58 +0100)]
README.md: x86-32/64 support

9 years agodocs/building.md: Cleanup
norly [Mon, 8 Jul 2013 15:50:51 +0000 (16:50 +0100)]
docs/building.md: Cleanup

9 years agoREADME.md: Build instructions
norly [Mon, 8 Jul 2013 15:48:02 +0000 (16:48 +0100)]
README.md: Build instructions

9 years agoREADME.md: Add example
norly [Mon, 8 Jul 2013 15:24:09 +0000 (16:24 +0100)]
README.md: Add example

9 years agoDocument tests
norly [Fri, 28 Jun 2013 16:04:55 +0000 (17:04 +0100)]
Document tests

9 years agoMore READMEs
norly [Fri, 28 Jun 2013 15:28:51 +0000 (16:28 +0100)]
More READMEs

9 years agoGPLv2 release
norly [Fri, 28 Jun 2013 14:53:13 +0000 (15:53 +0100)]
GPLv2 release

10 years agoImplement memory management TODOs
norly [Fri, 28 Jun 2013 02:00:05 +0000 (03:00 +0100)]
Implement memory management TODOs

10 years agoAnnotate doxygen-style doxygen
norly [Fri, 28 Jun 2013 01:35:44 +0000 (02:35 +0100)]
Annotate doxygen-style

10 years agoAdd doxygen skeleton
norly [Thu, 27 Jun 2013 02:56:12 +0000 (03:56 +0100)]
Add doxygen skeleton

10 years agoAllocate .symtab during Reladd if none present cleanup
norly [Thu, 27 Jun 2013 02:20:54 +0000 (03:20 +0100)]
Allocate .symtab during Reladd if none present

10 years agoRemove unneeded struct member and fix references to it
norly [Thu, 27 Jun 2013 02:05:12 +0000 (03:05 +0100)]
Remove unneeded struct member and fix references to it

10 years agoSerialize symtab after merge in Reladd
norly [Thu, 27 Jun 2013 01:12:36 +0000 (02:12 +0100)]
Serialize symtab after merge in Reladd

10 years agoAdd test for dynamically linked global variables (stdout, etc)
norly [Thu, 27 Jun 2013 01:10:40 +0000 (02:10 +0100)]
Add test for dynamically linked global variables (stdout, etc)

10 years agoRelax restrictions on NOBITS sections
norly [Thu, 27 Jun 2013 01:06:41 +0000 (02:06 +0100)]
Relax restrictions on NOBITS sections

10 years agoDump: More info about child sections
norly [Thu, 27 Jun 2013 01:05:43 +0000 (02:05 +0100)]
Dump: More info about child sections

10 years agoMove test data256mb to end and add data64kb
norly [Thu, 27 Jun 2013 00:41:31 +0000 (01:41 +0100)]
Move test data256mb to end and add data64kb

10 years agoRemove stale Makefile in tests/src/
norly [Thu, 27 Jun 2013 00:08:53 +0000 (01:08 +0100)]
Remove stale Makefile in tests/src/

10 years agoLookup dynamically linked global variables.
norly [Thu, 27 Jun 2013 00:00:17 +0000 (01:00 +0100)]
Lookup dynamically linked global variables.

This works ONLY in position-dependent executables.

Processing position-independent code includes generating and inserting
code that finds out the current instruction address. That's beyond the
scope of editing normal executables, which are usually
position-dependent unless requested otherwise.

10 years agoOnly use -fPIC when compiling the shared object.
norly [Wed, 26 Jun 2013 23:46:07 +0000 (00:46 +0100)]
Only use -fPIC when compiling the shared object.

We can only use position-dependent global variables (R_*_COPY) in
injected code, not the position-independent R_*_GLOB_DAT as used in
shared objects.
And being able to modify the tool itself turns out to be a cool thing to
be able to.

10 years agoSeparate PLT lookup
norly [Wed, 26 Jun 2013 18:57:39 +0000 (19:57 +0100)]
Separate PLT lookup

10 years agoExpand PHDR space only if there are pages available
norly [Wed, 26 Jun 2013 18:49:58 +0000 (19:49 +0100)]
Expand PHDR space only if there are pages available

10 years agoExpand downwards only if there is enough space
norly [Wed, 26 Jun 2013 17:44:42 +0000 (18:44 +0100)]
Expand downwards only if there is enough space

10 years agoOnly make space for more PHDRs if they are in the first LOAD
norly [Wed, 26 Jun 2013 17:41:11 +0000 (18:41 +0100)]
Only make space for more PHDRs if they are in the first LOAD

10 years agoCheck for (and abort on) multiple symbol tables
norly [Tue, 25 Jun 2013 15:07:03 +0000 (16:07 +0100)]
Check for (and abort on) multiple symbol tables

10 years agoFix Makefile for Red Hat's libelf that does not support pkg-config
norly [Mon, 24 Jun 2013 03:25:43 +0000 (04:25 +0100)]
Fix Makefile for Red Hat's libelf that does not support pkg-config

10 years agoRemove assertion that breaks with Red Hat's libelf morephdr
norly [Mon, 24 Jun 2013 03:16:05 +0000 (04:16 +0100)]
Remove assertion that breaks with Red Hat's libelf

10 years agoTests for x86-64
norly [Mon, 24 Jun 2013 03:07:10 +0000 (04:07 +0100)]
Tests for x86-64

10 years agoPHDR addition. Should make x86-64 work in many cases.
norly [Sat, 22 Jun 2013 00:11:40 +0000 (01:11 +0100)]
PHDR addition. Should make x86-64 work in many cases.

10 years agomLayoutAuto: Do not move LOAD segments, and update PHDR PHDR
norly [Mon, 24 Jun 2013 02:35:44 +0000 (03:35 +0100)]
mLayoutAuto: Do not move LOAD segments, and update PHDR PHDR

10 years agoReorder PHDRs according to ELF spec
norly [Mon, 24 Jun 2013 02:34:19 +0000 (03:34 +0100)]
Reorder PHDRs according to ELF spec

10 years agomLayoutGetSpaceInPhdr: Use mPhdrLoadLowestHighest
norly [Sat, 22 Jun 2013 00:46:55 +0000 (01:46 +0100)]
mLayoutGetSpaceInPhdr: Use mPhdrLoadLowestHighest

10 years agoPHDR: Find lowest/highest addr/offs
norly [Sat, 22 Jun 2013 00:26:45 +0000 (01:26 +0100)]
PHDR: Find lowest/highest addr/offs

10 years agoreladd: Work more with sh_addr instead of sh_offset
norly [Sat, 22 Jun 2013 00:03:28 +0000 (01:03 +0100)]
reladd: Work more with sh_addr instead of sh_offset

10 years agoMinor fixes to PHDR expansion to lower addresses
norly [Sat, 22 Jun 2013 00:02:29 +0000 (01:02 +0100)]
Minor fixes to PHDR expansion to lower addresses

10 years agoPHDR: find by addr/offset
norly [Sat, 22 Jun 2013 00:00:38 +0000 (01:00 +0100)]
PHDR: find by addr/offset

10 years agoUse .rela.plt too - need this for x86-64 c90
norly [Fri, 21 Jun 2013 21:36:36 +0000 (22:36 +0100)]
Use .rela.plt too - need this for x86-64

10 years agomFromFile: Initialize *me
norly [Fri, 21 Jun 2013 21:15:01 +0000 (22:15 +0100)]
mFromFile: Initialize *me

10 years agoMinor cleanup in reladd, 2nd pass
norly [Thu, 20 Jun 2013 23:43:55 +0000 (00:43 +0100)]
Minor cleanup in reladd, 2nd pass

10 years agoMerge cloneScn() into reladd.c
norly [Thu, 20 Jun 2013 23:41:14 +0000 (00:41 +0100)]
Merge cloneScn() into reladd.c

It's the only place where we use it, and it's case-specific

10 years agoLOAD PHDRs at top level, others as children. mPhdrForall().
norly [Thu, 20 Jun 2013 22:47:01 +0000 (23:47 +0100)]
LOAD PHDRs at top level, others as children. mPhdrForall().

The reference binaries had to be updated as PHDRs are now reordered.

10 years agoAdd Elf/Phdr/Scn alloc/destroy
norly [Thu, 20 Jun 2013 22:25:09 +0000 (23:25 +0100)]
Add Elf/Phdr/Scn alloc/destroy

10 years agoExtend relocation parser to full 32/64 bits
norly [Thu, 20 Jun 2013 22:06:12 +0000 (23:06 +0100)]
Extend relocation parser to full 32/64 bits

10 years agoCleaner ElfuPhdr alloc
norly [Thu, 20 Jun 2013 21:56:34 +0000 (22:56 +0100)]
Cleaner ElfuPhdr alloc

10 years agoClean up code using ElfuScn
norly [Thu, 20 Jun 2013 18:02:44 +0000 (19:02 +0100)]
Clean up code using ElfuScn

10 years agoSeparate library code, build .a/.so
norly [Thu, 20 Jun 2013 00:56:24 +0000 (01:56 +0100)]
Separate library code, build .a/.so

10 years agoAutomate tests
norly [Wed, 19 Jun 2013 19:20:10 +0000 (20:20 +0100)]
Automate tests

10 years agoBasic detour support
norly [Tue, 18 Jun 2013 07:47:33 +0000 (08:47 +0100)]
Basic detour support

10 years agoC90 compliance, except variadic macros and TODOs
norly [Mon, 17 Jun 2013 22:34:30 +0000 (23:34 +0100)]
C90 compliance, except variadic macros and TODOs

Also removed a lot of dead code from the early days.

10 years agomv main.c -> elfucli.c, make it scriptable via args symrel
norly [Sat, 15 Jun 2013 23:47:23 +0000 (00:47 +0100)]
mv main.c -> elfucli.c, make it scriptable via args

10 years agoClean up main.c a bit
norly [Sat, 15 Jun 2013 23:15:24 +0000 (00:15 +0100)]
Clean up main.c a bit

10 years agoFactor out symbol table handling
norly [Sat, 15 Jun 2013 21:21:57 +0000 (22:21 +0100)]
Factor out symbol table handling

10 years agoRename mRelocate
norly [Sat, 15 Jun 2013 21:09:18 +0000 (22:09 +0100)]
Rename mRelocate

10 years agoBasic x86-64 support, not very usable in practice
norly [Sat, 15 Jun 2013 20:42:53 +0000 (21:42 +0100)]
Basic x86-64 support, not very usable in practice

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.

10 years agoMerge symbol tables. (Not fully ELF conformant)
norly [Sat, 15 Jun 2013 15:27:28 +0000 (16:27 +0100)]
Merge symbol tables. (Not fully ELF conformant)

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.

10 years agoFlatten symtab to file - gdb works, check breaks.
norly [Sat, 15 Jun 2013 12:27:42 +0000 (13:27 +0100)]
Flatten symtab to file - gdb works, check breaks.

10 years agoMake symtab and reltab resident in ElfuScn
norly [Sat, 15 Jun 2013 10:53:17 +0000 (11:53 +0100)]
Make symtab and reltab resident in ElfuScn

10 years agoRename CLI to elfucli
norly [Sat, 15 Jun 2013 08:17:04 +0000 (09:17 +0100)]
Rename CLI to elfucli

10 years agoRename elfedit to centaur, model to modelops
norly [Wed, 12 Jun 2013 17:41:42 +0000 (18:41 +0100)]
Rename elfedit to centaur, model to modelops

10 years agoDo not insert STRTAB sections explicitly
norly [Mon, 3 Jun 2013 01:43:18 +0000 (02:43 +0100)]
Do not insert STRTAB sections explicitly

10 years agoInsert NOBITS sections (.bss), ignore empty sections
norly [Mon, 3 Jun 2013 01:20:00 +0000 (02:20 +0100)]
Insert NOBITS sections (.bss), ignore empty sections

10 years agoGuess where unknown functions are in .rel.plt
norly [Sun, 2 Jun 2013 03:05:30 +0000 (04:05 +0100)]
Guess where unknown functions are in .rel.plt

10 years agoDisable memory dump to screen
norly [Sun, 2 Jun 2013 02:58:49 +0000 (03:58 +0100)]
Disable memory dump to screen

10 years agoBasic 32-bit SYMTAB and REL (not RELA) support
norly [Sat, 1 Jun 2013 16:42:36 +0000 (17:42 +0100)]
Basic 32-bit SYMTAB and REL (not RELA) support

10 years agoUse pkg-config
norly [Tue, 12 Feb 2013 15:44:48 +0000 (15:44 +0000)]
Use pkg-config

10 years agoSimplify includes
norly [Mon, 3 Jun 2013 01:06:44 +0000 (02:06 +0100)]
Simplify includes

10 years agoInsert section names (with fixed prefix)
norly [Fri, 31 May 2013 18:01:40 +0000 (19:01 +0100)]
Insert section names (with fixed prefix)

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".

10 years agoAuto-layout file after --reladd
norly [Fri, 31 May 2013 16:14:27 +0000 (17:14 +0100)]
Auto-layout file after --reladd

10 years agoPull out existing re-layouting code
norly [Fri, 31 May 2013 00:43:22 +0000 (01:43 +0100)]
Pull out existing re-layouting code

10 years agoMore rigorous sh_addr and sh_offset checking
norly [Thu, 30 May 2013 17:13:59 +0000 (18:13 +0100)]
More rigorous sh_addr and sh_offset checking

10 years agoRedesign data structures, make basic reladd work. newparser
norly [Thu, 30 May 2013 03:01:51 +0000 (04:01 +0100)]
Redesign data structures, make basic reladd work.

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.

10 years agoImplement orphaned sections
norly [Tue, 28 May 2013 22:34:51 +0000 (23:34 +0100)]
Implement orphaned sections

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.

10 years agoRemove old and ugly printing functions
norly [Tue, 28 May 2013 17:22:31 +0000 (18:22 +0100)]
Remove old and ugly printing functions

10 years agoAdd printing functions for models to ease debugging
norly [Tue, 28 May 2013 17:18:55 +0000 (18:18 +0100)]
Add printing functions for models to ease debugging

10 years agoFind PHDR -> PHDR dependencies
norly [Mon, 27 May 2013 16:21:52 +0000 (17:21 +0100)]
Find PHDR -> PHDR dependencies

10 years agoOnly establish PHDR->Scn relationship for PT_LOAD
norly [Mon, 27 May 2013 15:40:31 +0000 (16:40 +0100)]
Only establish PHDR->Scn relationship for PT_LOAD

10 years agoRestrict sh_link/sh_info evaluation where possible
norly [Mon, 27 May 2013 13:53:33 +0000 (14:53 +0100)]
Restrict sh_link/sh_info evaluation where possible

10 years agoAbstract model more - break 'make check'
norly [Mon, 27 May 2013 03:57:46 +0000 (04:57 +0100)]
Abstract model more - break 'make check'

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.

10 years agoTurn elfu_gPhdrContainsScn into a macro
norly [Mon, 27 May 2013 02:57:16 +0000 (03:57 +0100)]
Turn elfu_gPhdrContainsScn into a macro

10 years agoTurn elfu_gScnSizeFile into a macro
norly [Mon, 27 May 2013 02:18:00 +0000 (03:18 +0100)]
Turn elfu_gScnSizeFile into a macro

10 years agoClean up loader code
norly [Sun, 26 May 2013 21:37:02 +0000 (22:37 +0100)]
Clean up loader code

10 years agoValidate input at libelf level
norly [Sun, 26 May 2013 21:16:54 +0000 (22:16 +0100)]
Validate input at libelf level

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.

10 years agoBe more verbose
norly [Fri, 24 May 2013 23:46:12 +0000 (00:46 +0100)]
Be more verbose

10 years agoFix alignment error in mInsertSpaceBefore
norly [Fri, 24 May 2013 23:45:39 +0000 (00:45 +0100)]
Fix alignment error in mInsertSpaceBefore

10 years agoObject file injection, first part
norly [Fri, 24 May 2013 06:23:41 +0000 (07:23 +0100)]
Object file injection, first part

10 years agoMove section-in-segment.c to generic/
norly [Fri, 24 May 2013 02:48:14 +0000 (03:48 +0100)]
Move section-in-segment.c to generic/

10 years agoCleaner error handling with ELFU_WARN and ELFU_WARNELF
norly [Fri, 24 May 2013 00:07:45 +0000 (01:07 +0100)]
Cleaner error handling with ELFU_WARN and ELFU_WARNELF

10 years agoUse explicit libelf/* path in includes
norly [Thu, 23 May 2013 23:45:06 +0000 (00:45 +0100)]
Use explicit libelf/* path in includes

11 years agoTypos
norly [Sun, 24 Mar 2013 14:10:15 +0000 (15:10 +0100)]
Typos

11 years agoClean up file handling in main.c a bit
norly [Fri, 22 Mar 2013 13:43:05 +0000 (13:43 +0000)]
Clean up file handling in main.c a bit

11 years agoNOBITS expansion, for .bss etc
norly [Thu, 21 Mar 2013 18:23:57 +0000 (18:23 +0000)]
NOBITS expansion, for .bss etc

GNU binutils' readelf gets confused with symbol versions. More analysis
needed on that.

11 years agoCopy section contents into newly allocated buffers
norly [Thu, 21 Mar 2013 00:41:08 +0000 (00:41 +0000)]
Copy section contents into newly allocated buffers

11 years agoTypo
norly [Wed, 20 Mar 2013 21:06:29 +0000 (21:06 +0000)]
Typo

11 years agoImplement mInsertAfter, for post-.data injection
norly [Fri, 1 Mar 2013 18:59:57 +0000 (18:59 +0000)]
Implement mInsertAfter, for post-.data injection

11 years agoImplement mInsertBefore, for pre-.interp injection
norly [Wed, 27 Feb 2013 21:34:34 +0000 (21:34 +0000)]
Implement mInsertBefore, for pre-.interp injection

11 years agoAdd simple 'make check'
norly [Sun, 24 Feb 2013 14:02:25 +0000 (14:02 +0000)]
Add simple 'make check'

Uses elfedit to copy itself and ensure both versions are identical.

11 years agoRefactor mdoel-related code
norly [Sat, 23 Feb 2013 16:08:26 +0000 (16:08 +0000)]
Refactor mdoel-related code

11 years agoClean up ELF-related files and functions
norly [Sat, 23 Feb 2013 15:59:12 +0000 (15:59 +0000)]
Clean up ELF-related files and functions

11 years agoMerge {first,last}-section-in-segment.c
norly [Sat, 23 Feb 2013 15:47:53 +0000 (15:47 +0000)]
Merge {first,last}-section-in-segment.c

11 years agoMove headers for ELF-based operations together
norly [Sat, 23 Feb 2013 15:45:17 +0000 (15:45 +0000)]
Move headers for ELF-based operations together