diff options
author | Rahul Chaudhry <rahulchaudhry@google.com> | 2018-03-26 12:06:01 -0700 |
---|---|---|
committer | Rahul Chaudhry <rahulchaudhry@google.com> | 2018-03-26 12:10:52 -0700 |
commit | b4a70cbe16cb2549cc554be9f995cfd515442c6b (patch) | |
tree | 1617aeedbfca2349489397204ad988a7bf8d6dda | |
parent | 41d8fcbbadfde8f3de3bf4b2e3d3f2736033cc22 (diff) | |
download | binutils-b4a70cbe16cb2549cc554be9f995cfd515442c6b.tar.gz |
gold: better error message on seeing odd offset for RELR relocation.
Print a more informative error message instead of asserting out.
This prints errors for all the odd offsets before exiting gold.
Bug: None
Test: Verified error message on linking test binary with odd offset.
Change-Id: Ib481a4983cac2e637b1128ea0559d9606e671c35
-rw-r--r-- | binutils-2.27/gold/dwp.h | 5 | ||||
-rw-r--r-- | binutils-2.27/gold/output.h | 15 |
2 files changed, 18 insertions, 2 deletions
diff --git a/binutils-2.27/gold/dwp.h b/binutils-2.27/gold/dwp.h index c0c4d567..4538a199 100644 --- a/binutils-2.27/gold/dwp.h +++ b/binutils-2.27/gold/dwp.h @@ -84,6 +84,11 @@ gold_exit(Exit_status status) ATTRIBUTE_NORETURN; extern void gold_fatal(const char* format, ...) ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF_1; +// This function is called to issue an error. This will cause gold to +// eventually exit with failure. +extern void +gold_error(const char* msg, ...) ATTRIBUTE_PRINTF_1; + // This function is called to issue a warning. extern void gold_warning(const char* msg, ...) ATTRIBUTE_PRINTF_1; diff --git a/binutils-2.27/gold/output.h b/binutils-2.27/gold/output.h index 78fd4265..f4b8e5eb 100644 --- a/binutils-2.27/gold/output.h +++ b/binutils-2.27/gold/output.h @@ -27,6 +27,10 @@ #include <list> #include <vector> +// __STDC_FORMAT_MACROS is needed to turn on macros in <inttypes.h>. +#define __STDC_FORMAT_MACROS +#include <inttypes.h> + #include "elfcpp.h" #include "mapfile.h" #include "layout.h" @@ -2523,8 +2527,15 @@ class Output_data_reloc<elfcpp::SHT_RELR, dynamic, size, big_endian> while (curr != this->relocs_.end()) { Address current = curr->rel_.get_address(); - // Odd addresses are not supported in SHT_RELR. - gold_assert(current%2 == 0); + if (current%2 != 0) + { + // Odd addresses are not supported in SHT_RELR. + gold_error( + _("odd offset for RELR relocation (0x%" PRIx64 "), " + "pass --no-experimental-use-relr flag " + "to disable RELR dynamic relocations"), + static_cast<uint64_t>(current)); + } Relr_Data bits = 0; typename Relocs::iterator next = curr; |