Commit Graph

829 Commits

Author SHA1 Message Date
Rui Ueyama 12c0d773fe Try to fix test failure on buildbot.
llvm-svn: 191259
2013-09-24 00:47:31 +00:00
Rui Ueyama f062c84aac [PECOFF] Add /nodefaultlib command line option.
llvm-svn: 191254
2013-09-24 00:16:27 +00:00
Rui Ueyama 456740c740 [PECOFF] Do not allow space to separate command line option and its value.
We used to support both Windows and Unix style command line options. In Windows
style, an option and its value are separated by ":" (colon). In Unix, separator
is a space. Accepting both styles were convenient, but we can no longer allow
Unix style because I found that can be ambiguous.

For example, /nodefaultlib option takes an optional argument. In Windows style
it's going to be something like "/nodefaultlib:foo". There's no ambiguity what
"foo" means. However, if the option is "/nodefaultlib foo", "foo" can be
interpreted either an optional argument for "/nodefaultlib" or an input file
"foo.obj". We should just stop accepting the non-standard command line style.

llvm-svn: 191247
2013-09-23 23:51:31 +00:00
Rui Ueyama 5c59ab7f3d [PECOFF] Ignore /delay and /delayload options.
These options are to enable DLL delay loading. If enabled, DLL is loaded
at run time by a helper routine when a function in the DLL is actually called
for the first time, instead of making the Windows loader to load all DLLs at
startup time. This should shorten startup delay if an executable have many
imported symbols.

The linker needs to create a "delayed import table" and link delayimp.lib in
which helper functions are defined to support the feature.

For now, we just ignore the options, so that the linker does not complain when
it sees these options. We want to support them in the future.

llvm-svn: 191232
2013-09-23 22:41:46 +00:00
Rui Ueyama 85c821fcb2 [PECOFF] Add more tests for /machine, /base, /stack, /heap and /align.
llvm-svn: 191229
2013-09-23 21:52:01 +00:00
Rui Ueyama 1e0b586f33 [PECOFF] Add comments to unit tests and reorder them if necessary.
llvm-svn: 191228
2013-09-23 21:38:03 +00:00
Rui Ueyama c0a6d43c92 [PECOFF] Add /allowisolation command line option.
llvm-svn: 191227
2013-09-23 21:22:01 +00:00
Rui Ueyama 6907b3df70 [PECOFF] Add /allowbind command line option.
llvm-svn: 191224
2013-09-23 20:44:20 +00:00
Rui Ueyama 2721aa4065 [PECOFF] Simplify WinLinkOptions.td.
llvm-svn: 191223
2013-09-23 20:36:39 +00:00
Rui Ueyama 724d75b2c8 [PECOFF] Add one more test for r191218
llvm-svn: 191221
2013-09-23 20:24:12 +00:00
Ron Ofir b7d3e6b76b [lld][PECOFF] Fix data directory entry RVA of base relocations section
Summary:
This patch changes WriterPECOFF to actually write down the address instead of ignoring it.
Also, it changes the order of adding the BaseReloc chunk as otherwise the address wasn't set yet.

I think a better way of doing it would be to change DataDirectoryAtom to create a Reference
instead of using a number, and to change IdataPass accordingly, but I'm not sure how to do that.

Reviewers: ruiu

Reviewed By: ruiu

CC: llvm-commits

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

llvm-svn: 191220
2013-09-23 20:21:24 +00:00
Rui Ueyama 9149181ae9 [PECOFF] Add /align command line option.
llvm-svn: 191218
2013-09-23 19:52:35 +00:00
Rui Ueyama c532036aeb Whitespace and extra parentheses.
llvm-svn: 191217
2013-09-23 19:52:31 +00:00
Ron Ofir 41dcb848a7 [lld][PECOFF] Calculate SizeOfHeaders field instead of using a hard-coded value
Summary: This patch changes WritePECOFF to calculate the value of the SizeOfHeaders PE header field instead of just using 512.

Reviewers: rui314, ruiu

Reviewed By: ruiu

