Commit Graph

499 Commits

Author SHA1 Message Date
Tim Northover c532bbd647 AArch64: add support for dynamic-loader relocations
LLD needs them, and it's good to be able to print them properly when
our object dumpers encounter them.

Patch by Daniel Stewart.

llvm-svn: 215352
2014-08-11 10:10:27 +00:00
Rafael Espindola 8f7d5f29f8 Delete dead code. NFC.
llvm-svn: 215224
2014-08-08 16:49:35 +00:00
Rafael Espindola 676223170f getLoadName is only implemented for ELF, make it ELF only.
llvm-svn: 215219
2014-08-08 16:39:22 +00:00
Rafael Espindola 72318b47fc Use a simpler predicate. NFC.
llvm-svn: 215218
2014-08-08 16:30:17 +00:00
Rafael Espindola 40f5446d84 pr20589: Fix duplicated arch flag.
llvm-svn: 215216
2014-08-08 16:18:29 +00:00
Kevin Enderby ae2a9a236f Add two missing ARM cpusubtypes to the switch statement in
MachOObjectFile::getArch(uint32_t CPUType, uint32_t CPUSubType) .

Upcoming changes will cause existing test cases to use this but
I wanted to check in this obvious change separately.

llvm-svn: 215150
2014-08-07 21:30:25 +00:00
Rafael Espindola f55771388b A std::unique_ptr case I missed in the previous patch.
llvm-svn: 214379
2014-07-31 03:36:00 +00:00
Rafael Espindola 437b0d5887 Use std::unique_ptr to make the ownership explicit.
llvm-svn: 214377
2014-07-31 03:12:45 +00:00
Tim Northover e19bed7d33 AArch64: remove arm64 triple enumerator.
Having both Triple::arm64 and Triple::aarch64 is extremely confusing, and
invites bugs where only one is checked. In reality, the only legitimate
difference between the two (arm64 usually means iOS) is also present in the OS
part of the triple and that's what should be checked.

We still parse the "arm64" triple, just canonicalise it to Triple::aarch64, so
there aren't any LLVM-side test changes.

llvm-svn: 213743
2014-07-23 12:32:47 +00:00
David Blaikie 4b9ae52ac1 Correct the ownership passing semantics of object::createBinary and make them explicit in the type system.
createBinary documented that it destroyed the parameter in error cases,
though by observation it does not. By passing the unique_ptr by value
rather than lvalue reference, callers are now explicit about passing
ownership and the function implements the documented contract. Remove
the explicit documentation, since now the behavior cannot be anything
other than what was documented, so it's redundant.

Also drops a unique_ptr::release in llvm-nm that was always run on a
null unique_ptr anyway.

llvm-svn: 213557
2014-07-21 16:26:24 +00:00
David Blaikie dc01ca1896 Remove unnecessary use of unique_ptr::release() used to construct another unique_ptr.
llvm-svn: 213556
2014-07-21 16:23:21 +00:00
David Blaikie 370a67a56c Remove unused variable.
llvm-svn: 213554
2014-07-21 16:13:24 +00:00
Artyom Skrobov 7d602f7a77 Namespace cleanup (no functional change)
llvm-svn: 213478
2014-07-20 12:08:28 +00:00
Hal Finkel 3ee2af7d1c [PowerPC] 32-bit ELF PIC support
This adds initial support for PPC32 ELF PIC (Position Independent Code; the
-fPIC variety), thus rectifying a long-standing deficiency in the PowerPC
backend.

Patch by Justin Hibbits!

llvm-svn: 213427
2014-07-18 23:29:49 +00:00
Artyom Skrobov 78d5daf8ce extracting swapStruct into include/llvm/Support/MachO.h (no functional change)
llvm-svn: 213361
2014-07-18 09:26:16 +00:00
Lang Hames 84bc818baf [RuntimeDyld] Revert r211652 - MachO object GDB registration support.
The registration scheme used in r211652 violated the read-only contract of
MemoryBuffer. This caused crashes in llvm-rtdyld where macho objects were backed
by read-only mmap'd memory.

llvm-svn: 213086
2014-07-15 19:35:22 +00:00
NAKAMURA Takumi a56f860e29 Object/LLVMBuild.txt: Sort required_libraries by alphabetical order.
llvm-svn: 212917
2014-07-14 02:52:08 +00:00
Simon Atanasyan 6abd4be930 Add forgotten `break` statement.
llvm-svn: 212910
2014-07-13 16:18:56 +00:00
Simon Atanasyan 1cd169f137 [Mips] Support SHT_MIPS_ABIFLAGS section type flag in the llvm-readobj,
obj2yaml and yaml2obj tools.

llvm-svn: 212908
2014-07-13 15:28:54 +00:00
Simon Atanasyan 8ebb6aed9b [ELFYAML] Group ELF section type flags to target specific blocks.
Recognize only flags which correspond to the current target.

llvm-svn: 212880
2014-07-12 18:25:08 +00:00
Kevin Enderby 8c50dbb8cb Add support for BSD format Archive map symbols (aka the table of contents
from a __.SYMDEF or "__.SYMDEF SORTED" archive member).

llvm-svn: 212568
2014-07-08 22:10:02 +00:00
Rafael Espindola adf21f2a56 Update the MemoryBuffer API to use ErrorOr.
llvm-svn: 212405
2014-07-06 17:43:13 +00:00
Rafael Espindola d5a8efe733 This only needs a StringRef. No functionality change.
llvm-svn: 212371
2014-07-05 11:38:52 +00:00
Rafael Espindola ba79dba8ed Make RecordStreamer.h private.
llvm-svn: 212361
2014-07-04 22:44:18 +00:00
Rafael Espindola 2dc0d9bddb Ignore llvm.* globals.
It is not clear if llvm.global_ctors should or should not be in llvm.metadata,
but in practice it is not and we need to ignore it for LTO.

