Commit Graph

89 Commits

Author SHA1 Message Date
Tim Northover cf78d37fd6 [mach-o] create __unwind_info section on x86_64
This is a minimally useful pass to construct the __unwind_info section in a
final object from the various __compact_unwind inputs. Currently it doesn't
produce any compressed pages, only works for x86_64 and will fail if any
function ends up without __compact_unwind.

rdar://problem/18208653

llvm-svn: 218703
2014-09-30 21:29:54 +00:00
Rafael Espindola 0941b568ce Update for LLVM api change
llvm-svn: 216395
2014-08-25 18:16:56 +00:00
Joerg Sonnenberger bbe75b99f0 References cannot be bound to null.
llvm-svn: 213323
2014-07-17 22:30:09 +00:00
Rafael Espindola 372bc70c63 Update for llvm api change.
llvm-svn: 210919
2014-06-13 17:20:48 +00:00
Rafael Espindola 54427ccef3 include system_error directly.
llvm-svn: 210801
2014-06-12 17:15:58 +00:00
Rafael Espindola 1675d51eac Run llvm/utils/sort_includes.py in a few files.
This will reduce the noise in a followup patch.

llvm-svn: 210800
2014-06-12 17:12:28 +00:00
Rafael Espindola b1a4d3a26c Don't import error_code into the lld namespace.
llvm-svn: 210785
2014-06-12 14:53:47 +00:00
Rafael Espindola 99c78a9f3c Don't use make_error_code from the llvm namespace.
llvm-svn: 210741
2014-06-12 03:13:49 +00:00
Rui Ueyama e05d380486 Move Simple.h and Alias.h to include/Core.
Because the files in Core actually depend on these files.

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

llvm-svn: 210710
2014-06-11 21:47:51 +00:00
Rafael Espindola 7b8b9ae1cb Use std::error_code instead of llvm::error_code.
This is an update for a llvm api change.

llvm-svn: 210689
2014-06-11 19:05:58 +00:00
Rui Ueyama d7b32b93e0 Remove dead parameter.
llvm-svn: 210461
2014-06-09 09:58:53 +00:00
Iain Sandoe c4d9bedcfc Initial set of Makefiles
This provides support for the autoconfing & make build style.
The format, style and implementation follows that used within the llvm and clang projects.

TODO: implement out-of-source documentation builds.
llvm-svn: 210177
2014-06-04 09:54:07 +00:00
Rui Ueyama 9aee050a0c Remove group-parent references.
Previously section groups are doubly linked to their children.
That is, an atom representing a group has group-child references
to its group contents, and content atoms also have group-parent
references to the group atom. That relationship was invariant;
if X has a group-child edge to Y, Y must have a group-parent
edge to X.

However we were not using group-parent references at all. The
resolver only needs group-child edges.

This patch simplifies the section group by removing the unused
reverse edge. No functionality change intended.

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

llvm-svn: 210066
2014-06-03 03:07:49 +00:00
Rafael Espindola 63ed1a3519 Use error_code() instead of error_code::succes()
There is no std::error_code::success, so this removes much of the noise
in transitioning to std::error_code.

llvm-svn: 209948
2014-05-31 01:22:21 +00:00
Rui Ueyama beacd25780 Re-submit r207884: Remove dead code
Differential Revision: http://reviews.llvm.org/D3599

llvm-svn: 207989
2014-05-05 18:56:04 +00:00
Rui Ueyama 82d62c4420 Revert "Remove dead code."
This reverts commit r207884 which was prematurely committed by accident.

llvm-svn: 207886
2014-05-02 23:45:28 +00:00
Rui Ueyama d50ed14d92 Remove dead code.
isAlias always returns false and no one is using it. It was
originally added Atom to query if an atom is an alias for another
atom, assuming that alias atoms are different from normal atoms.

We now support atom aliasing, but the way that's implemented is
in a different way than what isAlias assumed. An alias atom is
just a regular defined atom with no content, and it has a layout-
before edge to alias-to atom so that they are layed out at the
same location in the result. So this is dead code, and it doesn't
make much sense to keep it.

llvm-svn: 207884
2014-05-02 23:43:59 +00:00
David Majnemer 678088148c Update to match changes made in r205955
llvm-svn: 205956
2014-04-10 07:49:18 +00:00
Shankar Easwaran 9316c40a1b [core] support .gnu.linkonce sections
.gnu.linkonce sections are similar to section groups.

They were supported before section groups existed and provided a way
to resolve COMDAT sections using a different design.

There are few implementations that use .gnu.linkonce sections
to store simple floating point constants which doesnot require complex section
group support but need a way to store only one copy of the floating point
constant in a binary.

.gnu.linkonce based symbol resolution achieves that.

Review : http://llvm-reviews.chandlerc.com/D3242

llvm-svn: 205280
2014-04-01 03:49:55 +00:00
Shankar Easwaran 50136f1f4e Revert "[core] support .gnu.linkonce sections"
This reverts commit 5d5ca72a7876c3dd3dd1db83dc6a0d74be9e2cd1.