CC: llvm-commits, ruiu

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

llvm-svn: 191212
2013-09-23 18:08:51 +00:00
Shankar Easwaran e67ba51791 [lld][ELF] Remove invalid comment
llvm-svn: 191207
2013-09-23 16:28:23 +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
Ron Ofir 5403eaecc0 [lld][WinLink] Fix typo
llvm-svn: 191079
2013-09-20 09:13:53 +00:00
Rui Ueyama eb0434e9ae Fallback to the default stringize function to show some meaningful error message.
GNU LD driver only understood no_such_file_or_directory error and was showing
just "Unknown Error" for any other type of error. With this patch, the driver
now prints file name and error message string by default.

llvm-svn: 191070
2013-09-20 03:32:27 +00:00
Rui Ueyama 391ffdf70e Generalize errStr() function so that it can handle any type of errors.
llvm-svn: 191069
2013-09-20 03:18:58 +00:00
Rui Ueyama 508939428d [PECOFF] Ignore /incremental option.
/incremental is an option to enable incremental linking. We will eventually
want to implement the feature for better performance, but in the meantime,
we want to just ignore the option so that the linker does not output unknown
option error when it sees /incremental option.

llvm-svn: 191063
2013-09-20 00:55:37 +00:00
Rui Ueyama 9f5f635e7f Remove extraneous parentheses.
llvm-svn: 191061
2013-09-20 00:33:34 +00:00
Rui Ueyama 388fbd8f31 Handle "file not found" error in the superclass's errStr().
If a subclass does not override the member function, the superclass's method
takes care of string conversion of "file not found" error. This is a reasonable
default behavior. Subclasses are still able to override to customize error
messages.

llvm-svn: 191058
2013-09-20 00:32:40 +00:00
Rui Ueyama dc30cdb18c Fix file comments and include guard
llvm-svn: 191054
2013-09-19 23:34:20 +00:00
Rui Ueyama 91a95a590a [PECOFF] Ignore /errorReport command line option.
/errorReport is a command line option to let the linker to report internal
linker error information to Microsoft. For LLD that option doesn't make any
sense, so it just ignores the option.

llvm-svn: 191044
2013-09-19 22:19:40 +00:00
Shankar Easwaran a2f881e275 [lld][ELF][Hexagon] Cleanup unused data
Cleanup structure members that are not being used.

Also clang-format it.

llvm-svn: 191038
2013-09-19 21:27:21 +00:00
Shankar Easwaran 70fefd515a [lld][ELF] Group command line options for better usage
llvm-svn: 191033
2013-09-19 20:07:06 +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 1bddfc1fc7 [PECOFF][Driver] Support /version command line option
llvm-svn: 190986
2013-09-19 02:37:36 +00:00
Rui Ueyama 0397239f6b [PECOFF] Fix the order of the Import Table entries.
Test is coming after submitting http://llvm-reviews.chandlerc.com/D1719.

llvm-svn: 190983
2013-09-19 01:39:53 +00:00
Rui Ueyama ccd21fe418 [PECOFF] Fix base relocation block alignment
Base relocation block should be aligned on a 32-bit boundary. While the PECOFF
spec mentions only aligning the blocks, and not padding them, link.exe seems
to add an extra IMAGE_REL_I386_ABSOLUTE entry (just a zeroed WORD) in order to
pad the blocks.

Patch by Ron Ofir.

llvm-svn: 190951
2013-09-18 18:36:39 +00:00
Rui Ueyama 0742ce9cf7 [PECOFF] Make helper functions private.
llvm-svn: 190949
2013-09-18 18:15:18 +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
Shankar Easwaran 063b75013f [lld][ELF] Assign sectionChoice properly to ELF atoms
This sets the sectionChoice property for DefinedAtoms. The output section name
is derived by the property of the atom. This also decreases native file size.

Adds a test.

llvm-svn: 190840
2013-09-17 02:56:22 +00:00
Rui Ueyama e0e28d059b [PECOFF] Take into account all sections when setting size fields in the PE header
This patch changes lld to go through all sections while calculating the size
for SizeOfCode, SizeOfInitializedData and SizeOfUninitializedData fields in the
PE header, instead of using only a small set of hard-coded sections.

