[llvm] r240681 - Diagnose undefined temporary symbols.
Rafael Espindola
rafael.espindola at gmail.com
Thu Jun 25 13:10:45 PDT 2015
Author: rafael
Date: Thu Jun 25 15:10:45 2015
New Revision: 240681
URL: http://llvm.org/viewvc/llvm-project?rev=240681&view=rev
Log:
Diagnose undefined temporary symbols.
We already disallowed
.global .Lfoo
so this is reasonable.
This is a small cherry pick from r240130.
Added:
llvm/trunk/test/MC/ELF/undef-temp.s
Removed:
llvm/trunk/test/MC/ELF/undef2.s
Modified:
llvm/trunk/lib/MC/ELFObjectWriter.cpp
llvm/trunk/test/MC/ELF/discriminator.s
llvm/trunk/test/MC/ELF/undef.s
Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ELFObjectWriter.cpp?rev=240681&r1=240680&r2=240681&view=diff
==============================================================================
--- llvm/trunk/lib/MC/ELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/ELFObjectWriter.cpp Thu Jun 25 15:10:45 2015
@@ -787,10 +787,15 @@ void ELFObjectWriter::computeSymbolTable
Renames.count(&Symbol)))
continue;
+ if (Symbol.isTemporary() && Symbol.isUndefined())
+ Ctx.reportFatalError(SMLoc(), "Undefined temporary");
+
ELFSymbolData MSD;
MSD.Symbol = cast<MCSymbolELF>(&Symbol);
bool Local = Symbol.getBinding() == ELF::STB_LOCAL;
+ assert(Local || !Symbol.isTemporary());
+
if (Symbol.isAbsolute()) {
MSD.SectionIndex = ELF::SHN_ABS;
} else if (Symbol.isCommon()) {
Modified: llvm/trunk/test/MC/ELF/discriminator.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/discriminator.s?rev=240681&r1=240680&r2=240681&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/discriminator.s (original)
+++ llvm/trunk/test/MC/ELF/discriminator.s Thu Jun 25 15:10:45 2015
@@ -19,12 +19,12 @@ foo:
.long .L.debug_abbrev_begin # Offset Into Abbrev. Section
.byte 8 # Address Size (in bytes)
.byte 1 # Abbrev [1] 0xb:0x1b DW_TAG_compile_unit
- .long .Linfo_string0 # DW_AT_producer
+ .long info_string0 # DW_AT_producer
.short 12 # DW_AT_language
- .long .Linfo_string1 # DW_AT_name
+ .long info_string1 # DW_AT_name
.quad 0 # DW_AT_low_pc
.long 0 # DW_AT_stmt_list
- .long .Linfo_string2 # DW_AT_comp_dir
+ .long info_string2 # DW_AT_comp_dir
# DW_AT_APPLE_optimized
.section .debug_abbrev,"", at progbits
.L.debug_abbrev_begin:
Added: llvm/trunk/test/MC/ELF/undef-temp.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/undef-temp.s?rev=240681&view=auto
==============================================================================
--- llvm/trunk/test/MC/ELF/undef-temp.s (added)
+++ llvm/trunk/test/MC/ELF/undef-temp.s Thu Jun 25 15:10:45 2015
@@ -0,0 +1,4 @@
+// RUN: not llvm-mc -filetype=obj -triple x86_64-pc-linux %s -o - 2>&1 | FileCheck %s
+
+// CHECK: Undefined temporary
+ .long .Lfoo
Modified: llvm/trunk/test/MC/ELF/undef.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/undef.s?rev=240681&r1=240680&r2=240681&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/undef.s (original)
+++ llvm/trunk/test/MC/ELF/undef.s Thu Jun 25 15:10:45 2015
@@ -2,7 +2,6 @@
// Test which symbols should be in the symbol table
- .long .Lsym1
.Lsym2:
.Lsym3:
.Lsym4 = .Lsym2 - .Lsym3
@@ -42,15 +41,6 @@ test2_b = undef + 1
// CHECK-NEXT: Section: .rodata.str1.1
// CHECK-NEXT: }
// CHECK-NEXT: Symbol {
-// CHECK-NEXT: Name: .Lsym1
-// CHECK-NEXT: Value: 0x0
-// CHECK-NEXT: Size: 0
-// CHECK-NEXT: Binding: Global
-// CHECK-NEXT: Type: None
-// CHECK-NEXT: Other: 0
-// CHECK-NEXT: Section: Undefined
-// CHECK-NEXT: }
-// CHECK-NEXT: Symbol {
// CHECK-NEXT: Name: sym6
// CHECK-NEXT: Value: 0x0
// CHECK-NEXT: Size: 0
Removed: llvm/trunk/test/MC/ELF/undef2.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/undef2.s?rev=240680&view=auto
==============================================================================
--- llvm/trunk/test/MC/ELF/undef2.s (original)
+++ llvm/trunk/test/MC/ELF/undef2.s (removed)
@@ -1,18 +0,0 @@
-// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | llvm-readobj -s -t | FileCheck %s
-
-// Test that this produces an undefined reference to .Lfoo
-
- je .Lfoo
-
-// CHECK: Section {
-// CHECK: Name: .strtab
-
-// CHECK: Symbol {
-// CHECK: Name: .Lfoo
-// CHECK-NEXT: Value:
-// CHECK-NEXT: Size:
-// CHECK-NEXT: Binding: Global
-// CHECK-NEXT: Type:
-// CHECK-NEXT: Other:
-// CHECK-NEXT: Section:
-// CHECK-NEXT: }
More information about the llvm-commits
mailing list