Commit Graph

549 Commits

Author SHA1 Message Date
Kevin Enderby
a167fe1877 dd the option, -link-opt-hints to llvm-objdump used with -macho to print the
Mach-O AArch64 linker optimization hints for ADRP code optimization.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@227246 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-27 21:28:24 +00:00
Simon Atanasyan
09a46075ee [ELFYAML] Support mips64 relocation record format in yaml2obj/obj2yaml
MIPS64 ELF file has a very specific relocation record format. Each
record might specify up to three relocation operations. So the `r_info`
field in fact consists of three relocation type sub-fields and optional
code of "special" symbols.

http://techpubs.sgi.com/library/manuals/4000/007-4658-001/pdf/007-4658-001.pdf
page 40

The patch implements support of the MIPS64 relocation record format in
yaml2obj/obj2yaml tools by introducing new optional Relocation fields:
Type2, Type3, and SpecSym. These fields are recognized only if the
object/YAML file relates to the MIPS64 target.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@227044 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-25 13:29:25 +00:00
Lang Hames
bdf296fb06 [Object] Fix a bug in a condition introduced in r226217 - visibility can't be
both hidden and default.

Bug found by inspection by Rafael Espindola. No test: As discussed in the commit
message for r226217 we don't have a good way to test this yet.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226869 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-22 22:04:47 +00:00
Kevin Enderby
57cc8ad672 Fix the Archive::Child::getRawSize() method used by llvm-objdump’s -archive-headers option
and tweak its use in llvm-objdump.  Add back the test case for the -archive-headers option.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226332 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-16 22:10:36 +00:00
Kevin Enderby
cdfe54f8a9 Add the option, -archive-headers, used with -macho to print the Mach-O archive headers to llvm-objdump.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226228 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-15 23:19:11 +00:00
Lang Hames
07e3f81e93 [Object] Add SF_Exported flag. This flag will be set on all symbols that would
be exported from a dylib if their containing object file were linked into one.

No test case: No command line tools query this flag, and there are no Object
unit tests.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226217 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-15 22:33:30 +00:00
Chandler Carruth
1b279144ec [cleanup] Re-sort all the #include lines in LLVM using
utils/sort_includes.py.

I clearly haven't done this in a while, so more changed than usual. This
even uncovered a missing include from the InstrProf library that I've
added. No functionality changed here, just mechanical cleanup of the
include order.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225974 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-14 11:23:27 +00:00
Kevin Enderby
6248d1b153 Add the option, -universal-headers, used with -macho to print the Mach-O universal headers to llvm-objdump.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225537 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-09 19:22:37 +00:00
Kevin Enderby
9a516cdc3e Add printing the LC_THREAD load commands with llvm-objdump’s -private-headers.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224792 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-23 22:56:39 +00:00
Kevin Enderby
5ebdee51db Add printing the LC_ROUTINES load commands with llvm-objdump’s -private-headers.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224627 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-19 22:25:22 +00:00
Kevin Enderby
728b8cfc76 Add printing the LC_SUB_CLIENT load command with llvm-objdump’s -private-headers.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224616 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-19 21:06:24 +00:00
Kevin Enderby
2ef4e25dd1 Add printing the LC_SUB_LIBRARY load command with llvm-objdump’s -private-headers.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224607 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-19 19:48:16 +00:00
Kevin Enderby
604a34e086 Add printing the LC_SUB_UMBRELLA load command with llvm-objdump’s -private-headers.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224548 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-18 23:13:26 +00:00
Kevin Enderby
a42da31d2c Add printing the LC_SUB_FRAMEWORK load command with llvm-objdump’s -private-headers.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224534 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-18 19:24:35 +00:00
Kevin Enderby
1025e9e9d6 Add printing the LC_LINKER_OPTION load command with llvm-objdump’s -private-headers.
Also corrected the name of the load command to not end in an ’S’ as well as corrected
the name of the MachO::linker_option_command struct and other places that had the
word option as plural which did not match the Mac OS X headers.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224485 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-18 00:53:40 +00:00
Kevin Enderby
e479df2161 Add printing the LC_ENCRYPTION_INFO_64 load command with llvm-objdump’s -private-headers
and add tests for the two AArch64 binaries.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224400 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-17 01:01:30 +00:00
Kevin Enderby
46a81fde99 Add printing the LC_ENCRYPTION_INFO load command with llvm-objdump’s -private-headers.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224390 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-16 23:25:52 +00:00
Rafael Espindola
96b7967f83 Start adding thin archive support.
This is just sufficient for 'ar t' to work.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224307 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-16 01:43:41 +00:00
Michael Ilseman
9ecdca9115 Silence more static analyzer warnings.
Add in definedness checks for shift operators, null checks when
pointers are assumed by the code to be non-null, and explicit
unreachables.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224255 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-15 18:48:43 +00:00
Rafael Espindola
c0e334099c Move three methods only used by MCJIT to MCJIT.
These methods are only used by MCJIT and are very specific to it. In fact, they
are also fairly specific to the fact that we have a dynamic linker of
relocatable objects.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223964 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-10 20:46:55 +00:00
Rafael Espindola
b2a5bf25f9 Return ErrorOr<std::unique_ptr<Archive>> form getAsArchive.
This is the same return type of Archive::create.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223827 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-09 21:05:36 +00:00
Rafael Espindola
075a8cee5d Rename createIRObjectFile to just create.
It is a static method of IRObjectFile, so having to use
IRObjectFile::createIRObjectFile was redundant.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223822 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-09 20:36:13 +00:00
Rafael Espindola
8a48c86a5f Move method out of line to make buildbot happy.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223781 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-09 16:18:11 +00:00
Rafael Espindola
4f20ed1c36 Don't lookup an object symbol name in the module.
Instead, walk the obj symbol list in parallel to find the GV. This shouldn't
change anything on ELF where global symbols are not mangled, but it is a step
toward supporting other object formats.

