1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 19:12:56 +02:00
Commit Graph

44 Commits

Author SHA1 Message Date
Rui Ueyama
f2a2b72f46 Fix a bug in Windows resource file detection.
The magic bytes should not include the trailing NUL byte.

llvm-svn: 192769
2013-10-16 03:29:49 +00:00
Rui Ueyama
a0789cb92a Path: Recognize Windows compiled resource file.
Some background: One can pass compiled resource files (.res files) directly
to the linker on Windows. If a resource file is given, the linker will run
"cvtres" command in background to convert the resource file to a COFF file
to link it.

What I'm trying to do with this patch is to make the linker to recognize
the resource file by file magic, so that it can run cvtres command.

Differential Revision: http://llvm-reviews.chandlerc.com/D1943

llvm-svn: 192742
2013-10-15 22:45:38 +00:00
Benjamin Kramer
10412fd112 Path: Add an in-place version of path::native.
This reflects the common use case of nativizing a prepared path. The existing
version invokes undefined behavior if input = output, add an assert to catch
that case.

llvm-svn: 190510
2013-09-11 10:45:21 +00:00
Tareq A. Siraj
135d71f85d Fixes a bug when iterating on paths
This fixes the incorrect implementation of iterating on file/directory
paths.

Differential Review: http://llvm-reviews.chandlerc.com/D1277

llvm-svn: 188183
2013-08-12 17:10:49 +00:00
Rafael Espindola
2bf7932f99 Include st_dev to make the result of getUniqueID actually unique.
This will let us use getUniqueID instead of st_dev directly on clang.

llvm-svn: 187378
2013-07-29 21:26:49 +00:00
Rafael Espindola
28c7549697 Don't end a file name with a dot. It looks odd.
llvm-svn: 187124
2013-07-25 15:00:17 +00:00
Rafael Espindola
f40c5de45c Split openFileForWrite into windows and unix versions.
It is similar to 186511, but for creating files for writing.

llvm-svn: 186679
2013-07-19 15:02:03 +00:00
Rafael Espindola
a045716bb8 Split openFileForRead into Windows and Unix versions.
This has some advantages:

* Lets us use native, utf16 windows functions.
* Easy to produce good errors on windows about trying to use a
directory when we want a file.
* Simplifies the unix version a bit.

llvm-svn: 186511
2013-07-17 14:58:25 +00:00
Rafael Espindola
2a9326a78f Add a wrapper for open.
This centralizes the handling of O_BINARY and opens the way for hiding more
differences (like how open behaves with directories).

llvm-svn: 186447
2013-07-16 19:44:17 +00:00
Rafael Espindola
5d9e1a875f Remove unique_file now that it is unused.
llvm-svn: 185728
2013-07-05 21:19:35 +00:00
Rafael Espindola
66da97e093 Add a createUniqueFile function and switch llvm's users of unique_file.
This function is complementary to createTemporaryFile. It handles the case were
the unique file is *not* temporary: we will rename it in the end. Since we
will rename it, the file has to be in the same filesystem as the final
destination and we don't prepend the system temporary directory.

This has a small semantic difference from unique_file: the default mode is 0666.
This matches the behavior of most unix tools. For example, with this change
lld now produces files with the same permissions as ld. I will add a test
of this change when I port clang over to createUniqueFile (next commit).

llvm-svn: 185726
2013-07-05 21:01:08 +00:00
Rafael Espindola
b874aa69e3 Add a higher level createTemporaryFile function.
This function is inspired by clang's Driver::GetTemporaryPath. It hides the
pattern used for uniquing and requires simple file names that are always
placed in the system temporary directory.

llvm-svn: 185716
2013-07-05 19:56:49 +00:00
Rafael Espindola
2da320119c Improve comment.
llvm-svn: 185141
2013-06-28 10:55:41 +00:00
Rafael Espindola
8eae838533 Improvements to unique_file and createUniqueDirectory.
* Don't try to create parent directories in unique_file. It had two problem:
   * It violates the contract that it is atomic. If the directory creation
     success and the file creation fails, we would return an error but the
     file system was modified.
   * When creating a temporary file clang would have to first check if the
     parent directory existed or not to avoid creating one when it was not
     supposed to.

* More efficient implementations of createUniqueDirectory and the unique_file
  that produces only the file name. Now all 3 just call into a static
  function passing what they want (name, file or directory).

Clang also has to be updated, so tests might fail if a bot picks up this commit
and not the corresponding clang one.

llvm-svn: 185126
2013-06-28 03:48:47 +00:00
Rafael Espindola
4cfcd31f11 Don't ask for a mode when we are not keeping the file.
llvm-svn: 185123
2013-06-28 01:05:47 +00:00
Rafael Espindola
ac62522b9b Add a convenience createUniqueDirectory function.
There are a few valid situation where we care about the structure inside a
directory, but not about the directory itself. A simple example is for unit
testing directory traversal.

PathV1 had a function like this, add one to V2 and port existing users of the
created temp file and delete it hack to using it.

llvm-svn: 185059
2013-06-27 03:45:31 +00:00
Rafael Espindola
9edd4f6c46 Rename PathV2 to just Path now that it is the only one.
llvm-svn: 185015
2013-06-26 19:33:03 +00:00
Rafael Espindola
dc28d9e2d2 PathV1 is deprecated since the 18th of Dec 2010. Remove it.
llvm-svn: 184960
2013-06-26 16:24:35 +00:00
Rafael Espindola
24a81dcac4 Remove Path::isObjectFile.
llvm-svn: 184305
2013-06-19 14:25:38 +00:00
Rafael Espindola
7690460b6c Inline Path::isBitcodeFile into only use and remove it.
llvm-svn: 183840
2013-06-12 15:13:57 +00:00
Rafael Espindola
21dc9d4207 Remove Path::hasMagicNumber.
llvm-svn: 183838
2013-06-12 15:04:59 +00:00
Rafael Espindola
968c6bbebf Include PathV1.h in files that use it.
This is preparation for replacing Path.h with PathV2.h.

