Commit Graph

249 Commits

Author SHA1 Message Date
Shankar Easwaran 7f1146c494 [LinkingContext] make LinkingContext non-const
llvm-svn: 192183
2013-10-08 15:43:48 +00:00
Rui Ueyama 8b8e5216af Make bitmask an unsigned type.
llvm-svn: 192163
2013-10-08 03:59:45 +00:00
Rui Ueyama 094546836b Add comments. Early return.
llvm-svn: 192149
2013-10-08 00:43:53 +00:00
Rui Ueyama f8c54842d6 Convert error code structs to scoped enums.
Summary:
The original code with enum "_" is intended to emulate scoped enums.
Now we have real scoped enums, so use it.

Reviewers: Bigcheese

CC: llvm-commits

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

llvm-svn: 192148
2013-10-08 00:43:50 +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
Shankar Easwaran 7915ff34b7 [lld][LinkingContext][ELF] Allow different output file types.
This adds an option --output-filetype that can be set to either
YAML/Native(case insensitive). The linker would create the outputs
associated with the type specified by the user.

Changes all the tests to use the new option.

llvm-svn: 191183
2013-09-23 04:24:15 +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
Rui Ueyama 6f32549623 [PECOFF] Handle weak external symbols.
Used the fallback mechanism to implement COFF weak external symbols.

llvm-svn: 190633
2013-09-12 21:42:52 +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
Joerg Sonnenberger bd25241e0e Drop the context forceLoadAllArchives() support. Rename the isForceLoad
attribute in LinkerInput to isWholeArchive and use that for deciding
whether library archives should be expanded. Implement the -all_load
option of the Darwin linker using this flag and drop the support for it
in GNU mode.

llvm-svn: 190275
2013-09-08 13:30:14 +00:00
Joerg Sonnenberger 5e235de9d3 Change the parseFile argument from MemoryBuffer pointer to LinkerInput
reference. Move readFile logic into FileNode::createLinkerInput.

llvm-svn: 190253
2013-09-07 17:55:28 +00:00
Shankar Easwaran 8c705690ab [lld][ELF] Differentiate between Note sections(RW/RO)
It looks like there is a possibility of seeing RO/RW note sections
and we would need to create an appropriate RO/RW segment associated
with them.

Adds a test too.

llvm-svn: 189907
2013-09-04 02:42:02 +00:00
Shankar Easwaran b85f1857a1 [lld][ELF] Emit note sections
Emit note sections if the input contains a note section.

Also emit a note segment.

llvm-svn: 189896
2013-09-04 00:51:42 +00:00
Rui Ueyama 4313451ba4 Resolver: Do not use assert() to notify user input error.
llvm-svn: 189775
2013-09-03 00:50:22 +00:00
Shankar Easwaran d26c8e3463 [lld][LinkingContext] Atoms created from command line options should be available in YAML
This adds an API to the LinkingContext for flavors to add Internal files
containing atoms that need to appear in the YAML output as well, when -emit-yaml
switch is used.

Flavors can add more internal files for other options that are needed.

llvm-svn: 189718
2013-08-31 05:27:38 +00:00
Rui Ueyama a372a9b503 Use do-while instead of a magic number. No functionality change.
llvm-svn: 189413
2013-08-27 23:10:26 +00:00
Shankar Easwaran d9e0a49357 [lld][ELF] Rename typeTLV content type for ELF
typeTLV content type is used by Darwin to represent thread local
storage. A new contentType has to be made to represent ELF
thread local storage data. These have been set to

- typeThreadZeroFill (represents TBSS storage)
- typeThreadData     (represents TDATA storage)

llvm-svn: 189137
2013-08-23 20:03:28 +00:00
Rui Ueyama 02d0bf0f80 Fix spelling error. s/Libary/Library/g.
llvm-svn: 188049
2013-08-09 04:19:54 +00:00
Rui Ueyama 0ca149fce9 Rename TargetInfo -> LinkingContext.
Also change some local variable names: "ti" -> "context" and
"_targetInfo" -> "_context".

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

llvm-svn: 187823
2013-08-06 22:31:59 +00:00
Nick Kledzik 196d7a77a3 fix typo in error string
llvm-svn: 186996
2013-07-23 22:17:47 +00:00
Rui Ueyama c8a53795ab [PECOFF] Support linking against DLL.
This patch adds a new pass, IdataPass, to transform shared atom references
to real references and to construct the .idata section data. With this patch
lld can produce a working Hello World program by linking it against
kernel32.dll and user32.dll.

