[PATCH] Path: Recognize COFF import library file magic.

Rafael EspĂ­ndola rafael.espindola at gmail.com
Wed Nov 13 07:06:07 PST 2013


can you add a testcase?

On 13 November 2013 02:04, Rui Ueyama <ruiu at google.com> wrote:
> Hi Bigcheese,
>
> Make identify_magic to recognize COFF import file.
>
> http://llvm-reviews.chandlerc.com/D2165
>
> Files:
>   include/llvm/Support/FileSystem.h
>   lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
>   lib/Object/Binary.cpp
>   lib/Object/ObjectFile.cpp
>   lib/Support/Path.cpp
>
> Index: include/llvm/Support/FileSystem.h
> ===================================================================
> --- include/llvm/Support/FileSystem.h
> +++ include/llvm/Support/FileSystem.h
> @@ -238,6 +238,7 @@
>      macho_dsym_companion,     ///< Mach-O dSYM companion file
>      macho_universal_binary,   ///< Mach-O universal binary
>      coff_object,              ///< COFF object file
> +    coff_import_library,      ///< COFF import library
>      pecoff_executable,        ///< PECOFF executable file
>      windows_resource          ///< Windows compiled resource file (.rc)
>    };
> Index: lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
> ===================================================================
> --- lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
> +++ lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
> @@ -574,6 +574,7 @@
>      case sys::fs::file_magic::bitcode:
>      case sys::fs::file_magic::archive:
>      case sys::fs::file_magic::coff_object:
> +    case sys::fs::file_magic::coff_import_library:
>      case sys::fs::file_magic::pecoff_executable:
>      case sys::fs::file_magic::macho_universal_binary:
>      case sys::fs::file_magic::windows_resource:
> Index: lib/Object/Binary.cpp
> ===================================================================
> --- lib/Object/Binary.cpp
> +++ lib/Object/Binary.cpp
> @@ -91,6 +91,7 @@
>        return object_error::success;
>      }
>      case sys::fs::file_magic::coff_object:
> +    case sys::fs::file_magic::coff_import_library:
>      case sys::fs::file_magic::pecoff_executable: {
>        OwningPtr<Binary> ret(
>            ObjectFile::createCOFFObjectFile(scopedSource.take()));
> Index: lib/Object/ObjectFile.cpp
> ===================================================================
> --- lib/Object/ObjectFile.cpp
> +++ lib/Object/ObjectFile.cpp
> @@ -69,6 +69,7 @@
>    case sys::fs::file_magic::macho_dsym_companion:
>      return createMachOObjectFile(Object);
>    case sys::fs::file_magic::coff_object:
> +  case sys::fs::file_magic::coff_import_library:
>    case sys::fs::file_magic::pecoff_executable:
>      return createCOFFObjectFile(Object);
>    }
> Index: lib/Support/Path.cpp
> ===================================================================
> --- lib/Support/Path.cpp
> +++ lib/Support/Path.cpp
> @@ -848,6 +848,10 @@
>      return file_magic::unknown;
>    switch ((unsigned char)Magic[0]) {
>      case 0x00: {
> +      // COFF short import library file
> +      if (Magic[1] == (char)0x00 && Magic[2] == (char)0xff &&
> +          Magic[3] == (char)0xff)
> +        return file_magic::coff_import_library;
>        // Windows resource file
>        const char Expected[] = { 0, 0, 0, 0, '\x20', 0, 0, 0, '\xff' };
>        if (Magic.size() >= sizeof(Expected) &&
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>



More information about the llvm-commits mailing list