This only really changes SizeOfInitializedData which didn't include .reloc
section before this patch.

Patch by Ron Ofir.

llvm-svn: 190799
2013-09-16 17:39:26 +00:00
Rui Ueyama d5e4f637ef [PECOFF] Add DISCARDABLE characteristic to .reloc section
This patch sets the IMAGE_SCN_MEM_DISCARDABLE characteristic to the base
relocations section in order to match MS PECOFF specification.

Patch by Ron Ofir.

llvm-svn: 190798
2013-09-16 17:35:13 +00:00
Rui Ueyama 3ee2bf6a62 [PECOFF] Use a dummy file as an "input file" for Idata atoms.
llvm-svn: 190772
2013-09-15 22:33:15 +00:00
Joerg Sonnenberger 97fc3834b8 Output soname.
llvm-svn: 190758
2013-09-14 19:53:51 +00:00
Joerg Sonnenberger 9e5676c5c8 If .bss doesn't exist, set _end/end based on .data.
llvm-svn: 190753
2013-09-14 13:59:49 +00:00
Joerg Sonnenberger 4263d8b35d Add _end symbol for dynamic libraries. At least brk/sbrk in libc on
NetBSD need it.

llvm-svn: 190752
2013-09-14 13:45:29 +00:00
Rui Ueyama ec9bb694bd Revert "[PECOFF] Allocate storage for .drective in the reader ..."
This reverts r189881 because that patch caused dangling StringRefs.

llvm-svn: 190725
2013-09-13 21:14:18 +00:00
Rui Ueyama a8ce9529c3 [PECOFF] Fix alignment bug.
There was a bug that if a section has an alignment requirement and there are
multiple symbols at offset 0 in the section, only the last atom at offset 0
would be aligned properly. That bug would move only the last symbol to an
alignment boundary, leaving other symbols unaligned, although they should be at
the same location. That caused a mysterious SEGV error of the resultant
executable.

With this patch, we manage all symbols at the same location properly, rather
than keeping the last one.

llvm-svn: 190724
2013-09-13 21:11:00 +00:00
Rui Ueyama 1ea9b97707 [PECOFF] Fix atom default alignment.
Alignment(1) does not mean that the atom should be aligned on a 1 byte
boundary but on a 2^1 boundary. So, atoms without any specific alignment
requirements should have Alignment(0).

llvm-svn: 190723
2013-09-13 20:53:11 +00:00
Joerg Sonnenberger 3c6b056186 Add test case for the not-yet implemented copy relocations.
llvm-svn: 190714
2013-09-13 18:32:34 +00:00
Shankar Easwaran 2a92c18ba3 [lld][ELF] Handle multiple weak symbols
This handles multiple weak symbols which appear back to back. This fix is needed
which otherwise will lead to symbols getting initialized to arbitrary values.

There was a constructor/destructor test that really triggered this to be fixed
on X86_64.

Adds a test.

llvm-svn: 190658
2013-09-13 04:25:44 +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
Shankar Easwaran 4ff19b3c87 [lld][LinkingContext] Fix doxygen comment
llvm-svn: 190629
2013-09-12 20:00:15 +00:00
Rui Ueyama 55b3cc5054 Do not prepend "_" to external symbols if non-i386.
llvm-svn: 190628
2013-09-12 19:52:59 +00:00
Rui Ueyama 98896ed1b5 [PECOFF] Add a field for machine type to PECOFFLinkingContext.
So that we can determine what the target architecture is. Adding this
field does not mean that we are going to support non-i386 architectures
soon; there are many things to do to support them, and I'm focusing on
i386 now. But this is the first step toward multi architecture support.

llvm-svn: 190627
2013-09-12 19:46:53 +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
Shankar Easwaran 2206d5ad7d [lld][tests] Fix buildbot failure on darwin
llvm-svn: 190619
2013-09-12 18:10:20 +00:00