Discuss on a better design to raise error when there is a similar group with Gnu
linkonce sections and COMDAT sections.

llvm-svn: 205224
2014-03-31 17:12:06 +00:00
Shankar Easwaran 79cfed55fc [core] support .gnu.linkonce sections
.gnu.linkonce sections are similar to section groups. They were supported before
section groups existed and provided a way to resolve COMDAT sections using a
different design. There are few implementations that use .gnu.linkonce sections
to store simple floating point constants which doesnot require complex section
group support but need a way to store only one copy of the floating point
constant. .gnu.linkonce based symbol resolution achieves that.

llvm-svn: 205163
2014-03-31 03:16:37 +00:00
Shankar Easwaran 7ac2a3df64 [core] add SectionGroup support
Review : http://llvm-reviews.chandlerc.com/D3182

llvm-svn: 204830
2014-03-26 16:37:13 +00:00
Rui Ueyama 7ad72ebc5e [PECOFF] Support yet another new type of weak symbol.
COMDAT_SELECT_LARGEST is a COMDAT type that make linker to choose the largest
definition from among all of the definition of a symbol. If the size is the
same, the choice is arbitrary.

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

llvm-svn: 204172
2014-03-18 19:37:50 +00:00
Ahmed Charles 13c70b6d4b Replace OwningPtr with std::unique_ptr.
This results in some simplifications to the code where an OwningPtr had to
be used with the previous api and then ownership moved to a unique_ptr for
the rest of lld.

llvm-svn: 203809
2014-03-13 16:20:38 +00:00
Ahmed Charles d6432c8aed [Cleanup] Sort includes.
llvm-svn: 203666
2014-03-12 15:55:13 +00:00
Rui Ueyama c79dd2f80a [PECOFF] Support a new type of weak symbol.
Summary:
COMDAT_SELECT_SAME_SIZE is a COMDAT type that I presume exist only in COFF.
The semantics of the type is that linker should merge such COMDAT sections if
their sizes are the same. Otherwise it's an error.

Reviewers: Bigcheese, shankarke, kledzik

CC: llvm-commits

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

llvm-svn: 203308
2014-03-07 23:05:10 +00:00
Rui Ueyama 16e543bc02 Add "override" and remove "virtual" where appropriate.
For the record, I used clang-modernize to add "override" and perl to remove
"virtual".

llvm-svn: 203164
2014-03-06 21:14:04 +00:00
Rafael Espindola f27f9fa136 Update for LLVM api change.
llvm-svn: 202054
2014-02-24 18:20:36 +00:00
Rafael Espindola 27810169cb Don't assume that F_None is the default. It is about to change.
llvm-svn: 202039
2014-02-24 15:06:34 +00:00
Simon Atanasyan 0743a72caa Accept and handle absolute symbols with empty name.
llvm-svn: 200911
2014-02-06 07:35:16 +00:00
Shankar Easwaran 3d8de47f76 Fix trailing whitespace.
llvm-svn: 200182
2014-01-27 03:09:26 +00:00
Nick Kledzik 0052bd4a34 Fix spacing
llvm-svn: 199074
2014-01-13 04:08:15 +00:00
Nick Kledzik 8293c711e7 [yaml] use BumpPtrAllocator for string copies
llvm-svn: 198987
2014-01-11 01:11:49 +00:00
Nick Kledzik 6edd722a2c [mach-o] enable mach-o and native yaml to be intermixed
The main goal of this patch is to allow "mach-o encoded as yaml" and "native
encoded as yaml" documents to be intermixed.  They are distinguished via 
yaml tags at the start of the document.  This will enable all mach-o test cases
to be written using yaml instead of checking in object files.

The Registry was extend to allow yaml tag handlers to be registered.  The
mach-o Reader adds a yaml tag handler for the tag "!mach-o". 

Additionally, this patch fixes some buffer ownership issues.  When parsing
mach-o binaries, the mach-o atoms can have pointers back into the memory 
mapped .o file.  But with yaml encoded mach-o, name and content are ephemeral, 
so a copyRefs parameter was added to cause the mach-o atoms to make their
own copy.  

llvm-svn: 198986
2014-01-11 01:07:43 +00:00
Nick Kledzik f30e848432 Restore vertical alignment lost by clang-format
llvm-svn: 197834
2013-12-20 20:34:19 +00:00
Rui Ueyama 170a1a892e Run clang-format on r197727.
llvm-svn: 197788
2013-12-20 07:48:29 +00:00
Nick Kledzik e555277780 [lld] Introduce registry and Reference kind tuple
The main changes are in:
  include/lld/Core/Reference.h
  include/lld/ReaderWriter/Reader.h
Everything else is details to support the main change.

1) Registration based Readers
Previously, lld had a tangled interdependency with all the Readers.  It would
have been impossible to make a streamlined linker (say for a JIT) which
just supported one file format and one architecture (no yaml, no archives, etc).
The old model also required a LinkingContext to read an object file, which
would have made .o inspection tools awkward.

The new model is that there is a global Registry object. You programmatically 
register the Readers you want with the registry object. Whenever you need to 
read/parse a file, you ask the registry to do it, and the registry tries each 
registered reader.

