Commit Graph

5015 Commits

Author SHA1 Message Date
NAKAMURA Takumi
eddc485a8f bugpoint/ToolRunner.cpp: ProcessFailure(): Close ErrorFD immediately, or it couldn't be reopened on Win32.
FIXME: We may have an option in openFileForWrite(), not to use ResultFD but to close it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212902 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-13 13:28:18 +00:00
Kevin Enderby
7f50100cfa Add the "-s" flag to llvm-nm for Mach-O files that prints symbols only in
the specified section.  This is same functionality as darwin’s nm(1) "-s" flag.

There is one FIXME in the code and I’m all ears to anyone that can help me
with that.  This option takes exactly two strings and should be allowed
anywhere on the command line.  Such that "llvm-nm -s __TEXT __text foo.o"
would work. But that does not as the CommandLine Library does not have a
way to make this work as far as I can tell.  For now the "-s __TEXT __text"
has to be last on the command line.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212842 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-11 20:30:00 +00:00
Kevin Enderby
e3108d31e0 Changed the lvm-nm alias "-s" for -print-armap to "-M".
This will allow the "-s" flag to implemented in the future as it
is in darwin’s nm(1) to list symbols only in the specified section.

Given a LGTM by Shankar Easwaran who originally implemented
the support for lvm-nm’s -print-armap and archive map symbols.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212576 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-08 23:47:31 +00:00
Rafael Espindola
b6b12e59a2 Use raw_fd_ostream instead of std::ofstream.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212483 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-07 20:34:51 +00:00
Rafael Espindola
7cba2a973f Update the MemoryBuffer API to use ErrorOr.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212405 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-06 17:43:13 +00:00
Rafael Espindola
04e43e64a9 Declare variable on first use.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212403 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-06 14:31:22 +00:00
Rafael Espindola
26a84a6e7c This only needs a StringRef.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212401 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-06 14:17:29 +00:00
Alp Toker
1508c82095 SourceMgr: make valid buffer IDs start from one
Use 0 for the invalid buffer instead of -1/~0 and switch to unsigned
representation to enable more idiomatic usage.