Reviewers: Bigcheese

CC: llvm-commits

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

llvm-svn: 186071
2013-07-11 08:46:21 +00:00
Rui Ueyama 7b7b0b9f7d Removed unnecessary "class" keyword.
llvm-svn: 184589
2013-06-21 19:59:15 +00:00
Rafael Espindola c1b32686fe Factor duplicated yamlReader creation.
The yaml reader is not specific to any file format. This patch moves
it to TargetInfo and makes validate a non virtual interface so that it
can be constructed from a single location.

The same method will be used to create a reader for llvm bitcode
files.

llvm-svn: 183740
2013-06-11 12:36:05 +00:00
Michael J. Spencer bd66d04f34 Instrument things.
llvm-svn: 182789
2013-05-28 18:55:39 +00:00
Rui Ueyama 90b3b92a8b [lld] Use range based for loop instead of explicit iterators (no functionality change)
llvm-svn: 181503
2013-05-09 04:00:44 +00:00
Rui Ueyama 60f5f30687 [lld] Add comments to InputFiles::searchLibraries() arguments.
llvm-svn: 181492
2013-05-08 23:54:10 +00:00
Nick Kledzik 80d8308b57 Use anonymous namespace for local classes. Patch by Rui Ueyama
llvm-svn: 181473
2013-05-08 21:34:11 +00:00
Michael J. Spencer 9d70cef481 [Core] Allow weak symbols in shared library when linking.
Patch by Rui Ueyama.

llvm-svn: 180209
2013-04-24 19:00:26 +00:00
Shankar Easwaran eeee23e60a This adds functionality for undefined atoms from dynamic libraries to be added
to the list of undefined atoms. 

The processing of undefined atoms from dynamic libraries is controlled by
use-shlib-undefines command line option. 

This patch also adds additional command line arguments to allow/disallow
unresolved symbols from shared libraries and mimics GNU ld behavior.

llvm-svn: 179257
2013-04-11 02:56:30 +00:00
Michael J. Spencer d4eb47c110 Add VTune as an optional external dependency and add task tracking.
llvm-svn: 178940
2013-04-06 00:56:40 +00:00
Michael J. Spencer e6d5609de4 Revert "Correctly pass ownership of MemoryBuffers."
llvm-svn: 178918
2013-04-05 22:04:44 +00:00
Michael J. Spencer ce1e53e19c Correctly pass ownership of MemoryBuffers.
llvm-svn: 178914
2013-04-05 21:08:30 +00:00
Michael J. Spencer 096ea03f31 Fix uninitialized variables. Found by ubsan.
llvm-svn: 178913
2013-04-05 21:07:44 +00:00
Nick Kledzik c314b46e71 This is my Driver refactoring patch.
The major changes are:
1) LinkerOptions has been merged into TargetInfo
2) LinkerInvocation has been merged into Driver
3) Drivers no longer convert arguments into an intermediate (core) argument 
   list, but instead create a TargetInfo object and call setter methods on 
   it. This is only how in-process linking would work. That is, you can 
   programmatically set up a TargetInfo object which controls the linking.
4) Lots of tweaks to test suite to work with driver changes
5) Add the DarwinDriver
6) I heavily doxygen commented TargetInfo.h

Things to do after this patch is committed:
a) Consider renaming TargetInfo, given its new roll. 
b) Consider pulling the list of input files out of TargetInfo. This will 
   enable in-process clients to create one TargetInfo the re-use it with 
   different input file lists.
c) Work out a way for Drivers to format the warnings and error done in 
   core linking.

