summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFangrui Song <maskray@google.com>2018-11-20 17:04:11 +0000
committerFangrui Song <maskray@google.com>2018-11-20 17:04:11 +0000
commit537a5bfb7f1e9b85d615df95d7facacb5fb1638b (patch)
tree38a1e34ec0f98851c692f04306851d5246e91bc9
parentbac49ac455f01db9c986dbfbae83b17ebe796864 (diff)
downloadbcm5719-llvm-537a5bfb7f1e9b85d615df95d7facacb5fb1638b.tar.gz
bcm5719-llvm-537a5bfb7f1e9b85d615df95d7facacb5fb1638b.zip
[ELF] Allow --noinhibit-exec to produce corrupted executable with relocation overflow
Summary: When --noinhibit-exec is used, ld.bfd/gold emit errors but allow to produce corrupted executable, which is handy for debugging purpose. lld's --noinhibit-exec has a different meaning and changes some errors to warnings. This patch replaces "error" with "errorOrWarn" to exploit that property. We may revisit this: if we should keep them as errors (as ld.bfd/gold do) but allow to produce a (corrupted) executable. Reviewers: ruiu, grimar, espindola Reviewed By: grimar Subscribers: Timmmm, jhenderson, emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D54651 llvm-svn: 347327
-rw-r--r--lld/ELF/Target.h6
-rw-r--r--lld/test/ELF/x86-64-reloc-range.s2
2 files changed, 5 insertions, 3 deletions
diff --git a/lld/ELF/Target.h b/lld/ELF/Target.h
index b97522317fa..f93208e9b22 100644
--- a/lld/ELF/Target.h
+++ b/lld/ELF/Target.h
@@ -196,9 +196,9 @@ static inline void reportRangeError(uint8_t *Loc, RelType Type, const Twine &V,
Hint = "; consider recompiling with -fdebug-types-section to reduce size "
"of debug sections";
- error(ErrPlace.Loc + "relocation " + lld::toString(Type) +
- " out of range: " + V.str() + " is not in [" + Twine(Min).str() + ", " +
- Twine(Max).str() + "]" + Hint);
+ errorOrWarn(ErrPlace.Loc + "relocation " + lld::toString(Type) +
+ " out of range: " + V.str() + " is not in [" + Twine(Min).str() +
+ ", " + Twine(Max).str() + "]" + Hint);
}
// Make sure that V can be represented as an N bit signed integer.
diff --git a/lld/test/ELF/x86-64-reloc-range.s b/lld/test/ELF/x86-64-reloc-range.s
index c58a692821e..87e3379da85 100644
--- a/lld/test/ELF/x86-64-reloc-range.s
+++ b/lld/test/ELF/x86-64-reloc-range.s
@@ -1,6 +1,8 @@
// REQUIRES: x86
// RUN: llvm-mc %s -o %t.o -triple x86_64-pc-linux -filetype=obj
// RUN: not ld.lld %t.o -o /dev/null -shared 2>&1 | FileCheck %s
+// RUN: ld.lld --noinhibit-exec -shared %t.o -o %t 2>&1 | FileCheck %s
+// RUN: ls %t
// CHECK: {{.*}}:(.text+0x3): relocation R_X86_64_PC32 out of range: 2147483648 is not in [-2147483648, 2147483647]
// CHECK-NOT: relocation
OpenPOWER on IntegriCloud