Diagnose undefined temporary symbols.

We already disallowed

.global .Lfoo

so this is reasonable.

This is a small cherry pick from r240130.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240681 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola 2015-06-25 20:10:45 +00:00
parent f2c0530fca
commit 1de6f369b3
5 changed files with 12 additions and 31 deletions

View File

@ -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()) {

View File

@ -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,"",@progbits
.L.debug_abbrev_begin:

4
test/MC/ELF/undef-temp.s Normal file
View File

@ -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

View File

@ -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

View File

@ -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: }