llvm-svn: 178776
2013-04-04 18:59:24 +00:00
Michael J. Spencer 67f25272f1 [SymbolTable][Perf] Use hash_combine instead of a custom hash, also use memcmp.
ArrayRef<uint8_t>::equals(); lowers to a byte compare loop :(.

TODO: Figure out if we are getting hash collisions, or just have a lot of equal
content. Also test if crypto hashing the content instead of full compare is
better.

llvm-svn: 177588
2013-03-20 22:18:22 +00:00
Shankar Easwaran 8962feb915 [lld] remove trailing whitespace
llvm-svn: 177079
2013-03-14 16:09:49 +00:00
Michael J. Spencer a55e37f477 Add basic linker script parsing.
llvm-svn: 176309
2013-03-01 00:03:36 +00:00
Shankar Easwaran db74ffbe72 [ELF][Hexagon]add typeZeroFillFast
llvm-svn: 175983
2013-02-24 03:09:10 +00:00
Shankar Easwaran 873c9ffba0 add changes for typeDataFast
llvm-svn: 175901
2013-02-22 17:18:53 +00:00
Michael J. Spencer be1100e192 [Resolver] Improve undefined symbol error.
llvm-svn: 174277
2013-02-03 10:50:06 +00:00
Michael J. Spencer 280dadbbaf [Core] Only complain about undefined symbols if they are marked as canBeNullNever.
llvm-svn: 174107
2013-01-31 22:56:13 +00:00
Nick Kledzik 36293f6512 Add SectionPosition and OrderPass
llvm-svn: 173300
2013-01-23 22:32:56 +00:00
Michael J. Spencer c0d3c4efe6 Add PassManager.
It owns and manages passes.

llvm-svn: 173287
2013-01-23 20:03:10 +00:00
Michael J. Spencer 4586fbcbad [Core] Move Resolver and SymbolTable over to TargetInfo.
No functionality change.

llvm-svn: 173192
2013-01-22 20:49:42 +00:00
Michael J. Spencer d68d6196af Add {,ELF,MachO}TargetInfo.
llvm-svn: 173117
2013-01-22 02:15:30 +00:00
Nick Kledzik 233f537799 Add new merge-by-content Merge attribute for use by anonymous
constants and string literals which the linker should coalesce.

llvm-svn: 172495
2013-01-15 00:17:57 +00:00
Nick Kledzik cc3d2dca60 Better tie together ContentType and Permissions.
Since most content types (e.g. typeCode) have a 
preferred Permission, add a function to do that mapping.
Then hook up to YAML Reader and Writer such that
the 'permissions:' key does not need to be specified unless
overriding what the content type prefers.

llvm-svn: 171929
2013-01-09 01:17:12 +00:00
Nick Kledzik 80fe907903 fix typo
llvm-svn: 171916
2013-01-08 23:43:11 +00:00
Nick Kledzik 6b079f5e2f Removes files for separate ReaderYAML.cpp and WriterYAML.cpp
and adds a new file ReaderWriterYAML.cpp that uses YAML I/O.

Lots of tweaks to test suite for slightly different YAML encoding.

llvm-svn: 171592
2013-01-05 02:22:35 +00:00
Michael J. Spencer 552074f18e Style fixes.
llvm-svn: 171531
2013-01-04 21:18:34 +00:00
Michael J. Spencer 7f693c50db Slightly better diagnostics on duplicate symbols.
llvm-svn: 171528
2013-01-04 21:17:51 +00:00
Benjamin Kramer f7798e34c9 Add library dependencies to the lld cmake build.
llvm-svn: 169306
2012-12-04 21:09:04 +00:00
Hemant Kulkarni f828613945 Add absolute symbol scope recognition in lld/Core
llvm-svn: 167394
2012-11-05 19:13:54 +00:00
Nick Kledzik 751eb3d2b3 use llvm_unreachable() instead of assert(0) for invalid enum values in switch statements
llvm-svn: 158542
2012-06-15 20:37:24 +00:00
Nick Kledzik abb6981f68 Major refactoring: Remove Platform concept. In its place there are
now Reader and Writer subclasses for each file format.  Each Reader and
Writer subclass defines an "options" class which controls how that Reader
or Writer operates.

llvm-svn: 157774
2012-05-31 22:34:00 +00:00
Filipe Cabecinhas 6f970e8458 Remove some compilation warnings.
llvm-svn: 157253
2012-05-22 14:45:44 +00:00
Nick Kledzik a3c24f447f remove completed items
llvm-svn: 156143
2012-05-04 01:14:02 +00:00
Nick Kledzik 3011259a85 Rework how YAMLReader is layered on top of YAMLParser. Turn hand written
recursive descent functions into one table driven parser.  Add proper
error recovery and reporting.  Add lots of test cases with semantics errors
and verify error messages.

llvm-svn: 156136
2012-05-03 23:55:34 +00:00
Michael J. Spencer d0d5ec4a38 Convert the YAMLReader to use LLVM/Support/YAMLParser.
llvm-svn: 155847
2012-04-30 21:20:13 +00:00
Michael J. Spencer 63d320064d Remove whitespace.
llvm-svn: 155846
2012-04-30 21:19:44 +00:00
Nick Kledzik 20e652d627 Add way to represent static archives in yaml test cases.
Add SharedLibraryFile and ArchiveLibraryFile subclasses of File.

Add command line options to lld-core to set various ResolverOptions settings
and added lots of test cases to verify the options work.

llvm-svn: 155183
2012-04-20 01:24:37 +00:00
Nick Kledzik bb963dfb7e Factor out core linking options from Platform in a new ResolverOptions
class.  Change Resolver to no longer use Platform.  Core linking
now issues errors directly.  We need to factor that out later.

Rework how Darwin executable writer finds "main" atom.  It now
adds to core linking an Atom  which has a Reference to "main".  

llvm-svn: 155060
2012-04-18 21:55:06 +00:00
Nick Kledzik 467209b1d4 Remove definedAtomsBegin() and co. so that C++11 range based for loops can be used
llvm-svn: 154302
2012-04-09 00:58:21 +00:00
Nick Kledzik 062a98cff0 Rename referencesBegin() to begin() so that C++11 range based for loops can be used
llvm-svn: 154301
2012-04-08 23:52:13 +00:00
Michael J. Spencer d73a53f158 [docs] Add more open projects.
llvm-svn: 154277
2012-04-08 03:47:49 +00:00
Michael J. Spencer f9bc125c5a [docs] Add open projects page that includes the TODO.txt files.
llvm-svn: 154274
2012-04-07 23:10:01 +00:00
Nick Kledzik 5a1528f49d Add to-do lists
llvm-svn: 154246
2012-04-07 01:54:17 +00:00
Nick Kledzik b334be1ed2 First implementation of Darwin Platform. It is rich enough to generate
a hello world executable from atoms.  There is still much to be flushed out.
Added one test case, test/darwin/hello-world.objtxt, which exercises the
darwin platform.

Added -platform option to lld-core tool to dynamically select platform.

llvm-svn: 154242
2012-04-07 01:31:00 +00:00
Michael J. Spencer 765792d5d1 Remove trailing whitespace.
llvm-svn: 153964
2012-04-03 18:40:27 +00:00
Michael J. Spencer e6203a57b5 Steal LLVM.h from Clang. This brings in very commonly used LLVM ADT/Support
types into the lld namespace.

llvm-svn: 153963
2012-04-03 18:39:40 +00:00
Michael J. Spencer b495562b5d Use the LLVM RTTI library.
llvm-svn: 153912
2012-04-02 23:56:36 +00:00
Michael J. Spencer c9d2506a76 Replace all uses of NULL with nullptr.
llvm-svn: 153677
2012-03-29 19:39:14 +00:00
Michael J. Spencer d58cf03cff llvm::OwningPtr -> std::unique_ptr.
llvm-svn: 153620
2012-03-29 00:49:50 +00:00
Michael J. Spencer cfd029fd91 Rearange header order to match llvm style. This exposed some missing types.
Also fix some Platform.h includes that somehow got missed last time.

llvm-svn: 153590
2012-03-28 19:04:02 +00:00
Nick Kledzik f4e2c73fa7 Add Pass to instantiate GOT entries
llvm-svn: 152874
2012-03-15 23:36:24 +00:00
Michael J. Spencer 166b090a46 Audit uses of StringRef::getAsInteger.
llvm-svn: 152565
2012-03-12 18:13:36 +00:00
Michael J. Spencer e753cbc685 Fix MSVC incompatibilities.
llvm-svn: 152389
2012-03-09 05:27:43 +00:00
Michael J. Spencer b5ef4df359 StringRef is not null terminated.
llvm-svn: 152388
2012-03-09 05:27:20 +00:00
Michael J. Spencer 9f91f958b1 Use llvm/Support/DataTypes instead of stdint.h
llvm-svn: 152387
2012-03-09 05:27:11 +00:00
Michael J. Spencer 4ff3c79998 Use nullptr instead of NULL, and remove use of VLA.
llvm-svn: 152386
2012-03-09 05:26:55 +00:00
Nick Kledzik 1a6615dc88 Sources now require C++11 to build.
Add first linker pass (StubsPass) which looks for calls to shared library
symbols and replaces them with calls to a StubAtom.  On ELF system, a "stub"
is a PLT entry.  Added a simple test case.

Pass a Platform object to YAML reader and writer for converting fixup kinds 
between names and values.

Change output of Resolver to be a File object instead of a vector of Atoms.
Thus, passes operate on a File instead of just Atoms.

Rework how to walk through a File's Atoms. Now iterator based instead of 
a method that visits each atom.  

llvm-svn: 152269
2012-03-08 00:18:30 +00:00
Nick Kledzik 6bc04c6904 Add support for SharedLibraryAtoms (proxy atoms for exported symbols from a
shared library) and AbsoluteAtoms (proxy atoms for absolute address (e.g. ROM)).
Redesign weak importing as can-be-null-at-runtime and can-be-null-at-build-time.
Add lots of test cases for all the above.

llvm-svn: 151204
2012-02-22 21:56:59 +00:00
Nick Kledzik af18a2b29f use llvm::DenseMap instead of std::map
llvm-svn: 150547
2012-02-15 00:50:07 +00:00
Nick Kledzik 49d6cc8457 (no commit message)
llvm-svn: 150539
2012-02-15 00:38:09 +00:00
Nick Kledzik 23384e84af Add support for UndefinedAtom in yaml and native format. Add test cases with undefined atoms
llvm-svn: 149962
2012-02-07 02:59:54 +00:00
Michael J. Spencer 7aba8957c1 Cleanup system_error extensions.
llvm-svn: 149432
2012-01-31 21:47:13 +00:00
Michael J. Spencer 8c36f458fa &vectorval[0] is UB when vectorval.size() == 0.
llvm-svn: 149430
2012-01-31 21:46:41 +00:00
Michael J. Spencer 4e45ebb92c Fix use after free.
llvm-svn: 149429
2012-01-31 21:46:29 +00:00
Michael J. Spencer 846fe662ba If cont.size() is 0, the expression &_contentPool[result] has undefined
behaivior because it indexes past the end of _contentPool.

llvm-svn: 149427
2012-01-31 21:46:05 +00:00
Michael J. Spencer b2bd733593 Flexible array members are not in C++03, and MSVC doesn't support them.
llvm-svn: 149426
2012-01-31 21:45:53 +00:00
Nick Kledzik 55fd6beb00 First chunk of native object file reader/writer. The lld-core tool now reads YAML file, links, writes that out as native object format, then reads that native file, then writes the YAML to stdout. Thus the test suite tests both YAML reading/writing as well as native object file reading/writing.
llvm-svn: 148256
2012-01-16 22:03:44 +00:00
Nick Kledzik f4fb2c5ac8 A couple of big refactorings: 1) Move most attributes of Atom down to DefinedAtom, so only atoms representing definitions need to implement them. 2) Remove definitionTentative, definitionWeak, mergeDuplicates, and autoHide. Replace with merge and interposable attributes. 3) Make all methods on Atom be virtual so that future object file readers can lazily generated attributes
llvm-svn: 147903
2012-01-11 01:06:19 +00:00
Nick Kledzik bfedfc171d add initial support for coalescing by content (c-strings) with test case
llvm-svn: 147799
2012-01-09 20:18:15 +00:00
Nick Kledzik 7735a7d1a0 Support more Atom attributes. Add more test cases to lld-core
llvm-svn: 147571
2012-01-04 23:58:17 +00:00
Nick Kledzik 38eec3d931 Add more merging/coalescing test cases and make core linking work for them
llvm-svn: 147130
2011-12-22 02:38:01 +00:00
Nick Kledzik f46669c828 Cleaned up Atom attribues some more. Added lots of doxygen comments
llvm-svn: 147105
2011-12-21 23:29:36 +00:00
Nick Kledzik f96d0ade79 Refactor and comment Atom attributes. Replace combine() with internalName() and mergeDuplicates()
llvm-svn: 146958
2011-12-20 02:18:44 +00:00
Nick Kledzik 070e1a7643 add parseObjectTextFileOrSTDIN() utility
llvm-svn: 146931
2011-12-20 00:07:11 +00:00
Michael J. Spencer 773a8fb6ab Initial commit. Code by Nick Kledzik. Cleanups and build system by me.
llvm-svn: 146844
2011-12-18 08:27:59 +00:00