For ease of use with the existing lld code base, there is one Registry
object inside the LinkingContext object. 


2) Changing kind value to be a tuple
Beside Readers, the registry also keeps track of the mapping for Reference
Kind values to and from strings.  Along with that, this patch also fixes
an ambiguity with the previous Reference::Kind values.  The problem was that
we wanted to reuse existing relocation type values as Reference::Kind values.
But then how can the YAML write know how to convert a value to a string? The
fix is to change the 32-bit Reference::Kind into a tuple with an 8-bit namespace
(e.g. ELF, COFFF, etc), an 8-bit architecture (e.g. x86_64, PowerPC, etc), and
a 16-bit value.  This tuple system allows conversion to and from strings with 
no ambiguities.

llvm-svn: 197727
2013-12-19 21:58:00 +00:00
Rui Ueyama 6a2e745351 [PECOFF] Refactor IdataPass.
This patch is to basically move the functionality to construct Data Directory
from IdataPass to WriterPECOFF.

Data Directory is a part of the PE/COFF header and contains the addresses of
the import tables.

We used to represent the link from Data Directory to the import tables as
relocation references. The idea behind it is that, because relocation
references are processed by the Writer, we wouldn't have to do anything special
to fill the addresses of the import tables. I thought that the addresses would
be set "automatically".

But it turned out that that design made the pass and the writer rather
complicated. In order to make relocation references between Data Directory to
the import tables, these data structures needed to be represented as Atom.
However, because Data Directory is not a section content but a part of the
PE/COFF header, it did not fit well as an Atom. So we ended up having
complicated code both in IdataPass and the writer.

This patch simplifies it.

One side effect of this patch is that we now have ".idata.a", ".idata.d" and
"idata.t" sections for the import address table, the import directory table,
and the import lookup table. The writer looks for the sections by name to find
the start addresses of the sections. We probably should have a better way to
find a specific atom from the core linking result, but currently using the
section name seems to be the easiest way to do that. The Windows loader do not
care about the import table's section layout.

llvm-svn: 197016
2013-12-11 08:23:37 +00:00
Michael J. Spencer b8ab9f52ca Add explictly exported atoms and export R_*_COPY'ed atoms.
llvm-svn: 194278
2013-11-08 21:04:20 +00:00
Rui Ueyama c1800beb55 Remove unnecessary namespace qualifier.
llvm-svn: 194037
2013-11-05 01:37:40 +00:00
Shankar Easwaran 6775518254 [ELF] Fix RO/RW note sections.
llvm-svn: 193482
2013-10-26 19:38:39 +00:00
Shankar Easwaran 3176d61332 [PECOFF] Add dataDirectoryEntry as a recognized ContentType
llvm-svn: 193477
2013-10-26 19:38:29 +00:00
Shankar Easwaran 1d3c48f1fc [Layout] Assign ordinals in Resolution order.
llvm-svn: 192277
2013-10-09 05:23:23 +00:00
Rui Ueyama c6015f6476 Update error classes from all lowercase to camel case.
llvm-svn: 192261
2013-10-09 00:57:22 +00:00
Shankar Easwaran a96f3a3da4 [lld][InputGraph] Change the Resolver to use inputGraph
Changes :-

a) Functionality in InputGraph to insert Input elements at any position
b) Functionality in the Resolver to use nextFile
c) Move the functionality of assigning file ordinals to InputGraph
d) Changes all inputs to MemoryBuffers
e) Remove LinkerInput, InputFiles, ReaderArchive

llvm-svn: 192081
2013-10-07 02:47:09 +00:00
Michael J. Spencer 4355bb9d22 [Core] Add type and size to SharedLibraryAtom.
llvm-svn: 191466
2013-09-26 22:08:43 +00:00
Shankar Easwaran a17e5bc02a [lld][ELF] Support non alloc sections in the Writer.
This also makes it support debugging executables built with lld.

Initial patch done by Bigcheese. This is only a revised patch to
have the functionality in the Writer.

llvm-svn: 191032
2013-09-19 20:07:01 +00:00
Shankar Easwaran 1b0256c379 [lld][YAML] RefNameResolver : add only if name/refname is not empty
llvm-svn: 190903
2013-09-17 23:38:04 +00:00
Rui Ueyama e5416ec2d2 Add a fallback mechanism for undefined atom.
In COFF, an undefined symbol can have up to one alternative name. If a symbol
is resolved by its regular name, then it's linked normally. If a symbol is not
found in any input files, all references to the regular name are resolved using
the alternative name. If the alternative name is not found, it's a link error.
This mechanism is called "weak externals".

To support this mechanism, I added a new member function fallback() to undefined
atom. If an undefined atom has the second name, fallback() returns a new undefined
atom that should be used instead of the original one to resolve undefines. If it
does not have the second name, the function returns nullptr.

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

llvm-svn: 190625
2013-09-12 19:14:05 +00:00
Rui Ueyama 2ff9d70ac4 Run clang-format.
llvm-svn: 190554
2013-09-11 22:21:42 +00:00