[lld] r338379 - [LLD][ELF] - ICF: Check we do not fold sections which relocations reffering to absolute symbols with a different values.
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 31 06:55:25 PDT 2018
Author: grimar
Date: Tue Jul 31 06:55:25 2018
New Revision: 338379
URL: http://llvm.org/viewvc/llvm-project?rev=338379&view=rev
Log:
[LLD][ELF] - ICF: Check we do not fold sections which relocations reffering to absolute symbols with a different values.
This adds a test for the following uncovered piece of code:
https://github.com/llvm-mirror/lld/blob/master/ELF/ICF.cpp#L263
Without that lines we would crash.
Added:
lld/trunk/test/ELF/Inputs/icf-absolute2.s
lld/trunk/test/ELF/icf-absolute2.s
Added: lld/trunk/test/ELF/Inputs/icf-absolute2.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/Inputs/icf-absolute2.s?rev=338379&view=auto
==============================================================================
--- lld/trunk/test/ELF/Inputs/icf-absolute2.s (added)
+++ lld/trunk/test/ELF/Inputs/icf-absolute2.s Tue Jul 31 06:55:25 2018
@@ -0,0 +1,3 @@
+.globl a1, a2
+a1 = 1
+a2 = 2
Added: lld/trunk/test/ELF/icf-absolute2.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/icf-absolute2.s?rev=338379&view=auto
==============================================================================
--- lld/trunk/test/ELF/icf-absolute2.s (added)
+++ lld/trunk/test/ELF/icf-absolute2.s Tue Jul 31 06:55:25 2018
@@ -0,0 +1,21 @@
+# REQUIRES: x86
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %S/Inputs/icf-absolute2.s -o %t2
+# RUN: ld.lld %t %t2 -o /dev/null --icf=all --print-icf-sections | FileCheck -allow-empty %s
+
+## Test we do not crash and do not fold sections which relocations reffering to
+## absolute symbols with a different values.
+# CHECK-NOT: selected
+
+.globl _start, f1, f2
+_start:
+ ret
+
+.section .text.f1, "ax"
+f1:
+ .byte a1
+
+.section .text.f2, "ax"
+f2:
+ .byte a2
More information about the llvm-commits
mailing list