aboutsummaryrefslogtreecommitdiff
path: root/gold/merge.h
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@google.com>2007-11-09 07:00:15 +0000
committerIan Lance Taylor <iant@google.com>2007-11-09 07:00:15 +0000
commit730cdc88f70c0804b5daf2259d3bd8ad29b6411b (patch)
treebdc5f06993a5579fea47d658ecb900c9586727f2 /gold/merge.h
parent0abe36f50df0f2475fec735f5c907bb7af584ab0 (diff)
downloadgdb-730cdc88f70c0804b5daf2259d3bd8ad29b6411b.zip
gdb-730cdc88f70c0804b5daf2259d3bd8ad29b6411b.tar.gz
gdb-730cdc88f70c0804b5daf2259d3bd8ad29b6411b.tar.bz2
Generate a complete exception frame header. Discard duplicate
exception frame information.
Diffstat (limited to 'gold/merge.h')
-rw-r--r--gold/merge.h92
1 files changed, 68 insertions, 24 deletions
diff --git a/gold/merge.h b/gold/merge.h
index cc554f2..630b593 100644
--- a/gold/merge.h
+++ b/gold/merge.h
@@ -31,6 +31,62 @@
namespace gold
{
+// This class manages mappings from input sections to offsets in an
+// output section. This is used where input sections are merged.
+
+class Merge_map
+{
+ public:
+ Merge_map()
+ : merge_map_()
+ { }
+
+ // Add a mapping for the bytes from OFFSET to OFFSET + LENGTH in the
+ // input section SHNDX in object OBJECT to OUTPUT_OFFSET in the
+ // output section. An OUTPUT_OFFSET of -1 means that the bytes are
+ // discarded.
+ void
+ add_mapping(Relobj* object, unsigned int shndx, off_t offset, off_t length,
+ off_t output_offset);
+
+ // Return the output offset for an input address. The input address
+ // is at offset OFFSET in section SHNDX in OBJECT. This sets
+ // *OUTPUT_OFFSET to the offset in the output section; this will be
+ // -1 if the bytes are not being copied to the output. This returns
+ // true if the mapping is known, false otherwise.
+ bool
+ get_output_offset(const Relobj* object, unsigned int shndx, off_t offset,
+ off_t *output_offset) const;
+
+ private:
+ // We build a mapping from OBJECT/SHNDX/OFFSET to an offset and
+ // length in the output section.
+ struct Merge_key
+ {
+ const Relobj* object;
+ unsigned int shndx;
+ off_t offset;
+ };
+
+ struct Merge_key_less
+ {
+ bool
+ operator()(const Merge_key&, const Merge_key&) const;
+ };
+
+ struct Merge_value
+ {
+ off_t length;
+ off_t output_offset;
+ };
+
+ typedef std::map<Merge_key, Merge_value, Merge_key_less> Merge_mapping;
+
+ // A mapping from input object/section/offset to offset in output
+ // section.
+ Merge_mapping merge_map_;
+};
+
// A general class for SHF_MERGE data, to hold functions shared by
// fixed-size constant data and string data.
@@ -41,10 +97,10 @@ class Output_merge_base : public Output_section_data
: Output_section_data(addralign), merge_map_(), entsize_(entsize)
{ }
- // Return the output address for an input address.
+ // Return the output offset for an input offset.
bool
- do_output_address(const Relobj* object, unsigned int shndx, off_t offset,
- uint64_t output_section_address, uint64_t* poutput) const;
+ do_output_offset(const Relobj* object, unsigned int shndx, off_t offset,
+ off_t* poutput) const;
protected:
// Return the entry size.
@@ -56,30 +112,15 @@ class Output_merge_base : public Output_section_data
// OBJECT to an OUTPUT_OFFSET in the output section.
void
add_mapping(Relobj* object, unsigned int shndx, off_t offset,
- off_t output_offset);
-
- private:
- // We build a mapping from OBJECT/SHNDX/OFFSET to an offset in the
- // output section.
- struct Merge_key
+ off_t length, off_t output_offset)
{
- const Relobj* object;
- unsigned int shndx;
- off_t offset;
- };
-
- struct Merge_key_less
- {
- bool
- operator()(const Merge_key&, const Merge_key&) const;
- };
-
- typedef std::map<Merge_key, off_t, Merge_key_less> Merge_map;
+ this->merge_map_.add_mapping(object, shndx, offset, length, output_offset);
+ }
+ private:
// A mapping from input object/section/offset to offset in output
// section.
Merge_map merge_map_;
-
// The entry size. For fixed-size constants, this is the size of
// the constants. For strings, this is the size of a character.
uint64_t entsize_;
@@ -221,10 +262,13 @@ class Output_merge_string : public Output_merge_base
off_t offset;
// The string itself, a pointer into a Stringpool.
const Char_type* string;
+ // The length of the string in bytes, including the null terminator.
+ size_t length;
Merged_string(Relobj *objecta, unsigned int shndxa, off_t offseta,
- const Char_type* stringa)
- : object(objecta), shndx(shndxa), offset(offseta), string(stringa)
+ const Char_type* stringa, size_t lengtha)
+ : object(objecta), shndx(shndxa), offset(offseta), string(stringa),
+ length(lengtha)
{ }
};