[llvm-commits] CVS: llvm/lib/System/Path.cpp
Reid Spencer
reid at x10sys.com
Tue Apr 10 19:02:26 PDT 2007
Changes in directory llvm/lib/System:
Path.cpp updated: 1.23 -> 1.24
---
Log message:
Teach sys::Path how to recognize different kinds of object files for ELF
and Mach-O systems. Additionally, correct the Mach-O logic code to look at
byte 12 not byte 15. Hopefully this fixes the llvm-ld warning on Darwin.
---
Diffs of the changes: (+25 -7)
Path.cpp | 32 +++++++++++++++++++++++++-------
1 files changed, 25 insertions(+), 7 deletions(-)
Index: llvm/lib/System/Path.cpp
diff -u llvm/lib/System/Path.cpp:1.23 llvm/lib/System/Path.cpp:1.24
--- llvm/lib/System/Path.cpp:1.23 Tue Apr 10 19:49:39 2007
+++ llvm/lib/System/Path.cpp Tue Apr 10 21:02:09 2007
@@ -58,7 +58,14 @@
case '\177':
if (magic[1] == 'E' && magic[2] == 'L' && magic[3] == 'F')
- return ELF_FileType;
+ if (length >= 18 && magic[17] == 0)
+ switch (magic[16]) {
+ default: break;
+ case 1: return ELF_Relocatable_FileType;
+ case 2: return ELF_Executable_FileType;
+ case 3: return ELF_SharedObject_FileType;
+ case 4: return ELF_Core_FileType;
+ }
break;
case 0xCE:
@@ -67,10 +74,19 @@
// See the Mach-O section in /usr/share/file/magic for details.
if (magic[1] == char(0xFA) && magic[2] == char(0xED) &&
magic[3] == char(0xFE))
- if (length >= 15)
- if (magic[15] == 1 || magic[15] == 3 || magic[15] == 6 ||
- magic[15] == 9)
- return Mach_O_FileType;
+ if (length >= 14 && magic[13] == 0)
+ switch (magic[12]) {
+ default: break;
+ case 1: return Mach_O_Object_FileType;
+ case 2: return Mach_O_Executable_FileType;
+ case 3: return Mach_O_FixedVirtualMemorySharedLib_FileType;
+ case 4: return Mach_O_Core_FileType;
+ case 5: return Mach_O_PreloadExectuable_FileType;
+ case 6: return Mach_O_DynamicallyLinkedSharedLib_FileType;
+ case 7: return Mach_O_DynamicLinker_FileType;
+ case 8: return Mach_O_Bundle_FileType;
+ case 9: return Mach_O_DynamicallyLinkedSharedLibStub_FileType;
+ }
break;
case 0xF0: // PowerPC Windows
@@ -108,8 +124,10 @@
if (getMagicNumber(Magic, 64))
switch (IdentifyFileType(Magic.c_str(), Magic.length())) {
default: return false;
- case ELF_FileType:
- case Mach_O_FileType:
+ case Mach_O_FixedVirtualMemorySharedLib_FileType:
+ case Mach_O_DynamicallyLinkedSharedLib_FileType:
+ case Mach_O_DynamicallyLinkedSharedLibStub_FileType:
+ case ELF_SharedObject_FileType:
case COFF_FileType: return true;
}
}
More information about the llvm-commits
mailing list