Gold itself is ELF only, but bfd ld supports COFF and the logic in the gold
plugin could be reused on lld.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223780 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-09 16:13:59 +00:00
Jean-Daniel Dupas
206b84f324 Add mach-o LC_RPATH support to llvm-objdump
Summary: Add rpath load command support in Mach-O object and update llvm-objdump to use it.

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223343 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-04 07:37:02 +00:00
Will Newton
e40dbd6233 Widen ELFYAML relocation type to 32 bits
The current 8 bits is sufficient for ELF32 targets but ELF64 requires
32 bits. Add a test for AArch64 that exposes the issue.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222898 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-27 17:20:48 +00:00
Simon Atanasyan
c5e9bf54c7 [Object][Mips] Return address of MIPS symbol with cleared microMIPS indicator bit
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222726 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-25 05:57:55 +00:00
Rui Ueyama
6272b8c4be llvm-readobj: teach it how to dump COFF base relocation table
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222289 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-19 00:18:07 +00:00
David Majnemer
a18e46cbc9 Object, COFF: Tighten the object file parser
We were a little lax in a few areas:
- We pretended that import libraries were like any old COFF file, they
  are not.  In fact, they aren't really COFF files at all, we should
  probably grow some specialized functionality to handle them smarter.
- Our symbol iterators were more than happy to attempt to go past the
  end of the symbol table if you had a symbol with a bad list of
  auxiliary symbols.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222124 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-17 11:17:17 +00:00
David Majnemer
237544b16d obj2yaml, yaml2obj: Add support for COFF executables
In support of serializing executables, obj2yaml now records the virtual address
and size of sections.  It also serializes whatever we strictly need from
the PE header, it expects that it can reconstitute everything else via
inference.

yaml2obj can reconstitute a fully linked executable.

In order to get executables correctly serialized/deserialized, other
bugs were fixed as a circumstance.  We now properly respect file and
section alignments.  We also avoid writing out string tables unless they
are strictly necessary.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221975 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-14 08:15:42 +00:00
David Majnemer
7daa543413 Object, COFF: Clean up formatting in hasExtendedRelocations
No functionality changed intended.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221867 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-13 07:42:05 +00:00
Rui Ueyama
08f70b58cb llvm-readobj: Print out address table when dumping COFF delay-import table
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221855 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-13 03:22:54 +00:00
David Majnemer
16d8031f94 MC, COFF: Use relocations for function references inside the section
Referencing one symbol from another in the same section does not
generally require a relocation.  However, the MS linker has a feature
called /INCREMENTAL which enables incremental links.  It achieves this
by creating thunks to the actual function and redirecting all
relocations to point to the thunk.