Also introduce a trivial SourceMgr::getMainFileID() instead of hard-coding 0/1
to identify the main file.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212398 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-06 10:33:31 +00:00
Simon Atanasyan
ad720cfde4 [llvm-readobj] Fix output of MIPS GOT without local and global entries.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212374 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-05 19:28:49 +00:00
Rafael Espindola
a593909c3d Change LTOModule`s getTargetTriple and setTargetTriple to use c++ types.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212343 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-04 14:19:41 +00:00
Tim Northover
5b003bb869 llvm-readobj: fix MachO relocatoin printing a bit.
There were two issues here:
1. At the very least, scattered relocations cannot use the same code to
   determine the corresponding symbol being referred to. For some reason we
   pretend there is no symbol, even when one actually exists in the symtab, so to
   match this behaviour getRelocationSymbol should simply return symbols_end for
   scattered relocations.
2. Printing "-" when we can't get a symbol (including the scattered case, but
   not exclusively), isn't that helpful. In both cases there *is* interesting
   information in that field, so we should print it. As hex will do.

Small part of rdar://problem/17553104

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212332 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-04 10:57:56 +00:00
Alp Toker
2255dc7712 Sink undesirable LTO functions into the old C API
We want to encourage users of the C++ LTO API to reuse memory buffers instead
of repeatedly opening and reading the same file contents.

This reverts commit r212305 and implements a tidier scheme.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212308 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-04 00:58:41 +00:00
Peter Collingbourne
59349ad8ad gold plugin: move target initialization to the top of the onload function.
On at least my machine, ar does not register an all symbols read hook (which
previously triggered target initialization), but it does register a claim
files hook, which depends on the targets being initialized.

Differential Revision: http://reviews.llvm.org/D4372

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212303 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-03 23:28:03 +00:00
Peter Collingbourne
1e64b30a9b LTO: rename the various makeLTOModule overloads.
This rename makes it easier to identify the specific overload being called
in each particular case and makes future refactorings easier.

Differential Revision: http://reviews.llvm.org/D4370

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212302 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-03 23:28:00 +00:00
Kevin Enderby
26272defb6 Add the -just-symbol-name (aka -j) flag to llvm-nm to just print the
symbol’s name.  On darwin the -j flag is used (often in combinations
with other flags) to produce a complete list of symbol names which
than can then be reorder and used with ld(1)’s -order_file.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212294 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-03 21:51:07 +00:00
Rafael Espindola
96052a8d12 Add support for inline asm symbols in llvm-ar.
This should allow llvm-ar to be used instead of gnu ar + plugin in a LTO
build. I will add a release note about it once I finish a LTO bootstrap with it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212287 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-03 19:40:08 +00:00
Rafael Espindola
c029b2b785 fix configure+make build
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212283 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-03 19:09:53 +00:00
Rafael Espindola
0a7a2ef6b5 Add support for inline asm symbols to IRObjectFile.
This also enables it in llvm-nm so that it can be tested.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212282 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-03 18:59:23 +00:00
Kevin Enderby
c150516f36 Add the -U flag to llvm-nm as an alias to -defined-only
as darwin’s nm(1) uses -U for this functionality.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212280 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-03 18:18:50 +00:00
Rafael Espindola
7413fefb8b Invert the MC -> Object dependency.
Now that we have a lib/MC/MCAnalysis, the dependency was there just because
of two helper classes. Move the two over to MC.

This will allow IRObjectFile to parse inline assembly.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212248 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-03 02:01:39 +00:00
Kevin Enderby
1faddea960 Add the -reverse-sort flag (aka -r) to llvm-nm
which exists in other Unix nm(1)’s.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212235 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-02 23:23:58 +00:00
Rafael Espindola
773d63e2ad Fix configure+make build.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212210 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-02 20:05:48 +00:00
Rafael Espindola
cca08872b0 Move CFG building code to a new lib/MC/MCAnalysis library.
The new library is 150KB on a Release+Asserts build, so it is quiet a bit of
code that regular users of MC don't need to link with now.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212209 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-02 19:49:34 +00:00
Kevin Enderby
62399746cc Also run clang-format on llvm-nm.cpp to tidy things up. No functional changes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212143 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-01 22:44:51 +00:00
Kevin Enderby
9c23bd0943 Run clang-format on llvm-size.cpp to tidy things up. No functional changes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212141 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-01 22:26:31 +00:00
Kevin Enderby
adaa88ecc5 Add the -arch flag support to llvm-size like what was done to llvm-nm
to select the slice out of a Mach-O universal file.  This also includes
support for -arch all, selecting the host architecture by default from
a universal file and checking if -arch is used with a standard Mach-O
it matches that architecture.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212108 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-01 17:19:10 +00:00
Benjamin Kramer
4232f4e605 Rephrase loop so it doesn't leave unused bools around in Release mode.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212102 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-01 14:46:44 +00:00
Kevin Enderby
c28eff1356 Add the -arch flag support to llvm-nm to select the slice out of a Mach-O
universal file.  This also includes support for -arch all, selecting the host
architecture by default from a universal file and checking if -arch is used
with a standard Mach-O it matches that architecture.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212054 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-30 18:45:23 +00:00
Tim Northover
12a261e117 macho-dump: add code to print LC_ID_DYLIB load commands.
I want to check them in lld.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212043 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-30 14:40:57 +00:00
Rafael Espindola
8d5114e46f Simplify code a bit, no functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211985 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-28 17:46:19 +00:00
Justin Bogner
1cfa342dc1 llvm-cov: Support specifying multiple source files
Make llvm-cov compatible with gcov for cases where multiple files are
specified on the command line. That is, loop over each one and report
coverage, and report errors on stderr only rather than via return
code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211959 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-27 20:41:25 +00:00
Lang Hames
c3747f276a [RuntimeDyld] Add a framework for testing relocation logic in RuntimeDyld.
This patch adds a "-verify" mode to the llvm-rtdyld utility. In verify mode,
llvm-rtdyld will test supplied expressions against the linked program images
that it creates in memory. This scheme can be used to verify the correctness
of the relocation logic applied by RuntimeDyld.

The expressions to test will be read out of files passed via the -check option
(there may be more than one of these). Expressions to check are extracted from
lines of the form:
# rtdyld-check: <expression>

This system is designed to fit the llvm-lit regression test workflow. It is
format and target agnostic, and supports verification of images linked for
remote targets. The expression language is defined in
llvm/include/llvm/RuntimeDyldChecker.h . Examples can be found in
test/ExecutionEngine/RuntimeDyld.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211956 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-27 20:20:57 +00:00
Saleem Abdulrasool
e46ce9ac24 Support: update DLLCharacteristics enumeration
Add the new AppContainer characteristic which is import for Windows Store
(Metro) compatible applications.  Add the new Control Flow Guard flag to bring
the enumeration up to date with the current values as of Windows 8.1.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211855 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-27 03:11:18 +00:00
Rafael Espindola
2db3151eab Don't force the build of toos/lto as a static lib.
Any uses of tools/lto as a static lib should probably move to lib/LTO.
This was also never implemented in the configure build, so this reduces
the differences among the two.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211852 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-27 02:51:21 +00:00
Alp Toker
8dd8d5c2b2 Revert "Introduce a string_ostream string builder facilty"
Temporarily back out commits r211749, r211752 and r211754.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211814 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-26 22:52:05 +00:00
Tom Roeder
9ad9c96755 Fix the new LTOCodeGenerator setup in gold to parse options before using MAttrs.
This fixes a regression that made clang -flto -Wl,--plugin-opt=-mattr=+aes not
pass the "+aes" option to the LTOCodeGenerator attributes.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211804 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-26 20:43:27 +00:00
Alp Toker
2559070422 Introduce a string_ostream string builder facilty
string_ostream is a safe and efficient string builder that combines opaque
stack storage with a built-in ostream interface.

small_string_ostream<bytes> additionally permits an explicit stack storage size
other than the default 128 bytes to be provided. Beyond that, storage is
transferred to the heap.

This convenient class can be used in most places an
std::string+raw_string_ostream pair or SmallString<>+raw_svector_ostream pair
would previously have been used, in order to guarantee consistent access
without byte truncation.

The patch also converts much of LLVM to use the new facility. These changes
include several probable bug fixes for truncated output, a programming error
that's no longer possible with the new interface.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211749 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-26 00:00:48 +00:00
Alexey Volkov
9316a78fdd Fix unresolved symbols when loading gold plugin
Differential Revision: http://reviews.llvm.org/D4275


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211675 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-25 08:04:58 +00:00
Rafael Espindola
0d50598d71 Pass a unique_ptr<MemoryBuffer> to the constructors in the Binary hierarchy.
Once the objects are constructed, they own the buffer. Passing a unique_ptr
makes that clear.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211595 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-24 13:56:32 +00:00
Rafael Espindola
b138caba43 Pass a std::unique_ptr& to the create??? methods is lib/Object.
This makes the buffer ownership on error conditions very natural. The buffer
is only moved out of the argument if an object is constructed that now
owns the buffer.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211546 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-23 22:00:37 +00:00
Rafael Espindola
1f659329b6 Make ObjectFile and BitcodeReader always own the MemoryBuffer.
This allows us to just use a std::unique_ptr to store the pointer to the buffer.
The flip side is that they have to support releasing the buffer back to the
caller.

Overall this looks like a more efficient and less brittle api.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211542 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-23 21:53:12 +00:00
Rafael Espindola
61438b1c26 Simplify memory management with std::unique_ptr.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211538 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-23 21:15:27 +00:00
Rafael Espindola
2da970364f Convert a few methods to use ErrorOr.
It used to be inconvenient to mix ErrorOr and UniquePtr, but with c++11
they work OK together.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211532 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-23 20:41:02 +00:00
Kevin Enderby
138222e56f Change the default input for llvm-nm to be a.out instead of standard input
to match llvm-size and other UNIX systems for their nm(1).

Tweak test cases that used llvm-nm with standard input to add a "-" to
indicate that and add a test case to check the default of a.out for llvm-nm.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211529 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-23 20:27:53 +00:00
Kevin Enderby
efc447827d Fix some double printing of filenames for archives in llvm-nm when
the tool is given multiple files.  Also fix the same issue with Mach-O
universal files. And fix the newline spacing to separate the output
in these cases.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211405 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-20 21:29:27 +00:00
Rafael Espindola
8483dacfd8 Small clanups:
Use static instead of anonymous namespace.
Delete write only variables.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211335 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-20 01:37:35 +00:00
Kevin Enderby
d1e64617ee Added the -m option as an alias for -format=darwin to llvm-nm and llvm-size
which is what the darwin tools use for the Mach-O format output.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211326 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-20 00:04:16 +00:00
Rafael Espindola
2ae686a2ab The gold plugin doesn't need disassemblers.
Back in r128440 tools/LTO started exporting the disassembler interface. It
was never clear why, but whatever the reason I am pretty sure it doesn't hold
for tools/gold.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211325 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-19 23:06:53 +00:00
Rafael Espindola
f38fdf1b61 Set gold plugin options in a sane order.
This fixes the  processing of --plugin-opt=-jump-table-type=arity.

Nice properties:
 * We call InitTargetOptionsFromCodeGenFlags once.
 * We call parseCodeGenDebugOptions once.
 * It works :-)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211322 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-19 22:54:47 +00:00
Kevin Enderby
f7b992bdcd Fix the output of llvm-nm for Mach-O files to use the characters ‘d’ and ‘b’ for
data and bss symbols instead of the generic ’s’ for a symbol in a section.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211321 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-19 22:49:21 +00:00