summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorKevin Enderby <enderby@apple.com>2011-11-01 23:39:05 +0000
committerKevin Enderby <enderby@apple.com>2011-11-01 23:39:05 +0000
commit82ed3be1fb92beacc57195fa0e00ccd2ae7f986c (patch)
tree1db151eb2f87e6e5c626bb8066fb671753839edf /llvm
parentfc89c142d3e53c430558ea18e435813e14ebe8ac (diff)
downloadbcm5719-llvm-82ed3be1fb92beacc57195fa0e00ccd2ae7f986c.tar.gz
bcm5719-llvm-82ed3be1fb92beacc57195fa0e00ccd2ae7f986c.zip
Fixed a bug in the code to create a dwarf file and directory table entires when
it is separating the directory part from the basename of the FileName. Noticed that this: .file 1 "dir/foo" when assembled got the two parts switched. Using the Mac OS X dwarfdump tool it can be seen easily: % dwarfdump -a a.out include_directories[ 1] = 'foo' Dir Mod Time File Len File Name ---- ---------- ---------- --------------------------- file_names[ 1] 1 0x00000000 0x00000000 dir ... Which should be: ... include_directories[ 1] = 'dir' Dir Mod Time File Len File Name ---- ---------- ---------- --------------------------- file_names[ 1] 1 0x00000000 0x00000000 foo llvm-svn: 143521
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/MC/MCContext.cpp6
-rw-r--r--llvm/test/MC/MachO/file.s22
2 files changed, 26 insertions, 2 deletions
diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp
index 814726ebd8c..a1a01e3bad8 100644
--- a/llvm/lib/MC/MCContext.cpp
+++ b/llvm/lib/MC/MCContext.cpp
@@ -273,8 +273,10 @@ unsigned MCContext::GetDwarfFile(StringRef Directory, StringRef FileName,
// Separate the directory part from the basename of the FileName.
std::pair<StringRef, StringRef> Slash = FileName.rsplit('/');
Directory = Slash.second;
- if (!Directory.empty())
- FileName = Slash.first;
+ if (!Directory.empty()) {
+ Directory = Slash.first;
+ FileName = Slash.second;
+ }
}
// Find or make a entry in the MCDwarfDirs vector for this Directory.
diff --git a/llvm/test/MC/MachO/file.s b/llvm/test/MC/MachO/file.s
new file mode 100644
index 00000000000..0168747ae19
--- /dev/null
+++ b/llvm/test/MC/MachO/file.s
@@ -0,0 +1,22 @@
+// RUN: llvm-mc -triple i386-apple-darwin9 %s -filetype=obj -o - | macho-dump --dump-section-data | FileCheck %s
+
+ .file 1 "dir/foo"
+ nop
+
+// CHECK: ('_section_data', '90')
+// CHECK-NEXT: # Section 1
+// CHECK-NEXT: (('section_name', '__debug_line\x00\x00\x00\x00')
+// CHECK-NEXT: ('segment_name', '__DWARF\x00\x00\x00\x00\x00\x00\x00\x00\x00')
+// CHECK-NEXT: ('address', 1)
+// CHECK-NEXT: ('size', 45)
+// CHECK-NEXT: ('offset', 221)
+// CHECK-NEXT: ('alignment', 0)
+// CHECK-NEXT: ('reloc_offset', 0)
+// CHECK-NEXT: ('num_reloc', 0)
+// CHECK-NEXT: ('flags', 0x2000000)
+// CHECK-NEXT: ('reserved1', 0)
+// CHECK-NEXT: ('reserved2', 0)
+// CHECK-NEXT: ),
+// CHECK-NEXT: ('_relocations', [
+// CHECK-NEXT: ])
+// CHECK-NEXT: ('_section_data', '29000000 02001e00 00000101 fb0e0d00 01010101 00000001 00000164 69720000 666f6f00 01000000 02000001 01')
OpenPOWER on IntegriCloud