[llvm-commits] [llvm] r121085 - in /llvm/trunk: lib/MC/MachObjectWriter.cpp test/MC/MachO/symbol-diff.s
Rafael Espindola
rafael.espindola at gmail.com
Mon Dec 6 17:09:54 PST 2010
Author: rafael
Date: Mon Dec 6 19:09:54 2010
New Revision: 121085
URL: http://llvm.org/viewvc/llvm-project?rev=121085&view=rev
Log:
Fix a crash reduced from gcc produced assembly.
Added:
llvm/trunk/test/MC/MachO/symbol-diff.s
Modified:
llvm/trunk/lib/MC/MachObjectWriter.cpp
Modified: llvm/trunk/lib/MC/MachObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MachObjectWriter.cpp?rev=121085&r1=121084&r2=121085&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MachObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/MachObjectWriter.cpp Mon Dec 6 19:09:54 2010
@@ -564,14 +564,10 @@
if (A_Base == B_Base && A_Base)
report_fatal_error("unsupported relocation with identical base");
- assert((A_Base == NULL) == (B_Base == NULL));
- assert(A_SD.getFragment()->getParent() ==
- B_SD.getFragment()->getParent());
-
- Value += Layout.getSymbolOffset(&A_SD) -
- (A_Base == NULL ? 0 : Layout.getSymbolOffset(A_Base));
- Value -= Layout.getSymbolOffset(&B_SD) -
- (B_Base == NULL ? 0 : Layout.getSymbolOffset(B_Base));
+ Value += getSymbolAddress(&A_SD, Layout) -
+ (A_Base == NULL ? 0 : getSymbolAddress(A_Base, Layout));
+ Value -= getSymbolAddress(&B_SD, Layout) -
+ (B_Base == NULL ? 0 : getSymbolAddress(B_Base, Layout));
if (A_Base) {
Index = A_Base->getIndex();
Added: llvm/trunk/test/MC/MachO/symbol-diff.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/MachO/symbol-diff.s?rev=121085&view=auto
==============================================================================
--- llvm/trunk/test/MC/MachO/symbol-diff.s (added)
+++ llvm/trunk/test/MC/MachO/symbol-diff.s Mon Dec 6 19:09:54 2010
@@ -0,0 +1,122 @@
+// RUN: llvm-mc -triple x86_64-apple-darwin10 %s -filetype=obj -o - | macho-dump --dump-section-data | FileCheck %s
+_g:
+LFB2:
+ .section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support
+_g.eh:
+ .quad LFB2-.
+
+// CHECK: ('cputype', 16777223)
+// CHECK-NEXT: ('cpusubtype', 3)
+// CHECK-NEXT: ('filetype', 1)
+// CHECK-NEXT: ('num_load_commands', 3)
+// CHECK-NEXT: ('load_commands_size', 336)
+// CHECK-NEXT: ('flag', 0)
+// CHECK-NEXT: ('reserved', 0)
+// CHECK-NEXT: ('load_commands', [
+// CHECK-NEXT: # Load Command 0
+// CHECK-NEXT: (('command', 25)
+// CHECK-NEXT: ('size', 232)
+// CHECK-NEXT: ('segment_name', '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
+// CHECK-NEXT: ('vm_addr', 0)
+// CHECK-NEXT: ('vm_size', 8)
+// CHECK-NEXT: ('file_offset', 368)
+// CHECK-NEXT: ('file_size', 8)
+// CHECK-NEXT: ('maxprot', 7)
+// CHECK-NEXT: ('initprot', 7)
+// CHECK-NEXT: ('num_sections', 2)
+// CHECK-NEXT: ('flags', 0)
+// CHECK-NEXT: ('sections', [
+// CHECK-NEXT: # Section 0
+// CHECK-NEXT: (('section_name', '__text\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
+// CHECK-NEXT: ('segment_name', '__TEXT\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
+// CHECK-NEXT: ('address', 0)
+// CHECK-NEXT: ('size', 0)
+// CHECK-NEXT: ('offset', 368)
+// CHECK-NEXT: ('alignment', 0)
+// CHECK-NEXT: ('reloc_offset', 0)
+// CHECK-NEXT: ('num_reloc', 0)
+// CHECK-NEXT: ('flags', 0x80000000)
+// CHECK-NEXT: ('reserved1', 0)
+// CHECK-NEXT: ('reserved2', 0)
+// CHECK-NEXT: ('reserved3', 0)
+// CHECK-NEXT: ),
+// CHECK-NEXT: ('_relocations', [
+// CHECK-NEXT: ])
+// CHECK-NEXT: ('_section_data', '')
+// CHECK-NEXT: # Section 1
+// CHECK-NEXT: (('section_name', '__eh_frame\x00\x00\x00\x00\x00\x00')
+// CHECK-NEXT: ('segment_name', '__TEXT\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
+// CHECK-NEXT: ('address', 0)
+// CHECK-NEXT: ('size', 8)
+// CHECK-NEXT: ('offset', 368)
+// CHECK-NEXT: ('alignment', 0)
+// CHECK-NEXT: ('reloc_offset', 376)
+// CHECK-NEXT: ('num_reloc', 2)
+// CHECK-NEXT: ('flags', 0x6800000b)
+// CHECK-NEXT: ('reserved1', 0)
+// CHECK-NEXT: ('reserved2', 0)
+// CHECK-NEXT: ('reserved3', 0)
+// CHECK-NEXT: ),
+// CHECK-NEXT: ('_relocations', [
+// CHECK-NEXT: # Relocation 0
+// CHECK-NEXT: (('word-0', 0x0),
+// CHECK-NEXT: ('word-1', 0x5e000001)),
+// CHECK-NEXT: # Relocation 1
+// CHECK-NEXT: (('word-0', 0x0),
+// CHECK-NEXT: ('word-1', 0xe000000)),
+// CHECK-NEXT: ])
+// CHECK-NEXT: ('_section_data', '00000000 00000000')
+// CHECK-NEXT: ])
+// CHECK-NEXT: ),
+// CHECK-NEXT: # Load Command 1
+// CHECK-NEXT: (('command', 2)
+// CHECK-NEXT: ('size', 24)
+// CHECK-NEXT: ('symoff', 392)
+// CHECK-NEXT: ('nsyms', 2)
+// CHECK-NEXT: ('stroff', 424)
+// CHECK-NEXT: ('strsize', 12)
+// CHECK-NEXT: ('_string_data', '\x00_g\x00_g.eh\x00\x00\x00')
+// CHECK-NEXT: ('_symbols', [
+// CHECK-NEXT: # Symbol 0
+// CHECK-NEXT: (('n_strx', 1)
+// CHECK-NEXT: ('n_type', 0xe)
+// CHECK-NEXT: ('n_sect', 1)
+// CHECK-NEXT: ('n_desc', 0)
+// CHECK-NEXT: ('n_value', 0)
+// CHECK-NEXT: ('_string', '_g')
+// CHECK-NEXT: ),
+// CHECK-NEXT: # Symbol 1
+// CHECK-NEXT: (('n_strx', 4)
+// CHECK-NEXT: ('n_type', 0xe)
+// CHECK-NEXT: ('n_sect', 2)
+// CHECK-NEXT: ('n_desc', 0)
+// CHECK-NEXT: ('n_value', 0)
+// CHECK-NEXT: ('_string', '_g.eh')
+// CHECK-NEXT: ),
+// CHECK-NEXT: ])
+// CHECK-NEXT: ),
+// CHECK-NEXT: # Load Command 2
+// CHECK-NEXT: (('command', 11)
+// CHECK-NEXT: ('size', 80)
+// CHECK-NEXT: ('ilocalsym', 0)
+// CHECK-NEXT: ('nlocalsym', 2)
+// CHECK-NEXT: ('iextdefsym', 2)
+// CHECK-NEXT: ('nextdefsym', 0)
+// CHECK-NEXT: ('iundefsym', 2)
+// CHECK-NEXT: ('nundefsym', 0)
+// CHECK-NEXT: ('tocoff', 0)
+// CHECK-NEXT: ('ntoc', 0)
+// CHECK-NEXT: ('modtaboff', 0)
+// CHECK-NEXT: ('nmodtab', 0)
+// CHECK-NEXT: ('extrefsymoff', 0)
+// CHECK-NEXT: ('nextrefsyms', 0)
+// CHECK-NEXT: ('indirectsymoff', 0)
+// CHECK-NEXT: ('nindirectsyms', 0)
+// CHECK-NEXT: ('extreloff', 0)
+// CHECK-NEXT: ('nextrel', 0)
+// CHECK-NEXT: ('locreloff', 0)
+// CHECK-NEXT: ('nlocrel', 0)
+// CHECK-NEXT: ('_indirect_symbols', [
+// CHECK-NEXT: ])
+// CHECK-NEXT: ),
+// CHECK-NEXT:])
More information about the llvm-commits
mailing list