llvm-svn: 212351
2014-07-04 19:08:22 +00:00
Rafael Espindola dddd1fd9f4 Implement LTOModule on top of IRObjectFile.
IRObjectFile provides all the logic for producing mangled names and getting
symbols from inline assembly.

LTOModule then adds logic for linking specific tasks, like constructing
llvm.compiler_user or extracting linker options from the bitcode.

The rule of the thumb is that IRObjectFile has the functionality that is
needed by both LTO and llvm-ar.

llvm-svn: 212349
2014-07-04 18:40:36 +00:00
Rafael Espindola 3885090b86 Mark intrinsic functions as llvm-specific.
llvm-svn: 212347
2014-07-04 15:58:00 +00:00
Rafael Espindola b674c17deb Don't include llvm.metadata variables in archive symbol tables.
llvm-svn: 212344
2014-07-04 15:03:17 +00:00
Tim Northover 07f99fb769 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

llvm-svn: 212332
2014-07-04 10:57:56 +00:00
Rafael Espindola 30f37f5fc4 Move createIRObjectFile to the IRObjectFile class and return the concrete type.
llvm-svn: 212301
2014-07-03 23:03:50 +00:00
Rafael Espindola 13b69d63e6 Add support for inline asm symbols to IRObjectFile.
This also enables it in llvm-nm so that it can be tested.

llvm-svn: 212282
2014-07-03 18:59:23 +00:00
Rafael Espindola 97de474a36 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.

llvm-svn: 212248
2014-07-03 02:01:39 +00:00
Reid Kleckner 4da3d57e62 Speculatively fix some code handling Power64 MachO files
MSVC was warning on a switch containing only default labels.  In this
instance, it looks like it uncovered a real bug.  :)

llvm-svn: 212062
2014-06-30 20:12:59 +00:00
Kevin Enderby 4c8dfe4d0f 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.

llvm-svn: 212054
2014-06-30 18:45:23 +00:00
Tim Northover 8f9590b622 macho-dump: add code to print LC_ID_DYLIB load commands.
I want to check them in lld.

llvm-svn: 212043
2014-06-30 14:40:57 +00:00
Alp Toker e69170a110 Revert "Introduce a string_ostream string builder facilty"
Temporarily back out commits r211749, r211752 and r211754.

llvm-svn: 211814
2014-06-26 22:52:05 +00:00
Alp Toker 614717388c 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.

llvm-svn: 211749
2014-06-26 00:00:48 +00:00
Lang Hames 41b192f35f [RuntimeDyld] Adds the necessary hooks to MCJIT to be able to debug generated
MachO files using the GDB JIT debugging interface.

Patch by Keno Fischer. Thanks Keno!

llvm-svn: 211652
2014-06-25 00:20:53 +00:00
Rafael Espindola 6fa0cb858a Replace two release calls with std::move. I missed this on the previous commit.
llvm-svn: 211597
2014-06-24 14:25:17 +00:00
Rafael Espindola 2e60ca964c 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.

llvm-svn: 211595
2014-06-24 13:56:32 +00:00
Rafael Espindola 6304e94108 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.

llvm-svn: 211546
2014-06-23 22:00:37 +00:00
Rafael Espindola c3f9b5a534 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.

llvm-svn: 211542
2014-06-23 21:53:12 +00:00
Rafael Espindola 4f7932b2fe 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.

llvm-svn: 211532
2014-06-23 20:41:02 +00:00
Kevin Enderby 4eff6cdd2e Fix a warning about the use of const being ignored with a cast.
llvm-svn: 211383
2014-06-20 18:07:34 +00:00
Kevin Enderby 1983fcf86c Change the output of llvm-nm and llvm-size for Mach-O universal files (aka
fat files) to print “ (for architecture XYZ)” for fat files with more than
one architecture to be like what the darwin tools do for fat files.

Also clean up the Mach-O printing of archive membernames in llvm-nm to use
the darwin form of "libx.a(foo.o)".

llvm-svn: 211316
2014-06-19 22:03:18 +00:00
Kevin Enderby 4b8fc281d4 Teach llvm-size to know about Mach-O universal files (aka fat files) and
fat files containing archives.

Also fix a bug in MachOUniversalBinary::ObjectForArch::ObjectForArch()
where it needed a >= when comparing the Index with the number of
objects in a fat file.  As the index starts at 0.

llvm-svn: 211230
2014-06-18 22:04:40 +00:00
Rafael Espindola 8af5cb2c28 Change IRObjectFile to parse the bitcode lazily.
The main point of this class is to provide a cheap object interface to a bitcode
file, so it has to be as lazy as possible.

llvm-svn: 211207
2014-06-18 19:05:24 +00:00
Rafael Espindola 24d8b84838 Fix a memory leak in the error path.
llvm-svn: 211184
2014-06-18 17:07:15 +00:00
Rafael Espindola 95cf2f25fe Fix pr17056.
This makes llvm-nm ignore members that are not sufficiently aligned for
lib/Object to handle.

These archives are invalid. GNU AR is able to handle this, but in general
just warns about broken archive members.

We should probably start warning too, but for now just make sure llvm-nm
exits with an 0.

llvm-svn: 211036
2014-06-16 16:41:00 +00:00
Rafael Espindola ae460027a4 Convert the Archive API to use ErrorOr.
Now that we have c++11, even things like ErrorOr<std::unique_ptr<...>> are
easy to use.

No intended functionality change.

llvm-svn: 211033
2014-06-16 16:08:36 +00:00