summaryrefslogtreecommitdiff
path: root/rld-files.h
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2012-12-08 09:07:30 +1100
committerChris Johns <chrisj@rtems.org>2012-12-08 09:07:30 +1100
commit4c10232ae7298504c124c33a8c0dc27c86dad5b5 (patch)
treef2745cad4ebf5cb07111191fe6f0cd8b7dd22cd5 /rld-files.h
parentc6add3b2f603f4cf9be8bfe4bb4c27ccf9c086fa (diff)
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.
Diffstat (limited to 'rld-files.h')
-rw-r--r--rld-files.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/rld-files.h b/rld-files.h
index de49b4c..65934e9 100644
--- a/rld-files.h
+++ b/rld-files.h
@@ -511,6 +511,37 @@ namespace rld
};
/**
+ * A relocation record. We extract what we want because the elf::section
+ * class requires the image be left open as references are alive. We
+ * extract and keep the data we need to create the image.
+ */
+ struct relocation
+ {
+ const std::string name; //< The name of the symbol.
+ const uint32_t offset; //< The section offset.
+ const uint32_t type; //< The type of relocation record.
+ const uint32_t info; //< The ELF info field.
+ const int32_t addend; //< The constant addend.
+
+ /**
+ * Construct from an ELF relocation record.
+ */
+ relocation (const elf::relocation& er);
+
+ private:
+ /**
+ * The default constructor is not allowed due to all elements being
+ * const.
+ */
+ relocation ();
+ };
+
+ /**
+ * A container of relocations.
+ */
+ typedef std::list < relocation > relocations;
+
+ /**
* The sections attributes. We extract what we want because the
* elf::section class requires the image be left open as references are
* alive. We extract and keep the data we need to create the image.
@@ -526,12 +557,23 @@ namespace rld
const uint32_t info; //< The ELF info field.
const uint32_t flags; //< The ELF flags.
const off_t offset; //< The ELF file offset.
+ bool rela; //< Relocation records have the addend field.
+ relocations relocs; //< The sections relocations.
/**
* Construct from an ELF section.
+ *
+ * @param es The ELF section to load the object file section from.
*/
section (const elf::section& es);
+ /**
+ * Load the ELF relocations.
+ *
+ * @param es The ELF section to load the relocations from.
+ */
+ void load_relocations (const elf::section& es);
+
private:
/**
* The default constructor is not allowed due to all elements being
@@ -622,6 +664,11 @@ namespace rld
void load_symbols (symbols::table& symbols, bool local = false);
/**
+ * Load the relocations.
+ */
+ void load_relocations ();
+
+ /**
* References to the image.
*/
virtual int references () const;