diff options
author | Kevin Enderby <enderby@apple.com> | 2012-01-31 23:02:57 +0000 |
---|---|---|
committer | Kevin Enderby <enderby@apple.com> | 2012-01-31 23:02:57 +0000 |
commit | e1a12cf3eeb1b87b01f6e9873f53cd008c7b50b0 (patch) | |
tree | f4ec0b1cda63eb6017ec821c28c4d0d8627a4e85 /llvm | |
parent | 9ccdb1d01bf98b47205f51a024a9ea4d5dd135d0 (diff) | |
download | bcm5719-llvm-e1a12cf3eeb1b87b01f6e9873f53cd008c7b50b0.tar.gz bcm5719-llvm-e1a12cf3eeb1b87b01f6e9873f53cd008c7b50b0.zip |
Fixed a crash in llvm-mc for Mach-O when a symbol difference expression uses a
symbol from an assignment. In this case the symbol did not have a fragment so
MCObjectWriter::IsSymbolRefDifferenceFullyResolved() should not have been
calling IsSymbolRefDifferenceFullyResolvedImpl() with a NULL fragment and should
just have returned false in that case.
llvm-svn: 149442
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/lib/MC/MCObjectWriter.cpp | 2 | ||||
-rw-r--r-- | llvm/test/MC/MachO/darwin-x86_64-diff-reloc-assign.s | 27 |
2 files changed, 29 insertions, 0 deletions
diff --git a/llvm/lib/MC/MCObjectWriter.cpp b/llvm/lib/MC/MCObjectWriter.cpp index 18887397ab6..030f24793c5 100644 --- a/llvm/lib/MC/MCObjectWriter.cpp +++ b/llvm/lib/MC/MCObjectWriter.cpp @@ -68,6 +68,8 @@ MCObjectWriter::IsSymbolRefDifferenceFullyResolved(const MCAssembler &Asm, const MCSymbolData &DataA = Asm.getSymbolData(SA); const MCSymbolData &DataB = Asm.getSymbolData(SB); + if(!DataA.getFragment() || !DataB.getFragment()) + return false; return IsSymbolRefDifferenceFullyResolvedImpl(Asm, DataA, *DataB.getFragment(), diff --git a/llvm/test/MC/MachO/darwin-x86_64-diff-reloc-assign.s b/llvm/test/MC/MachO/darwin-x86_64-diff-reloc-assign.s new file mode 100644 index 00000000000..49cfa418162 --- /dev/null +++ b/llvm/test/MC/MachO/darwin-x86_64-diff-reloc-assign.s @@ -0,0 +1,27 @@ +// RUN: llvm-mc -triple x86_64-apple-darwin9 %s -filetype=obj -o - | macho-dump --dump-section-data | FileCheck %s + +// Test case for rdar://10743265 + +// This tests that this expression does not cause a crash and produces two +// relocation entries: +// Relocation information (__TEXT,__text) 2 entries +// address pcrel length extern type scattered symbolnum/value +// 00000000 False long True SUB False _base +// 00000000 False long True UNSIGND False _start_ap_2 + +_base = . + +.long (0x2000) + _start_ap_2 - _base +.word 0 + +_start_ap_2: + cli + +// CHECK: ('_relocations', [ +// CHECK: # Relocation 0 +// CHECK: (('word-0', 0x0), +// CHECK: ('word-1', 0x5c000000)), +// CHECK: # Relocation 1 +// CHECK: (('word-0', 0x0), +// CHECK: ('word-1', 0xc000001)), +// CHECK: ]) |