Commit Graph

829 Commits

Author SHA1 Message Date
Shankar Easwaran d6d1b52937 [lld][LayoutPass] change comments to reflect the sort order
llvm-svn: 190612
2013-09-12 15:59:34 +00:00
Shankar Easwaran 2734d79d94 [lld][ELF] Fix vaddr of the first section
The first section in the output was not aligned to the alignment of the section.

llvm-svn: 190610
2013-09-12 15:43:17 +00:00
Shankar Easwaran df2dd193ee [lld][ELF] Fix the readonly section order.
This associates rodata and sections which just have the SHF_ALLOC flag
to be set to typeConstant.

llvm-svn: 190609
2013-09-12 15:43:13 +00:00
Shankar Easwaran f1b341c80e [lld][LayoutPass] Order the atoms that are in the same chain
We need to order atoms that exist in the same chain. This is to make sure that
the command line order is preserved when we emit the atoms to the output file.

Credits: BigCheese for finding the bug.

Adds a test which otherwise would fail.

llvm-svn: 190608
2013-09-12 15:43:09 +00:00
Rui Ueyama 81d0d29639 Remove hard-coded leading underscore from entry symbol.
llvm-svn: 190586
2013-09-12 05:09:01 +00:00
Rui Ueyama 1e6af15388 Do not hard code the leading underscore.
Mangling scheme varies on platform, and prepending an underscore is valid only
on 32-bit x86. Added a method to mangle name to PECOFFLinkingContext and use
it to avoid hard coding mangled names.

llvm-svn: 190585
2013-09-12 04:42:31 +00:00
Rui Ueyama 2ff9d70ac4 Run clang-format.
llvm-svn: 190554
2013-09-11 22:21:42 +00:00
Nick Kledzik 2e0fb1ef5b Allow darwin driver to use -help when no input files are specified.
Patch by Joe Ranieri

llvm-svn: 190453
2013-09-10 23:57:41 +00:00
Nick Kledzik e773e327d3 Support darwin linker options:
-current_version, -compatibility_version, and -install_name.

Patch by Joe Ranieri

llvm-svn: 190452
2013-09-10 23:55:14 +00:00
Nick Kledzik e850d9dedd Remove PackedVersion from MachOLinkingContext and replace with uint32_t
and a parsePackedVersion() utility.

Patch by Joe Ranieri

llvm-svn: 190451
2013-09-10 23:46:57 +00:00
Rui Ueyama 5c532370d5 Use llvm::sys::Process::GetEnv() instead of ::getenv().
Process::GetEnv() uses GetEnvironmentVariableW, which is a Windows API
to get an environment variable and is preferable over getenv().

llvm-svn: 190431
2013-09-10 20:33:21 +00:00
Rui Ueyama fff7f8a4ed Rename GnuLDInputGraph.h -> GnuLdInputGraph.h for consistency with other files.
llvm-svn: 190332
2013-09-09 19:30:23 +00:00
Rui Ueyama 67de33b075 Use _isWholeArchive to silence -Wunused-private-field warning.
llvm-svn: 190329
2013-09-09 19:21:06 +00:00
Joerg Sonnenberger ecd1d9bc1d Handle _DYNAMIC correctly in the x86_64 backend.
llvm-svn: 190302
2013-09-09 12:19:28 +00:00
Joerg Sonnenberger 23f8d43e5c Recognize -Bstatic as alias for -static, clang uses it.
llvm-svn: 190301
2013-09-09 11:48:43 +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 a82566b86e Update documentation.
llvm-svn: 190255
2013-09-07 18:01:39 +00:00
Joerg Sonnenberger 0310e734c3 Run clang-format.
llvm-svn: 190254
2013-09-07 17:56:23 +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
Rui Ueyama 0826dd23c6 [PECOFF] Don't add RVAs to base relocations table.
Patch by Ron Ofir.

llvm-svn: 190210
2013-09-06 22:09:02 +00:00
Rui Ueyama 97086a5a4f [PECOFF] Fix section alignment bug in ReaderCOFF.
Patch by Ron Ofir.

