diff options
| author | Fangrui Song <maskray@google.com> | 2020-02-12 14:08:42 -0800 |
|---|---|---|
| committer | Fangrui Song <maskray@google.com> | 2020-04-10 17:17:37 -0700 |
| commit | 489a7356cca373de761ada4c06c5b43edc581b4b (patch) | |
| tree | 8715d47e90c97f2ffbee5e3d89d9df0f911c9d25 /lld/test/ELF | |
| parent | d32170dbd5b0d54436537b6b75beaf44324e0c28 (diff) | |
| download | bcm5719-llvm-489a7356cca373de761ada4c06c5b43edc581b4b.tar.gz bcm5719-llvm-489a7356cca373de761ada4c06c5b43edc581b4b.zip | |
[ELF] Fix a null pointer dereference when --emit-relocs and --strip-debug are used together
Fixes https://bugs.llvm.org//show_bug.cgi?id=44878
When --strip-debug is specified, .debug* are removed from inputSections
while .rel[a].debug* (incorrectly) remain.
LinkerScript::addOrphanSections() requires the output section of a relocated
InputSectionBase to be created first.
.debug* are not in inputSections ->
output sections .debug* are not created ->
getOutputSectionName(.rel[a].debug*) dereferences a null pointer.
Fix the null pointer dereference by deleting .rel[a].debug* from inputSections as well.
Reviewed By: grimar, nickdesaulniers
Differential Revision: https://reviews.llvm.org/D74510
(cherry picked from commit 6c73246179376442705b3a545f4e1f1478777a04)
Diffstat (limited to 'lld/test/ELF')
| -rw-r--r-- | lld/test/ELF/emit-relocs-debug.s | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lld/test/ELF/emit-relocs-debug.s b/lld/test/ELF/emit-relocs-debug.s new file mode 100644 index 00000000000..04fa0f8d961 --- /dev/null +++ b/lld/test/ELF/emit-relocs-debug.s @@ -0,0 +1,20 @@ +# REQUIRES: x86 +## Test --emit-relocs handles .debug* + +# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o +# RUN: ld.lld --emit-relocs %t.o -o %t +# RUN: llvm-readobj -r %t | FileCheck %s +# RUN: ld.lld --emit-relocs --strip-debug %t.o -o %t.no +# RUN: llvm-readobj -r %t.no | FileCheck --check-prefix=NO %s + +# CHECK: Section {{.*}} .rela.debug_info { +# CHECK-NEXT: R_X86_64_64 .text 0x0 +# CHECK-NEXT: } + +# NO: Relocations [ +# NO-NEXT: ] + +foo: + +.section .debug_info +.quad foo |

