509 Commits

Author SHA1 Message Date
Chris Johns
6fae4de3c8 Fix errors building on CentOS. 2013-03-01 11:25:48 +11:00
Chris Johns
2bcaf0cdd3 Update the documentation 2013-01-23 14:04:11 +11:00
Chris Johns
e78e2b0ce5 Documentation. 2013-01-22 22:08:09 +11:00
Chris Johns
32d5401a9a Fixed the layout output to give to all the needed detail. 2013-01-15 17:03:04 +11:00
Chris Johns
6801aa22cf Use find_in_strtab when collecting symbols. Remove debug. 2013-01-01 12:04:24 +11:00
Chris Johns
f43851acc0 Sort the relocation records by offset for a section. 2012-12-31 18:29:10 +11:00
Chris Johns
4e7ec707b0 Make layout offsets match image offsets. Add a better strtab search.
The offsets of sections in objects have to be computed in load order
so the offsets work. For example an object could have a sections with
an alignment of 4 and 16 so the 4 may align with the current load
offset and the 16 is padded to align it. This is the way the image is
loaded and so the layout needs to follow these rules.

The strtab search needs to be better. An STL string find was finding
patrial strings and causing errors on the target.
2012-12-31 18:12:25 +11:00
Chris Johns
06a2cf6eb3 Sort the relocations by offset to make the overlay work. 2012-12-31 18:11:47 +11:00
Chris Johns
544de91e99 Fix managing weak symbols.
Weak symbols where not being managed correctly. The symbols table
is now a class with externals and weaks as separate symtabs so
the externals can be searched first then the weaks and if not
found an unresolved error is raised. This was found creating
a libbsdport RAP file where the drivers in the all driver table
resolved to the weak symbols and so linking in nothing.

Fixing the weak symbols as found in the libbsdport library
triggered a new resolver bug. The object files now contain the
resolver state and this is used to determine if an object file
has been resolved or is currently being resolved avoiding
rescursive loops with dependent object files.

The resolver trace output is a little easier to read.
2012-12-29 10:20:22 +11:00
Chris Johns
800d4fd748 Add the symsect offset to the section reloc. 2012-12-24 17:18:23 +11:00
Chris Johns
073d2441dc Trace the reloc addend. 2012-12-24 17:17:53 +11:00
Chris Johns
f31cded659 Improved section trace output.
Moved the section trace output to after the offsets have been
computed and add this to the output. This allows a simple way
to track the offset in an ELF section to the offset in the RAP
section.
2012-12-23 17:45:34 +11:00
Chris Johns
58250099cd Change the long opt from map to overlay. 2012-12-23 17:04:11 +11:00
Chris Johns
287569cc8a Add an overlay output.
An overlay shows the hex dump of the section data with the relocation
records so you can see the relationship between the relocations and
the section data.
2012-12-23 16:57:35 +11:00
Chris Johns
b9f631e560 Add a memory dump utility. 2012-12-23 16:57:16 +11:00
Chris Johns
3e902c68ad Fix the reloc symbol name. 2012-12-21 17:14:50 +11:00
Chris Johns
c4873564c9 Finish a dump of the RAP file. Fix expanding. 2012-12-21 17:12:07 +11:00
Chris Johns
6c28ffbf01 Set header length. Make sections public.
Set the compressed file length in the RAP header. Move
the string from the outputter to the RAP file.

Make the sections public by moving to the RAP header.
2012-12-21 17:10:18 +11:00
Chris Johns
4e9b3247a6 Decompressor fixes.
Make reading compressed files more robust returning the amount
of data that can be read. Also add >> operartors to get the
data. Add exceptions when a read fails.
2012-12-21 17:08:17 +11:00
Chris Johns
74e89db40d Turn off the debug. 2012-12-19 16:24:48 +11:00
Chris Johns
8bb0d53e58 RAP file utility. Decompressors RAP files. 2012-12-19 16:24:24 +11:00
Chris Johns
db216fec03 Decompression support added.
The compressor can now decompress LZ77 files.
2012-12-19 16:22:37 +11:00
Chris Johns
b2b811cbc7 Fixes to load libbsdports on i386.
Numerous fixes to load the the libbsdport RAP file on the i386.
2012-12-18 20:57:00 +11:00
Chris Johns
53221a0485 Add object::get_section.
Add a method to return a section given the ELF section index.

