[llvm-commits] [llvm] r103979 - in /llvm/trunk: lib/MC/MCMachOStreamer.cpp test/MC/MachO/string-table.s
Daniel Dunbar
daniel at zuster.org
Mon May 17 14:20:00 PDT 2010
Author: ddunbar
Date: Mon May 17 16:19:59 2010
New Revision: 103979
URL: http://llvm.org/viewvc/llvm-project?rev=103979&view=rev
Log:
MC/Mach-O: Reverse order of SymbolData scanning when emitting instructions.
- This fixes a string table mismatch with 'as' when two new symbols are defined
in a single instruction.
Added:
llvm/trunk/test/MC/MachO/string-table.s
Modified:
llvm/trunk/lib/MC/MCMachOStreamer.cpp
Modified: llvm/trunk/lib/MC/MCMachOStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCMachOStreamer.cpp?rev=103979&r1=103978&r2=103979&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCMachOStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCMachOStreamer.cpp Mon May 17 16:19:59 2010
@@ -414,7 +414,7 @@
void MCMachOStreamer::EmitInstruction(const MCInst &Inst) {
// Scan for values.
- for (unsigned i = 0; i != Inst.getNumOperands(); ++i)
+ for (unsigned i = Inst.getNumOperands(); i--; )
if (Inst.getOperand(i).isExpr())
AddValueSymbols(Inst.getOperand(i).getExpr());
Added: llvm/trunk/test/MC/MachO/string-table.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/MachO/string-table.s?rev=103979&view=auto
==============================================================================
--- llvm/trunk/test/MC/MachO/string-table.s (added)
+++ llvm/trunk/test/MC/MachO/string-table.s Mon May 17 16:19:59 2010
@@ -0,0 +1,100 @@
+// RUN: llvm-mc -triple i386-apple-darwin9 %s -filetype=obj -o - | macho-dump --dump-section-data | FileCheck %s
+
+ movl $a, b
+
+// CHECK: ('cputype', 7)
+// CHECK: ('cpusubtype', 3)
+// CHECK: ('filetype', 1)
+// CHECK: ('num_load_commands', 1)
+// CHECK: ('load_commands_size', 228)
+// CHECK: ('flag', 0)
+// CHECK: ('load_commands', [
+// CHECK: # Load Command 0
+// CHECK: (('command', 1)
+// CHECK: ('size', 124)
+// CHECK: ('segment_name', '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
+// CHECK: ('vm_addr', 0)
+// CHECK: ('vm_size', 10)
+// CHECK: ('file_offset', 256)
+// CHECK: ('file_size', 10)
+// CHECK: ('maxprot', 7)
+// CHECK: ('initprot', 7)
+// CHECK: ('num_sections', 1)
+// CHECK: ('flags', 0)
+// CHECK: ('sections', [
+// CHECK: # Section 0
+// CHECK: (('section_name', '__text\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
+// CHECK: ('segment_name', '__TEXT\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
+// CHECK: ('address', 0)
+// CHECK: ('size', 10)
+// CHECK: ('offset', 256)
+// CHECK: ('alignment', 0)
+// CHECK: ('reloc_offset', 268)
+// CHECK: ('num_reloc', 2)
+// CHECK: ('flags', 0x80000400)
+// CHECK: ('reserved1', 0)
+// CHECK: ('reserved2', 0)
+// CHECK: ),
+// CHECK: ('_relocations', [
+// CHECK: # Relocation 0
+// CHECK: (('word-0', 0x6),
+// CHECK: ('word-1', 0xc000000)),
+// CHECK: # Relocation 1
+// CHECK: (('word-0', 0x2),
+// CHECK: ('word-1', 0xc000001)),
+// CHECK: ])
+// CHECK: ('_section_data', '\xc7\x05\x00\x00\x00\x00\x00\x00\x00\x00')
+// CHECK: ])
+// CHECK: ),
+// CHECK: # Load Command 1
+// CHECK: (('command', 2)
+// CHECK: ('size', 24)
+// CHECK: ('symoff', 284)
+// CHECK: ('nsyms', 2)
+// CHECK: ('stroff', 308)
+// CHECK: ('strsize', 8)
+// CHECK: ('_string_data', '\x00a\x00b\x00\x00\x00\x00')
+// CHECK: ('_symbols', [
+// CHECK: # Symbol 0
+// CHECK: (('n_strx', 1)
+// CHECK: ('n_type', 0x1)
+// CHECK: ('n_sect', 0)
+// CHECK: ('n_desc', 0)
+// CHECK: ('n_value', 0)
+// CHECK: ('_string', 'a')
+// CHECK: ),
+// CHECK: # Symbol 1
+// CHECK: (('n_strx', 3)
+// CHECK: ('n_type', 0x1)
+// CHECK: ('n_sect', 0)
+// CHECK: ('n_desc', 0)
+// CHECK: ('n_value', 0)
+// CHECK: ('_string', 'b')
+// CHECK: ),
+// CHECK: ])
+// CHECK: ),
+// CHECK: # Load Command 2
+// CHECK: (('command', 11)
+// CHECK: ('size', 80)
+// CHECK: ('ilocalsym', 0)
+// CHECK: ('nlocalsym', 0)
+// CHECK: ('iextdefsym', 0)
+// CHECK: ('nextdefsym', 0)
+// CHECK: ('iundefsym', 0)
+// CHECK: ('nundefsym', 2)
+// CHECK: ('tocoff', 0)
+// CHECK: ('ntoc', 0)
+// CHECK: ('modtaboff', 0)
+// CHECK: ('nmodtab', 0)
+// CHECK: ('extrefsymoff', 0)
+// CHECK: ('nextrefsyms', 0)
+// CHECK: ('indirectsymoff', 0)
+// CHECK: ('nindirectsyms', 0)
+// CHECK: ('extreloff', 0)
+// CHECK: ('nextrel', 0)
+// CHECK: ('locreloff', 0)
+// CHECK: ('nlocrel', 0)
+// CHECK: ('_indirect_symbols', [
+// CHECK: ])
+// CHECK: ),
+// CHECK: ])
More information about the llvm-commits
mailing list