[lld] r310736 - Avoid crash with local abs symbol.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 11 10:47:12 PDT 2017
Author: rafael
Date: Fri Aug 11 10:47:12 2017
New Revision: 310736
URL: http://llvm.org/viewvc/llvm-project?rev=310736&view=rev
Log:
Avoid crash with local abs symbol.
Modified:
lld/trunk/ELF/Symbols.cpp
lld/trunk/test/ELF/map-file.s
Modified: lld/trunk/ELF/Symbols.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.cpp?rev=310736&r1=310735&r2=310736&view=diff
==============================================================================
--- lld/trunk/ELF/Symbols.cpp (original)
+++ lld/trunk/ELF/Symbols.cpp Fri Aug 11 10:47:12 2017
@@ -131,8 +131,13 @@ SymbolBody::SymbolBody(Kind K, StringRef
Name(Name) {}
InputFile *SymbolBody::getFile() const {
- if (isLocal())
- return cast<InputSectionBase>(cast<DefinedRegular>(this)->Section)->File;
+ if (isLocal()) {
+ const SectionBase *Sec = cast<DefinedRegular>(this)->Section;
+ // Local absolute symbols actually have a file, but that is not currently
+ // used. We could support that by having a mostly redundant InputFile in
+ // SymbolBody, or having a special absolute section if needed.
+ return Sec ? cast<InputSectionBase>(Sec)->File : nullptr;
+ }
return symbol()->File;
}
Modified: lld/trunk/test/ELF/map-file.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/map-file.s?rev=310736&r1=310735&r2=310736&view=diff
==============================================================================
--- lld/trunk/test/ELF/map-file.s (original)
+++ lld/trunk/test/ELF/map-file.s Fri Aug 11 10:47:12 2017
@@ -25,6 +25,9 @@ bar:
.long zed - .
local:
.comm common,4,16
+.global abs
+abs = 0xAB5
+labs = 0x1AB5
// CHECK: Address Size Align Out In Symbol
// CHECK-NEXT: 0000000000200158 0000000000000030 8 .eh_frame
@@ -48,12 +51,12 @@ local:
// CHECK-NEXT: 0000000000202000 0000000000000004 0 common
// CHECK-NEXT: 0000000000000000 0000000000000008 1 .comment
// CHECK-NEXT: 0000000000000000 0000000000000008 1 <internal>:(.comment)
-// CHECK-NEXT: 0000000000000000 00000000000000f0 8 .symtab
-// CHECK-NEXT: 0000000000000000 00000000000000f0 8 <internal>:(.symtab)
+// CHECK-NEXT: 0000000000000000 0000000000000120 8 .symtab
+// CHECK-NEXT: 0000000000000000 0000000000000120 8 <internal>:(.symtab)
// CHECK-NEXT: 0000000000000000 0000000000000039 1 .shstrtab
// CHECK-NEXT: 0000000000000000 0000000000000039 1 <internal>:(.shstrtab)
-// CHECK-NEXT: 0000000000000000 000000000000002f 1 .strtab
-// CHECK-NEXT: 0000000000000000 000000000000002f 1 <internal>:(.strtab)
+// CHECK-NEXT: 0000000000000000 0000000000000038 1 .strtab
+// CHECK-NEXT: 0000000000000000 0000000000000038 1 <internal>:(.strtab)
// RUN: not ld.lld %t1.o %t2.o %t3.o %t4.a -o %t -Map=/ 2>&1 \
// RUN: | FileCheck -check-prefix=FAIL %s
More information about the llvm-commits
mailing list