llvm-svn: 183782
2013-06-11 20:00:56 +00:00
Rafael Espindola
993b0c88c5 Remove Path::getDirname.
llvm-svn: 183780
2013-06-11 19:32:57 +00:00
Rafael Espindola
cd1368e1db Remove GetDLLSuffix.
llvm-svn: 183777
2013-06-11 19:18:05 +00:00
Rafael Espindola
30fee8bd79 Remove GetSystemLibraryPaths.
llvm-svn: 183770
2013-06-11 18:58:47 +00:00
Rafael Espindola
c5d8c2560a Remove unused FindLibrary function.
llvm-svn: 183764
2013-06-11 18:41:07 +00:00
Rafael Espindola
d506a5e174 Remove sys::identifyFileType.
llvm-svn: 183763
2013-06-11 18:18:02 +00:00
Rafael Espindola
64def1c6ed Pass a StringRef to sys::identifyFileType.
llvm-svn: 183669
2013-06-10 15:27:39 +00:00
Rafael Espindola
7f956c6000 Fix an out of bounds array access.
We were looking at Magic[5] without checking Length. Since this path would not
return unless Length >= 18 anyway, just move the >= 18 check up.

llvm-svn: 183666
2013-06-10 15:22:18 +00:00
Rafael Espindola
3db8a7c316 Update for current naming conventions.
I will change identifyFileType to use a StringRef in the next patch.

llvm-svn: 183664
2013-06-10 14:56:16 +00:00
Roman Divacky
a299a2efa5 Remove duplicate includes.
llvm-svn: 170902
2012-12-21 17:06:44 +00:00
Chandler Carruth
a490793037 Use the new script to sort the includes of every file under lib.
Sooooo many of these had incorrect or strange main module includes.
I have manually inspected all of these, and fixed the main module
include to be the nearest plausible thing I could find. If you own or
care about any of these source files, I encourage you to take some time
and check that these edits were sensible. I can't have broken anything
(I strictly added headers, and reordered them, never removed), but they
may not be the headers you'd really like to identify as containing the
API being implemented.

Many forward declarations and missing includes were added to a header
files to allow them to parse cleanly when included first. The main
module rule does in fact have its merits. =]

llvm-svn: 169131
2012-12-03 16:50:05 +00:00
Meador Inge
b8cf9886db PR13013: ELF Type identification fails for MSB type ELF files.
Fix 'sys::IdentifyFileType' to work with big and little endian byte orderings
when reading the ELF object file type.

Initial patch by Stefan Hepp.

llvm-svn: 159138
2012-06-25 14:48:43 +00:00
Michael J. Spencer
5cf93fd736 Support/FileSystem: Add file_magic and move a vew clients over to it.
llvm-svn: 146523
2011-12-13 23:17:12 +00:00
Michael J. Spencer
8d2c45200a Cleanup whitespace.
llvm-svn: 146521
2011-12-13 23:16:15 +00:00
Eli Friedman
62794425dd Remove a couple unused methods. PR11201.
llvm-svn: 143452
2011-11-01 05:11:01 +00:00
Benjamin Kramer
5b94d9657f ObjectFile: Add support for mach-o-style dSYM companion files.
llvm-svn: 139676
2011-09-14 00:39:22 +00:00
Eric Christopher
2c662fa29e Add support for 64-bit object files to Path.
llvm-svn: 129975
2011-04-22 03:50:19 +00:00
Eric Christopher
0e88a490eb Assorted bugfixes in object file handling:
- Adds support for sniffing PE/COFF files on win32 (.exe and .dll)
   which are COFF files that have an MS-DOS compatibility stub on
   the front of them.

 - Fixes a bug in the COFFObjectFile's support for the Microsoft COFF
   extension for long symbol names, wherein it was attempting to parse
   the leading '/' in an extended symbol name reference as part of the
   integer offset.

 - Fixes bugs in COFFObjectFile and ELFObjectFile wherein section
   and symbol iterators were being returned with uninitialized bytes;
   the type DataRefImpl is a union between 2 32-bit words (d.a and d.b)
   and a single intptr_t word (p). Only p was being initialized, so in
   32-bit builds the result would be iterators with random upper 32-bit
   words in their DataRefImpls. This caused random failures when
   seeking around in object files.

Patch by Graydon Hoare!

llvm-svn: 128799
2011-04-03 22:53:19 +00:00
Michael J. Spencer
e1defa51ae Support/PathV2: Add identify_magic.
llvm-svn: 123548
2011-01-15 20:39:36 +00:00
Michael J. Spencer
917b043a16 Support/Path: Deprecate PathV1::exists and replace all uses with PathV2::fs::exists.
llvm-svn: 123151
2011-01-10 02:34:23 +00:00
Michael J. Spencer
b604751adb Support/Path: Deprecate Path::hasMagicNumber and replace all uses with fs::has_magic.
llvm-svn: 122589
2010-12-28 01:49:21 +00:00
Dan Gohman
3ff3bc0c31 Delete Path::appendSuffix's return value; it wasn't used anywhere, which
is fine since isn't really necessary to check isValid there anyway.

llvm-svn: 120538
2010-12-01 02:46:41 +00:00
Michael J. Spencer
d5ec932c3a Merge System into Support.
llvm-svn: 120298
2010-11-29 18:16:10 +00:00