From: Cary Coutant Date: Wed, 1 Feb 2017 00:32:59 +0000 (-0800) Subject: Don't allow mov-to-lea optimization for __ehdr_start. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ed35cc4a1cb76fd9ac53ad19efb97ee2caffbae9;p=binutils-gdb.git Don't allow mov-to-lea optimization for __ehdr_start. gold/ PR gold/21090 * x86_64.cc (Target_x86_64::can_convert_mov_to_lea): Add check for predefined symbol. (Target_x86_64::Relocate::relocate): Fix formatting. --- diff --git a/gold/ChangeLog b/gold/ChangeLog index 7357c08a03a..c50e1f89332 100644 --- a/gold/ChangeLog +++ b/gold/ChangeLog @@ -1,3 +1,10 @@ +2017-01-31 Cary Coutant + + PR gold/21090 + * x86_64.cc (Target_x86_64::can_convert_mov_to_lea): Add check + for predefined symbol. + (Target_x86_64::Relocate::relocate): Fix formatting. + 2017-01-23 Rahul Chaudhry * testsuite/icf_safe_so_test.sh: Use "set -e". diff --git a/gold/x86_64.cc b/gold/x86_64.cc index ffa876116a1..d21c26813c9 100644 --- a/gold/x86_64.cc +++ b/gold/x86_64.cc @@ -1046,8 +1046,11 @@ class Target_x86_64 : public Sized_target return false; // We cannot convert references to IFUNC symbols, or to symbols that // are not local to the current module. + // We can't do predefined symbols because they may become undefined + // (e.g., __ehdr_start when the headers aren't mapped to a segment). if (gsym->type() == elfcpp::STT_GNU_IFUNC - || gsym->is_undefined () + || gsym->is_undefined() + || gsym->is_predefined() || gsym->is_from_dynobj() || gsym->is_preemptible()) return false; @@ -4244,12 +4247,14 @@ Target_x86_64::Relocate::relocate( if (gsym != NULL) { gold_assert(gsym->has_got_offset(GOT_TYPE_STANDARD)); - got_offset = gsym->got_offset(GOT_TYPE_STANDARD) - target->got_size(); + got_offset = (gsym->got_offset(GOT_TYPE_STANDARD) + - target->got_size()); } else { unsigned int r_sym = elfcpp::elf_r_sym(rela.get_r_info()); - gold_assert(object->local_has_got_offset(r_sym, GOT_TYPE_STANDARD)); + gold_assert(object->local_has_got_offset(r_sym, + GOT_TYPE_STANDARD)); got_offset = (object->local_got_offset(r_sym, GOT_TYPE_STANDARD) - target->got_size()); }