llvm-svn: 190198
2013-09-06 20:08:57 +00:00
Rui Ueyama 02c46bdb75 [PECOFF] Add /machine command line option.
llvm-svn: 190121
2013-09-06 04:17:07 +00:00
Rui Ueyama 030fe96ff3 [PECOFF] Align section contents as specified by the object file's section header.
llvm-svn: 190120
2013-09-06 04:06:58 +00:00
Rui Ueyama 822cb2e44b Remove extraneous parentheses.
llvm-svn: 190119
2013-09-06 03:16:28 +00:00
Rui Ueyama 01951de462 Return early to simplify.
llvm-svn: 190117
2013-09-06 01:48:19 +00:00
Rui Ueyama f48b8fc06d Remove unused identifiers.
llvm-svn: 190095
2013-09-05 20:21:24 +00:00
Shankar Easwaran fc09df0fe9 [lld][cleanup] remove unused ReaderFunc to avoid confusion.
llvm-svn: 190031
2013-09-05 04:27:17 +00:00
Shankar Easwaran 176e7fd05f [lld][ELF] Change the order of the writable note section
Writable note sections if they exist should not appear before text
they belong in the data segment

llvm-svn: 190024
2013-09-05 01:50:21 +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
Rui Ueyama 959aebf873 [PECOFF] Ignore options starting with -?
The compiler is allowed to add a linker option starting with -?<name> to
.drectve section. If the linker can interpret -<name>, it's processed as if
there's no question mark there. If not, such option is silently ignored.

This is a COFF's feature to allow the compiler to emit new linker options
while keeping compatibility with older linkers.

llvm-svn: 189897
2013-09-04 00:51:51 +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 8ccf6da056 Rename *Options.td -> <flavor>Options.td.
Before this patch, name of driver implementation is not consistent with its
option table file. Specifically, LDOptions has a different prefix than
GnuLdDriver.

This patch renames option files, so that the option files have the same prefix
as the corresponding driver files.

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

llvm-svn: 189895
2013-09-04 00:24:35 +00:00
Shankar Easwaran 2eaa47a008 [lld][Driver] remove return after llvm_unreachable
llvm-svn: 189891
2013-09-04 00:05:46 +00:00
Joerg Sonnenberger 37f50b7ccc Start a TODO list for the ELF backend.
llvm-svn: 189890
2013-09-04 00:00:48 +00:00
Shankar Easwaran 3df170b84e [lld][Driver] The driver was creating linker inputs twice
Also add a llvm_unreachable call so that the linker will trip on unhandled
inputElement types.

llvm-svn: 189887
2013-09-03 23:52:05 +00:00
Joerg Sonnenberger 33a6d3aaed Recognize -rpath-link option and add arguments to ELFLinkingContext.
llvm-svn: 189883
2013-09-03 23:28:51 +00:00
Rui Ueyama 225f090bdb [PECOFF] Allocate storage for .drective in the reader to avoid multiple calls of allocateString()
llvm-svn: 189881
2013-09-03 23:14:30 +00:00
Rui Ueyama 530488c92a [PECOFF] Verify parameter in validateImpl() not in the driver.
llvm-svn: 189877
2013-09-03 22:57:00 +00:00
Shankar Easwaran d3b3d71a3a [lld] Remove bitfield for boolean members
llvm-svn: 189876
2013-09-03 22:55:45 +00:00
Shankar Easwaran c16b5e76fc [lld][ELF][X86_64] Test alignment for init_array/fini_array sections
llvm-svn: 189875
2013-09-03 22:46:54 +00:00
Shankar Easwaran 84c643fcc3 [lld][ELF][X86_64] Fix alignment of init_array/fini_array sections
llvm-svn: 189874
2013-09-03 22:44:46 +00:00
Shankar Easwaran 2b9d1025d6 [lld][ELF] Change the InitFini atom type from Stub to Data
llvm-svn: 189873
2013-09-03 22:44:44 +00:00
Shankar Easwaran fce7952b79 [lld][ELF][Hexagon] add Init/Fini option for hexagon
This adds init/fini support for Hexagon.

