centaur.git
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

11 years agoMove ELF-related files together
norly [Sat, 23 Feb 2013 15:41:35 +0000 (15:41 +0000)]
Move ELF-related files together

11 years agoRemove ELFU_BOOL
norly [Sat, 23 Feb 2013 15:36:30 +0000 (15:36 +0000)]
Remove ELFU_BOOL

11 years agoAdd run-time sanity checks
norly [Sat, 23 Feb 2013 01:46:32 +0000 (01:46 +0000)]
Add run-time sanity checks

11 years agoUse CIRCLEQ_FOREACH throughout
norly [Fri, 22 Feb 2013 18:35:12 +0000 (18:35 +0000)]
Use CIRCLEQ_FOREACH throughout

11 years agoAdd elfu_count{Section,PHDR}s
norly [Fri, 22 Feb 2013 16:58:14 +0000 (16:58 +0000)]
Add elfu_count{Section,PHDR}s

11 years agoRemove --copy, do it whenever we have -o
norly [Fri, 22 Feb 2013 16:51:58 +0000 (16:51 +0000)]
Remove --copy, do it whenever we have -o

11 years agoFix build on Ubuntu 12.04
norly [Tue, 12 Feb 2013 15:37:21 +0000 (15:37 +0000)]
Fix build on Ubuntu 12.04

Thanks to Cristian Cadar.

11 years agoPHDR self-reference fixup function model-cleanup
norly [Mon, 11 Feb 2013 01:10:27 +0000 (01:10 +0000)]
PHDR self-reference fixup function

11 years agoMakefile: debug option - attach to running instance
norly [Mon, 11 Feb 2013 01:08:31 +0000 (01:08 +0000)]
Makefile: debug option - attach to running instance

11 years agoModel to ELF (writing) support, copy functionality
norly [Sun, 10 Feb 2013 18:39:15 +0000 (18:39 +0000)]
Model to ELF (writing) support, copy functionality

11 years agoFirst memory model of an ELF file
norly [Sun, 10 Feb 2013 00:36:16 +0000 (00:36 +0000)]
First memory model of an ELF file

11 years agoPrint ELF header/segments/sections
norly [Fri, 25 Jan 2013 15:24:36 +0000 (15:24 +0000)]
Print ELF header/segments/sections

11 years agoAdd .gitignore
norly [Fri, 25 Jan 2013 15:24:21 +0000 (15:24 +0000)]
Add .gitignore

11 years agoInitial commit
norly [Fri, 25 Jan 2013 15:24:14 +0000 (15:24 +0000)]
Initial commit