This breaks down with the old scheme if you have a function which
references, say, itself.  On x86_64, we would use %rip relative
addressing to reference the start of the function from out current
position.  This would lead to miscompiles because other references might
reference the thunk instead, breaking function pointer equality.

This fixes PR21520.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221678 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-11 08:43:57 +00:00
Simon Atanasyan
848edb1bfa [ELF][yaml2obj] Handle additional MIPS specific st_other field flags
The ELF symbol `st_other` field might contain additional flags besides
visibility ones. This patch implements support for some MIPS specific
flags.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221491 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-06 22:46:24 +00:00
Simon Atanasyan
5563be0f4f Add accessor to get 'visibility' part of st_other field
This new `getVisibility()` function will also be used in the LLD code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221392 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-05 20:47:35 +00:00
David Majnemer
4787059b2f llvm-readobj: Add support for dumping the DOS header in PE files
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221333 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-05 06:24:35 +00:00
Kevin Enderby
a25032214d Add the code and test cases for 32-bit Intel to llvm-objdump’s Mach-O symbolizer.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221211 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-04 00:43:16 +00:00
Lang Hames
7b8ba81502 [Object] Modify OwningBinary's interface to separate inspection from ownership.
The getBinary and getBuffer method now return ordinary pointers of appropriate
const-ness. Ownership is transferred by calling takeBinary(), which returns a
pair of the Binary and a MemoryBuffer.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221003 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-31 21:37:49 +00:00
David Majnemer
a2715904e5 Object, COFF: Cleanup symbol type code, improve binutils compatibility
Do a better job classifying symbols.  This increases the consistency
between the COFF handling code and the ELF side of things.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220952 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-31 05:07:00 +00:00
Jan Wen Voung
3262c451c4 Fix getRelocationValueString to return the symbol name for EM_386.
Summary: This helps llvm-objdump -r to print out the symbol name along
with the relocation type on x86. Adjust existing tests from checking
for "Unknown" to check for the symbol now.

Test Plan: Adjusted test/Object tests.

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220866 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-29 18:37:13 +00:00
Lang Hames
acaf8f5618 [MCJIT] Temporarily revert r220245 - it broke several bots.
(See e.g. http://bb.pgr.jp/builders/cmake-llvm-x86_64-linux/builds/17653)



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220249 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-21 00:24:02 +00:00
Lang Hames
32aaaeaa05 [MCJIT] Make MCJIT honor symbol visibility settings when populating the global
symbol table.

Patch by Anthony Pesch. Thanks Anthony!



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220245 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-20 23:39:54 +00:00
Alexey Samsonov
e505b3d541 Constify getELFDynamicSymbolIterators standalone function. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220232 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-20 20:33:20 +00:00
Alexey Samsonov
262b278dae Add const version of OwningBinary::getBinary
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220231 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-20 20:32:47 +00:00
Alexey Samsonov
9170808b2a Be more specific about return type of MachOUniversalBinary::getObjectForArch
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220230 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-20 20:30:57 +00:00
Alexey Samsonov
10051f0f62 Constify input argument of RelocVisitor and DWARFContext constructors. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220228 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-20 20:28:51 +00:00
Alexander Potapenko
4976a53fb7 Add MachOObjectFile::getUuid()
This CL introduces MachOObjectFile::getUuid(). This function returns an ArrayRef to the object file's UUID, or an empty ArrayRef if the object file doesn't contain an LC_UUID load command.
The new function is gonna be used by llvm-symbolizer.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219866 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-15 23:35:45 +00:00
David Majnemer
1e0e306deb Object, COFF: Relax aux symbols for section definitions
We, I suppose naïvely, believed the COFF specification with regard to
auxiliary symbol records which defined sections: they specified that the
symbol value should be zero.  However, dumpbin and MinGW's objdump do
not consider the symbol value as a restriction.  Relaxing this allows us
to properly dump MinGW linked executables.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219479 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-10 06:58:11 +00:00
David Majnemer
06f1f357e3 Object, COFF: Move the VirtualSize/SizeOfRawData logic to getSectionSize
While getSectionContents was updated to do the right thing,
getSectionSize wasn't.  Move the logic to getSectionSize and leverage it
from getSectionContents.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219391 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-09 08:42:31 +00:00
Rui Ueyama
f02f03c21a Object: Add range iterators for COFF import/export table
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219383 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-09 02:16:38 +00:00