llvm-svn: 189872
2013-09-03 22:44:42 +00:00
Shankar Easwaran 2f5d64062b [lld] handle the case of errors from createLinkerInput
This changes the interface of createLinkerInput to use ErrorOr, so that
errors from the linker can be captured.

Also adds a convenience function for error strings to be returned from
file nodes.

llvm-svn: 189871
2013-09-03 22:44:37 +00:00
Rui Ueyama b4170b17d4 [PECOFF] Fix fixme by making PECOFFLinkingContext non-const.
llvm-svn: 189865
2013-09-03 22:33:56 +00:00
Joerg Sonnenberger a82839593c Finish -rpath implementation to actually create the DT_RPATH entries.
llvm-svn: 189847
2013-09-03 20:45:09 +00:00
Joerg Sonnenberger 840d3daf01 Add support for --sysroot.
llvm-svn: 189826
2013-09-03 16:29:02 +00:00
Joerg Sonnenberger 7d5aed5ce5 A weak reference to a symbol that is only weakly referenced in
dependencies should remain weak, not get promoted to undef or dropped.

llvm-svn: 189793
2013-09-03 12:06:33 +00:00
Rui Ueyama 0e70a16419 Do not add entry symbol to the dead strip list. Partially revert r189776.
llvm-svn: 189778
2013-09-03 03:34:33 +00:00
Rui Ueyama 8cdbf525a9 Cosmetic changes
Differential Revision: http://llvm-reviews.chandlerc.com/D1577

llvm-svn: 189777
2013-09-03 01:25:21 +00:00
Rui Ueyama 504962f714 Partially revert r189718 to add entry symbol to dead strip root.
Also added a test to verify that entry symbol is not stripped even if
dead stripping is enabled.

llvm-svn: 189776
2013-09-03 01:00:01 +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
Rui Ueyama 900a501bdd Add llc to check-lld deps. We use the command in lit.cfg.
llvm-svn: 189774
2013-09-02 23:26:00 +00:00
Joerg Sonnenberger 37b08114bd Typo.
llvm-svn: 189771
2013-09-02 19:36:15 +00:00
Joerg Sonnenberger 2bbc79039d Recognize -Bshareable as alias for -shared.
llvm-svn: 189752
2013-09-02 09:34:35 +00:00
Joerg Sonnenberger 354a2f30d4 ReaderWriter depends on Passes.
llvm-svn: 189751
2013-09-02 09:33:06 +00:00
Shankar Easwaran df4f12bb65 [lld][test] organize test directory. No change in functionality
* Renames few tests which had extension objtxt to test
* created core directory that contains all the core tests

llvm-svn: 189720
2013-08-31 05:59:52 +00:00
Shankar Easwaran 2e4424b431 [lld][ELF] Add Init/Fini support
This creates .init_array/.fini_array section for X86_64 ELF
targets and executes init/fini functions specified by the
-init/-fini options respectively.

llvm-svn: 189719
2013-08-31 05:27:44 +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 981892ab71 Fix build breakage
llvm-svn: 189714
2013-08-31 01:36:36 +00:00
Rui Ueyama e45f37d238 Remove #include, for we don't need the definitions of these classes.
llvm-svn: 189713
2013-08-31 01:28:45 +00:00
Rui Ueyama 51991fed70 Remove dead code.
llvm-svn: 189708
2013-08-30 23:53:06 +00:00
Rui Ueyama 5b41201066 [PECOFF] Add /force:unresolved command line option as a synonym of /force.
llvm-svn: 189614
2013-08-29 21:46:47 +00:00
Rui Ueyama d4b9d068f0 [PECOFF] Fix bug that section grouping may lay out atoms in a wrong order.
We added layout edges to the head atoms in grouped sections. That was wrong,
because the head atom needs to be followed by the other atoms in the *same*
section, not by the other section contents. With this patch, layout edges are
added from tail atom, which is the last atom in a section, to head atom.

llvm-svn: 189573
2013-08-29 07:46:23 +00:00
Rui Ueyama 79e8215f96 [PECOFF] Fix bug that atom size was sometimes wrong.
Because of a bug, the last atom of each section contained a garbage at the
end of its data. In most cases the garbage is harmless but it could have cause
SEGV.