Add more trace output for debugging.
2012-12-18 20:52:18 +11:00
Chris Johns
b5a59dd96f Use cerr for errors and not cout. 2012-12-18 20:51:41 +11:00
Chris Johns
194160c9a3 Update the data out pointer.
The data pointer was not updating when looping.

Fix the total stats to track the data in the buffer.
2012-12-18 20:48:35 +11:00
Chris Johns
13b9f2b1d7 Add a new trace level. 2012-12-18 20:47:27 +11:00
Chris Johns
f10123a72f Const sections are not PROGBITS and ALLOC and not EXECINTR or WRITE. 2012-12-15 23:30:46 +11:00
Chris Johns
d54e81c971 Debug trace changes. 2012-12-15 23:19:21 +11:00
Chris Johns
b89ad2c6cb i386 related fixes
Fix the size of the section calculated in image::lay_out. It did not
correctly adjust for alignment. Make the sections being written
correctly align.
2012-12-15 22:44:58 +11:00
Chris Johns
f4d580bc73 Add the section offset to the symbol value. 2012-12-13 10:07:32 +11:00
Chris Johns
42f766f0ca Relocation fixes.
These changes implement a suitable relocation output in the image.
The code is still not working 100% but these changes are a big
improvement.
2012-12-12 21:51:03 +11:00
Chris Johns
90d8d43e4b Add support to demand load relocation records.
Support has been added to load relocation record on demand. The
relocation records are not read when the object file is first
opened and read. They are read only when being written to the
output file. This save loading lots of records into memory
from libraries to be thrown away.

The RAP format now supports writing out relocation records.
2012-12-08 09:07:30 +11:00
Chris Johns
be8e1886a3 Add doxygen support. 2012-12-08 09:05:12 +11:00
Chris Johns
825a10ea70 The symbol string is the offset into the symbol table. 2012-12-01 21:22:24 +11:00
Chris Johns
9ba89e17b0 Remove the trace on hack. 2012-12-01 08:09:02 +11:00
Chris Johns
803c60a946 RAP format up to relocation records completed.
Do not write the script into the RAP file rather just write the
init and fini labels. These are appended to the string table and
offsets in the string table added to the image.

Fi the sizes so the sections can be correctly loaded on the target.
2012-12-01 08:05:47 +11:00
Chris Johns
1a5bdef7a5 Add support for a custom RAP file format.
The file is a header and a searies of LZ77 blocks which hold the
application. The format allows for easy streaming and loading
on the target without needing the rewind or seek around the
file.
2012-11-29 19:05:19 +11:00
Chris Johns
93e80d5bbe Compress as blocks.
The LZ77 compressor works with blocks. Each block is prefixed with
a header that defines the output size of the block being compressed.
2012-11-29 19:04:12 +11:00
Chris Johns
9c70d1577d Remove the \0 character after the header. 2012-11-29 19:03:37 +11:00
Chris Johns
662c504ee0 Add the index to the section.
The index is referenced in the symbol and relocation records of ELF files
therefore we need to search for them.
2012-11-29 19:02:28 +11:00
Chris Johns
ea6f8d4c89 Add access to the value and info fields of a symbols. 2012-11-29 19:01:43 +11:00
Chris Johns
dc1c7447a4 Add machine related data to allow better checking. 2012-11-27 11:19:15 +11:00
Chris Johns
d99913fc5c Remove size_t stream operator.
On Darwin the operator works which on CentOS and FreeBSD it is seen
to be redefining the uint32_t stream operator. Too hard to provide
a generic solution so just cast in the user code.
2012-11-27 11:17:02 +11:00
Chris Johns
8190102ee7 Update to the latest framwork requirements. 2012-11-26 12:14:06 +11:00
Chris Johns
ae353d3bb0 Comment clean up. 2012-11-26 11:50:21 +11:00
Chris Johns
eb825b1deb Add RAP format support. 2012-11-26 11:09:35 +11:00
Chris Johns
cad8b53e6e Updated to reflect the framework changes. 2012-11-26 11:09:06 +11:00
Chris Johns
a458e27164 Add exit label, ELF application and Application.
Add an exit label that is called when removing an application.

Change the "applicatiion" to "elf_application" and add a custom
format called the RAP format for applications.
2012-11-26 11:07:06 +11:00
Chris Johns
076d935331 Add writing from images as well as streaming operators.
Add the ability to write to the compressed stream directly from
files::images.

Add streaming operator support which is always in a standard byte
format in the output image.
2012-11-26 11:04:57 +11:00