[PATCH] D44601: LLD: Avoid segfault on FreeBSD with --emit-relocs
Alexander Richardson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 17 15:41:18 PDT 2018
arichardson added inline comments.
================
Comment at: ELF/Writer.cpp:101
cast<InputSection>(S)->getRelocatedSection()->getOutputSection();
+ if (!Out)
+ return "";
----------------
It seems like the problem here is that when this is called with `.rela.eh_frame` getRelocatedSection() returns an `EhInputSection` where `->getParent()` returns null.
If I link the test file with ld.bfd it contains relocations so we should probably be emitting the same output and not just omit the relocations:
```
Relocations [
Section (3) .rela.eh_frame {
0x4000A0 R_X86_64_PC32 .text 0x0
}
]
```
================
Comment at: test/ELF/emit-relocs-freebsd.s:2
+# REQUIRES: x86
+# RUN: llvm-mc -triple=x86_64-unknown-freebsd -filetype=obj %s -o %t1.o
+# RUN: ld.lld %t1.o --emit-relocs -o %t
----------------
Possibly add a llvm-readobj invocation here to show that the input file contains relocations:
```
Relocations [
Section (4) .rela.eh_frame {
0x20 R_X86_64_PC32 .text 0x0
}
]
```
================
Comment at: test/ELF/emit-relocs-freebsd.s:6
+
+## Check single dash form.
+# RUN: ld.lld -emit-relocs %t1.o -o %t1
----------------
I don't there is much point in testing the aliases for `--emit-relocs` here. It is already done in `emit-relocs.s`
================
Comment at: test/ELF/emit-relocs-freebsd.s:8
+# RUN: ld.lld -emit-relocs %t1.o -o %t1
+# RUN llvm-read-obj -t -r -s %t1 | FileCheck %s
+
----------------
This line is not actually running llvm-readobj
================
Comment at: test/ELF/emit-relocs-freebsd.s:24
+# CHECK-NEXT: ]
+# CHECK-NEXT: Symbols [
+# CHECK-NEXT: Symbol {
----------------
I don't think we need to check the symbols in this test. This is about not crashing on relocations in .eh_frame and --emit-relocs
Repository:
rLLD LLVM Linker
https://reviews.llvm.org/D44601
More information about the llvm-commits
mailing list