summaryrefslogtreecommitdiff
path: root/gold/target-reloc.h
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>2013-04-27 00:53:16 +0000
committerIan Lance Taylor <ian@airs.com>2013-04-27 00:53:16 +0000
commit0e8048633ef3388613bbf33822f708fc7331f234 (patch)
tree366262a5bd5b546a22a8b9098ee66e866f2ac49c /gold/target-reloc.h
parent6c6b70567b85aedf48d80a6de9c4747df4f1386f (diff)
* target-reloc.h (relocate_section): If the reloc offset is out of
range, pass VIEW as NULL to relocate.relocate. * arm.cc (Target_arm:Relocate::relocate): Check for a NULL view. * i386.cc (Target_i386::Relocate::relocate): Likewise. * powerpc.cc (Target_powerpc::Relocate::relocate): Likewise. * sparc.cc (Target_sparc::Relocate::relocate): Likewise. * tilegx.cc (Target_tilegx::Relocate::relocate): Likewise. * x86_64.cc (Target_x86_64::Relocate::relocate): Likewise.
Diffstat (limited to 'gold/target-reloc.h')
-rw-r--r--gold/target-reloc.h16
1 files changed, 12 insertions, 4 deletions
diff --git a/gold/target-reloc.h b/gold/target-reloc.h
index 039621c50f..cf5e389565 100644
--- a/gold/target-reloc.h
+++ b/gold/target-reloc.h
@@ -1,6 +1,6 @@
// target-reloc.h -- target specific relocation support -*- C++ -*-
-// Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012
+// Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013
// Free Software Foundation, Inc.
// Written by Ian Lance Taylor <iant@google.com>.
@@ -389,12 +389,20 @@ relocate_section(
psymval = &symval2;
}
+ // If OFFSET is out of range, still let the target decide to
+ // ignore the relocation. Pass in NULL as the VIEW argument so
+ // that it can return quickly without trashing an invalid memory
+ // address.
+ unsigned char *v = view + offset;
+ if (offset < 0 || static_cast<section_size_type>(offset) >= view_size)
+ v = NULL;
+
if (!relocate.relocate(relinfo, target, output_section, i, reloc,
- r_type, sym, psymval, view + offset,
- view_address + offset, view_size))
+ r_type, sym, psymval, v, view_address + offset,
+ view_size))
continue;
- if (offset < 0 || static_cast<section_size_type>(offset) >= view_size)
+ if (v == NULL)
{
gold_error_at_location(relinfo, i, offset,
_("reloc has bad offset %zu"),