llvm-svn: 189572
2013-08-29 07:34:58 +00:00
Rui Ueyama 5a383d10ac [PECOFF] Add helper functions for debugging
llvm-svn: 189570
2013-08-29 07:17:47 +00:00
Rui Ueyama 67283bc22f [PECOFF] Do not create undefined atom for common symbol.
We were creating undefined atoms for common symbols by mistake. That did not
lead to a link failure, for undefined atoms would be resolved by common symbols
in the same file, but that's a waste of resource.

llvm-svn: 189534
2013-08-28 23:16:04 +00:00
Rui Ueyama 184a4b83d8 [PECOFF] Do not scan the symbol table twice but instead cache aux symbols.
We scanned the symbol table twice; first to gather all regular symbols, and
second to process aux symbols. That's a bit inefficient and complicated. We
can instead cache aux symbols in the first pass, to eliminate the need of the
second pass.

llvm-svn: 189525
2013-08-28 22:27:05 +00:00
Rui Ueyama 9d52a94cd1 [PECOFF] Make command line options case insensitive to match link.exe's behavior.
llvm-svn: 189505
2013-08-28 20:27:41 +00:00
Rui Ueyama c4d793f2ad Remove an option starting an uppercase character so that the test does not depends on sort order.
llvm-svn: 189423
2013-08-28 00:01:57 +00:00
Rui Ueyama b5292e6295 Modify test to adopt r189416.
r189416 changed the order of command line options shown in help message,
so the test needs adjusting.

llvm-svn: 189417
2013-08-27 23:48:49 +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
Rui Ueyama 488d41e6ef [PECOFF] Add the entry symbol and /include symbols to dead strip root set.
Differential Revision: http://llvm-reviews.chandlerc.com/D1527

llvm-svn: 189318
2013-08-27 05:15:20 +00:00
Rui Ueyama 8a5cbadff9 Fix use of temporary strings.
llvm-svn: 189310
2013-08-27 04:27:18 +00:00
Rui Ueyama bc839fcd3e [PECOFF] Enable dead-stripping by default to match link.exe behavior.
llvm-svn: 189308
2013-08-27 03:38:18 +00:00
Rui Ueyama 4c3184f3c0 Treat entry point symbol as an undefined atom.
With this patch the entry symbol is treated as an undefined symbol, to force
the resolver to resolve the entry symbol.

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

llvm-svn: 189307
2013-08-27 03:18:11 +00:00
Rui Ueyama 352e7308c0 Rename ti -> ctx.
This should have been done in r187823 when I renamed LinkingContext
from TargetInfo. I missed a few files.

llvm-svn: 189298
2013-08-27 00:04:42 +00:00
Rui Ueyama c7ef7a8dd7 [PECOFF] Add Support for entry point symbol name
Patch by Jesús Serrano García.

llvm-svn: 189267
2013-08-26 19:55:09 +00:00
Shankar Easwaran f1947537a0 [lld][ELF] Cleanup ELF writing, No change in functionality
The cleanup includes :-

* Rename ambiguous Header class to ELFHeader
* Convert Chunk contentype and kind to be a enumerated class
* Remove functions that are not being used, avoids future confusion

llvm-svn: 189209
2013-08-26 03:16:13 +00:00
Shankar Easwaran da7ceb9b58 [lld][ELF] Indent the td file to < 80 columns
llvm-svn: 189207
2013-08-26 01:56:27 +00:00
Shankar Easwaran 0f2a45cac5 [lld][ELF][Cleanup] Create multiclass for variations in options usage
llvm-svn: 189197
2013-08-25 18:05:15 +00:00
Shankar Easwaran be81dd757e [lld][ELF] process fini_array sections
This change processes fini_array section in addition to processing
init_array sections. This also makes functions registered at compile
time for initialization and finalization to be run during execution

llvm-svn: 189196
2013-08-25 18:05:12 +00:00
Saleem Abdulrasool 1089265a1d [PECOFF] support additional subsystem identifiers
This completes the subsystem name parsing to support the identifiers that the
Microsoft link.exe linker supports.  "windows" and "console" are left as the
first items as they are the expected common paths.

