[lld] r347327 - [ELF] Allow --noinhibit-exec to produce corrupted executable with relocation overflow

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 20 09:04:12 PST 2018


Author: maskray
Date: Tue Nov 20 09:04:11 2018
New Revision: 347327

URL: http://llvm.org/viewvc/llvm-project?rev=347327&view=rev
Log:
[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

Modified:
    lld/trunk/ELF/Target.h
    lld/trunk/test/ELF/x86-64-reloc-range.s

Modified: lld/trunk/ELF/Target.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.h?rev=347327&r1=347326&r2=347327&view=diff
==============================================================================
--- lld/trunk/ELF/Target.h (original)
+++ lld/trunk/ELF/Target.h Tue Nov 20 09:04:11 2018
@@ -196,9 +196,9 @@ static inline void reportRangeError(uint
     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.

Modified: lld/trunk/test/ELF/x86-64-reloc-range.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/x86-64-reloc-range.s?rev=347327&r1=347326&r2=347327&view=diff
==============================================================================
--- lld/trunk/test/ELF/x86-64-reloc-range.s (original)
+++ lld/trunk/test/ELF/x86-64-reloc-range.s Tue Nov 20 09:04:11 2018
@@ -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




More information about the llvm-commits mailing list