From 514ac22d8f5d4d04f8d1f5a7c085996ce1786eae Mon Sep 17 00:00:00 2001 From: George Rimar Date: Wed, 4 Jul 2018 10:38:12 +0000 Subject: [PATCH] [ELF] - Add a test case for relocation pointing to deduplicated COMDAT. ELF spec doesn't allow a relocation to point to a deduplicated COMDAT section. Unfortunately this happens in practice (e.g. .eh_frame) We have a code in MarkLive.cpp for that and it was uncovered by any test case: https://github.com/llvm-mirror/lld/blob/master/ELF/MarkLive.cpp#L199 Patch adds a test. llvm-svn: 336259 --- lld/test/ELF/Inputs/comdat-discarded-reloc.s | 6 ++++++ lld/test/ELF/comdat-discarded-reloc.s | 17 +++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 lld/test/ELF/Inputs/comdat-discarded-reloc.s create mode 100644 lld/test/ELF/comdat-discarded-reloc.s diff --git a/lld/test/ELF/Inputs/comdat-discarded-reloc.s b/lld/test/ELF/Inputs/comdat-discarded-reloc.s new file mode 100644 index 0000000..9526f5ac --- /dev/null +++ b/lld/test/ELF/Inputs/comdat-discarded-reloc.s @@ -0,0 +1,6 @@ +.section .text.bar1,"aG",@progbits,group,comdat + +.section .text.bar2 +.global bar +bar: + .quad .text.bar1 diff --git a/lld/test/ELF/comdat-discarded-reloc.s b/lld/test/ELF/comdat-discarded-reloc.s new file mode 100644 index 0000000..d23baf3 --- /dev/null +++ b/lld/test/ELF/comdat-discarded-reloc.s @@ -0,0 +1,17 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/comdat-discarded-reloc.s -o %t2.o +# RUN: ld.lld -gc-sections %t.o %t2.o -o %t + +## ELF spec doesn't allow a relocation to point to a deduplicated +## COMDAT section. Unfortunately this happens in practice (e.g. .eh_frame) +## Test case checks we do not crash. + +.global bar, _start + +.section .text.foo,"aG",@progbits,group,comdat + +.section .text +_start: + .quad .text.foo + .quad bar -- 2.7.4