diff options
author | Ian Lance Taylor <iant@google.com> | 2008-02-29 00:04:06 +0000 |
---|---|---|
committer | Ian Lance Taylor <iant@google.com> | 2008-02-29 00:04:06 +0000 |
commit | 8f2eb564ddf8002e343bd917a1f1e62f6412e862 (patch) | |
tree | e5d97984c7493e519018e1c759bd9418644ed3f3 /gold/expression.cc | |
parent | 46132b50a2d5b5fa2662e6b7c071fa47898a2fe1 (diff) | |
download | gdb-8f2eb564ddf8002e343bd917a1f1e62f6412e862.zip gdb-8f2eb564ddf8002e343bd917a1f1e62f6412e862.tar.gz gdb-8f2eb564ddf8002e343bd917a1f1e62f6412e862.tar.bz2 |
Permit scripts to refer to the addresses of output sections which were
not created.
Diffstat (limited to 'gold/expression.cc')
-rw-r--r-- | gold/expression.cc | 49 |
1 files changed, 44 insertions, 5 deletions
diff --git a/gold/expression.cc b/gold/expression.cc index 28d385b..25f3ac3 100644 --- a/gold/expression.cc +++ b/gold/expression.cc @@ -646,6 +646,11 @@ class Section_expression : public Expression Output_section*) = 0; // The child class must implement this. + virtual uint64_t + value_from_script_output_section(uint64_t address, uint64_t load_address, + uint64_t addralign, uint64_t size) = 0; + + // The child class must implement this. virtual const char* function_name() const = 0; @@ -658,14 +663,28 @@ Section_expression::value(const Expression_eval_info* eei) { const char* section_name = this->section_name_.c_str(); Output_section* os = eei->layout->find_output_section(section_name); - if (os == NULL) + if (os != NULL) + return this->value_from_output_section(eei, os); + + uint64_t address; + uint64_t load_address; + uint64_t addralign; + uint64_t size; + const Script_options* ss = eei->layout->script_options(); + if (ss->saw_sections_clause()) { - gold_error("%s called on nonexistent output section '%s'", - this->function_name(), section_name); - return 0; + if (ss->script_sections()->get_output_section_info(section_name, + &address, + &load_address, + &addralign, + &size)) + return this->value_from_script_output_section(address, load_address, + addralign, size); } - return this->value_from_output_section(eei, os); + gold_error("%s called on nonexistent output section '%s'", + this->function_name(), section_name); + return 0; } // ABSOLUTE function. @@ -792,6 +811,11 @@ class Addr_expression : public Section_expression return os->address(); } + uint64_t + value_from_script_output_section(uint64_t address, uint64_t, uint64_t, + uint64_t) + { return address; } + const char* function_name() const { return "ADDR"; } @@ -818,6 +842,11 @@ class Alignof_expression : public Section_expression Output_section* os) { return os->addralign(); } + uint64_t + value_from_script_output_section(uint64_t, uint64_t, uint64_t addralign, + uint64_t) + { return addralign; } + const char* function_name() const { return "ALIGNOF"; } @@ -988,6 +1017,11 @@ class Loadaddr_expression : public Section_expression } } + uint64_t + value_from_script_output_section(uint64_t, uint64_t load_address, uint64_t, + uint64_t) + { return load_address; } + const char* function_name() const { return "LOADADDR"; } @@ -1020,6 +1054,11 @@ class Sizeof_expression : public Section_expression return os->current_data_size(); } + uint64_t + value_from_script_output_section(uint64_t, uint64_t, uint64_t, + uint64_t size) + { return size; } + const char* function_name() const { return "SIZEOF"; } |