Signed-off-by: Saleem Abdulrasool <compnerd@compnerd.org>
llvm-svn: 189181
2013-08-24 20:14:54 +00:00
Rui Ueyama 72165ec8c3 Separates /fixed (no .reloc section) and /dynamicbase (enable ASLR)
in order to match link.exe's behaviour.

Patch by Ron Ofir.

llvm-svn: 189159
2013-08-24 00:39:10 +00:00
Hans Wennborg 2391fddfc7 CMake: Support the LLVM_INSTALL_TOOLCHAIN_ONLY flag
llvm-svn: 189157
2013-08-24 00:24:15 +00:00
Rui Ueyama d07c6f06eb Fixes an additional temporary string use.
Patch by Ron Ofir.

llvm-svn: 189151
2013-08-23 22:06:29 +00:00
Tim Northover 274a023d70 Check for "asserts" rather than "debug" on test
The debug flag being checked for seems to be controlled by whether the
build is asserts/non-asserts rather than debug/non-debug. Mostly these
correlate, but not necessarily.

As far as I can tell with various combinations of debug/assetions this
change makes no difference on autotools builds, but fixes a check-all
failure with CMake.

llvm-svn: 189147
2013-08-23 21:10:37 +00:00
Shankar Easwaran f9fe6250ff [lld][ELF] Dont ignore zero sized sections.
There may be relocations that may be pointing to the section
even if the section sizes are 0. We shouldnot ignore them
for that regard.

llvm-svn: 189139
2013-08-23 20:03:35 +00:00
Shankar Easwaran 78457803bc [lld][ELF][Cleanup] Section associated with the relocation traversed
There is no change in functionality, this uses the defined way to access
the relocation section that belongs to a particular section.

llvm-svn: 189138
2013-08-23 20:03:31 +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
Shankar Easwaran d17ba4bd4d [lld] handle typeZeroFill atoms in ELF/Native/YAML
BSS atoms dont take any file space in the Input file. They are associated
with a contentType(typeZeroFill). Similiar zero fill types also exist which
have the same meaning in terms of occupying file space in the Input.

These atoms have to be handled seperately when writing to the
lld's intermediate file or the lld test infrastructure.

Also adds a test.

llvm-svn: 189136
2013-08-23 20:03:21 +00:00
Hans Wennborg 306db8f3fa CMake: Don't look for llvm-tblgen when building outside LLVM tree
Previously, the CMake build would look for llvm-tblgen to determine
if a directory is an LLVM build or install directory. Since we don't
want to include llvm-tblgen in the install, look for llvm-config instead,
and use that to find llvm-tblgen.

(This is the lld equivalent of Clang r189127.)

llvm-svn: 189128
2013-08-23 18:18:13 +00:00
Shankar Easwaran 89732e1362 [lld][PECOFF] Fix one more reference to a temporary string
llvm-svn: 189035
2013-08-22 17:59:03 +00:00
Shankar Easwaran c48b9594b6 [lld][PECOFF] Fix use of temporary strings
llvm-svn: 189025
2013-08-22 15:37:09 +00:00
Shankar Easwaran ea68a5d636 [lld][unittests] Change assert to llvm_unreachable
llvm-svn: 189023
2013-08-22 15:23:54 +00:00
Shankar Easwaran 1d76b115a3 [lld][test] fix -Wreturn-type error
llvm-svn: 188988
2013-08-22 05:44:08 +00:00
Shankar Easwaran 5677e433d6 fix build failures on platforms that use -Wunused-private-variable for builds
llvm-svn: 188983
2013-08-22 04:24:57 +00:00
Shankar Easwaran b8b42658ea [lld][Driver] Fix the unit test for lld gnu flavor
llvm-svn: 188982
2013-08-22 03:18:01 +00:00
Shankar Easwaran c1ea4572ba [lld][Hexagon] Enable Hexagon sdata sorting test
llvm-svn: 188981
2013-08-22 03:02:17 +00:00
Shankar Easwaran 88d0d44635 [lld] Fix unused private fields for fixing build failure on darwin
llvm-svn: 188978
2013-08-22 01:49:16 +00:00