Commit Graph

1722 Commits

Author SHA1 Message Date
Rui Ueyama b13cda8f3e Call normalize() in the common driver.
Previously only GNU driver calls InputGraph::normalize, but its
functionality is not and should not be limited to GNU ld. Other
driver should be able to use it.

Currently only linker scripts use the feature, so this change
won't change the existing behavior.

llvm-svn: 208266
2014-05-07 23:33:48 +00:00
Rui Ueyama 9967f49a3c Simplify InputGraph::getNextFile. No functionality change.
llvm-svn: 208256
2014-05-07 22:27:12 +00:00
Rui Ueyama d6a0604180 Trivial simplification
llvm-svn: 208145
2014-05-07 00:04:48 +00:00
Rui Ueyama 3608609339 Expand nested input elements.
Previously only the toplevel elements were expanded by expandElements().
Now we recursively call getReplacements() to expand input elements even
if they are in, say, in a group.

llvm-svn: 208144
2014-05-06 23:52:19 +00:00
Rui Ueyama 0d85dbfce0 Tests no longer uses getNextInputElement, so make it private.
llvm-svn: 208124
2014-05-06 19:32:54 +00:00
Rui Ueyama 2fa41d1817 Add a test for notifyProgress().
llvm-svn: 208123
2014-05-06 19:26:21 +00:00
Rui Ueyama aa30ccffa8 Remove unused variable.
llvm-svn: 208121
2014-05-06 19:11:39 +00:00
Rui Ueyama b51711b356 Fix copypaste error.
llvm-svn: 208120
2014-05-06 19:05:14 +00:00
Rui Ueyama b12dcb6095 s/My/Test/ as these classes are for tests.
llvm-svn: 208119
2014-05-06 19:01:56 +00:00
Rui Ueyama fd5c70d0ec Make the test even more readable.
llvm-svn: 208118
2014-05-06 18:58:24 +00:00
Rui Ueyama 48a1727e6f Simplify unit test code.
llvm-svn: 208116
2014-05-06 18:41:12 +00:00
Rui Ueyama d976941704 Remove meaningless return value in test.
llvm-svn: 208112
2014-05-06 18:27:37 +00:00
Rui Ueyama 27169ce309 Replace copypasta with function calls to make tests intelligible.
llvm-svn: 208111
2014-05-06 18:24:27 +00:00
Rui Ueyama 1fe682cf37 Don't return value rather than always returning true.
addInputElement() never fails, and no one checks its return value
except tests. Let's simplify the signature.

llvm-svn: 208109
2014-05-06 17:33:14 +00:00
Rui Ueyama b340f0117c Remove a method that no one is using.
llvm-svn: 208101
2014-05-06 16:22:04 +00:00
Rui Ueyama 91dd26b9a0 Remove repeated access specifier.
llvm-svn: 208028
2014-05-06 01:10:01 +00:00
Rui Ueyama f129f72e43 Remove unused field.
llvm-svn: 208024
2014-05-06 01:00:43 +00:00
Rui Ueyama 1b1ec8bfe2 Fix spelling.
llvm-svn: 208022
2014-05-06 00:51:52 +00:00
Rui Ueyama 8620d933f4 Remove operator[] that was used only in tests.
llvm-svn: 208020
2014-05-06 00:50:46 +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
Simon Atanasyan b9b9e36187 [ELF] Use a range based access to the ELFFile's sections collection.
No functional changes.

llvm-svn: 207953
2014-05-05 07:17:40 +00:00
Simon Atanasyan e22ca46681 [Mips] R_MIPS_GPREL32 relocation support.
llvm-svn: 207949
2014-05-05 05:56:06 +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 3872d0ae26 Remove "virtual" and add "override".
llvm-svn: 207885
2014-05-02 23:44:02 +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
Rui Ueyama 20822d924e Return the expression result directly.
llvm-svn: 207878
2014-05-02 22:32:01 +00:00
Rui Ueyama 19173a39d3 Don't use "auto" where the actual type is not obvious.
llvm-svn: 207875
2014-05-02 21:48:01 +00:00
Rui Ueyama 0e363b75a4 [PECOFF] Support =internalName syntax in .def file.
Export definitions in a module definition file is as follows:

  exportedname[=internalname] [@ordinal [NONAME]] [PRIVATE] [DATA]

Previously we did not support =internalname, so users couldn't export
symbols from a DLL with a different name.

llvm-svn: 207827
2014-05-02 03:43:51 +00:00
Rui Ueyama db2fc6d756 Make the variable scope narrower. No functionality change.
llvm-svn: 207821
2014-05-02 01:17:40 +00:00
Rui Ueyama efa8076c29 [PECOFF] Drop stdcall's atsign suffix only.
You can omit @number suffix when specifying /export option,
but you can do that only for stdcall functions.

llvm-svn: 207809
2014-05-01 22:44:42 +00:00
Rui Ueyama a665de8f38 Fix FreeBSD buildbots.
llvm-svn: 207802
2014-05-01 22:13:39 +00:00
Joerg Sonnenberger c8f36d2d55 Sort.
llvm-svn: 207798
2014-05-01 21:40:22 +00:00
Rui Ueyama da808c39e6 [PECOFF] Do not call addDllExport to mutate export descriptors.
This is more efficient than before.

llvm-svn: 207791
2014-05-01 20:40:30 +00:00
Simon Atanasyan ffc1c6af49 [ELF] Fix the file look up algorithm used in the linker script GROUP command.
In general the linker scripts's GROUP command works like a pair
of command line options --start-group/--end-group. But there is
a difference in the files look up algorithm.

The --start-group/--end-group commands use a trivial approach:
a) If the path has '-l' prefix, add 'lib' prefix and '.a'/'.so'
   suffix and search the path through library search directories.
b) Otherwise, use the path 'as-is'.

The GROUP command implements more compicated approach:
a) If the path has '-l' prefix, add 'lib' prefix and '.a'/'.so'
   suffix and search the path through library search directories.
b) If the path does not have '-l' prefix, and sysroot is configured,
   and the path starts with the / character, and the script being
   processed is located inside the sysroot, search the path under
   the sysroot. Otherwise, try to open the path in the current
   directory. If it is not found, search through library search
   directories.

https://www.sourceware.org/binutils/docs-2.24/ld/File-Commands.html

The patch reviewed by Shankar Easwaran, Rui Ueyama.

llvm-svn: 207769
2014-05-01 16:22:08 +00:00
Simon Atanasyan 4e480de0cc [Mips] Follow-up to the r207744. Replace numerical e_flags constants by their names.
llvm-svn: 207745
2014-05-01 11:10:47 +00:00
Simon Atanasyan f01ce1990c [Mips] Follow-up to the r207687. Add the test to check MIPS specific
arguments of the -m command line option.

llvm-svn: 207738
2014-05-01 05:12:32 +00:00
Rui Ueyama e1452c22e5 [PECOFF] Fix exported symbol name.
When creating a .lib file, we should strip the leading underscore,
but should not strip stdcall atsign suffix. Otherwise produced .lib
files cannot be linked.

llvm-svn: 207729
2014-05-01 00:23:07 +00:00
Rui Ueyama e18ed4e16b [PECOFF] Add a test for lib.exe subcommand.
Previously the input file for the lib.exe command would be removed
as soon as the command exits, so we couldn't write a test to check
the file contents are correct.

This patch adds /lldmoduledeffile: option to retain a copy of the
temporary file at the given file path, so that you can see the file
if you want.

llvm-svn: 207727
2014-05-01 00:06:56 +00:00
Simon Atanasyan a64f34b759 [Driver] Check type of InputElement before request a error message. If the
element is a FileNode, request error description. If the element is Group,
print hard coded error message. We need to implement a better diagnostics
here but even current solution is better than a segmentation fault output.

llvm-svn: 207691
2014-04-30 19:04:01 +00:00
Simon Atanasyan db8a4a8578 [ELF] Return result from the function ASAP.
No functional changes.

llvm-svn: 207690
2014-04-30 19:03:56 +00:00
Simon Atanasyan a54d34d4ad [ELF] Factor out the code builds a library search directory path
into the separate function.

No functional changes.

llvm-svn: 207689
2014-04-30 19:03:51 +00:00
Simon Atanasyan 76d8d36c3c [Driver] Remove the redundant cast.
No functional changes.

llvm-svn: 207688
2014-04-30 19:03:45 +00:00
Simon Atanasyan e33f2add5d [Mips] Recognize MIPS emulation name 'elf32ltsmip'.
llvm-svn: 207687
2014-04-30 19:03:40 +00:00
Rui Ueyama 680210fe7d [PECOFF] Fix priority of locally imported symbols.
Linker should create _imp_ symbols for local use only when such
symbols cannot be resolved in any other way. If it overrides real
imported symbols, such symbols remain virtually unresolved without
error, causing odd issues. I observed that a program linked with
LLD entered an infinite loop before reaching main() because of
this issue.

This patch moves the virtual file creating _imp_ symbols to the
very end of the input file list. Previously, the file is at the end
of the library file group. Linker might revisit the group many times,
so it was not really at the end of the input file list.

llvm-svn: 207605
2014-04-30 03:31:46 +00:00
Simon Atanasyan 105d6abe50 [Mips] Re-order include headers.
llvm-svn: 207495
2014-04-29 05:46:02 +00:00
Simon Atanasyan 8de2b8fb81 [Mips] Implement emitting of R_MIPS_REL32 relocations:
1. Re-implement PLT entries and dynamic relocations emitting to keep PLT
and relocations table in a consistent state.

2. Initialize st_value and st_other fields for dynamic symbols table
entry if this entry corresponds to an external function which address is
taken in a non-PIC executable. In that case the st_value field holds an
address of the function's PLT entry. Also set STO_MIPS_PLT bit in the
st_other field.

llvm-svn: 207494
2014-04-29 05:21:54 +00:00
Simon Atanasyan f293b3e52c [Mips] 80 column.
llvm-svn: 207493
2014-04-29 05:21:36 +00:00
Rui Ueyama 7f4162bd06 [PECOFF] /export accepts non-decorated symbols.
You usually have to specify the exact name of a symbol to export it,
but for stdcall functions you can omit the @numbers suffix.

llvm-svn: 207491
2014-04-29 02:50:35 +00:00
Rui Ueyama 72d57ab32e [PECOFF] Fix _imp_ implicit symbols.
Implicit symbol for local use implemented in r207141 was not fully
compatible with MSVC link.exe. In r207141, I implemented the feature
in such way that implicit symbols are defined only when they are
exported with /EXPORT option.

After that I found that implicit symbols are defined not only for
dllexported symbols but for all defined symbols. Actually _imp_
implicit symbols have no relationship with the dllexport feature. You
could add _imp_ to any symbol to get a pointer to the symbol, whether
the symbol is dllexported or not.  It looks pretty weird to me but
that's what we want if link.exe behaves that way.

Here is a bit about the implementation: Creating all implicit symbols
beforehand is going to be a huge waste of resource. This feature is
rarely used, and MSVC link.exe even prints out a warning message when
it finds this feature is being used. So we create implicit symbols
on demand. There is an archive file that creates implicit symbols when
they are needed.

llvm-svn: 207476
2014-04-29 00:32:00 +00:00
Simon Atanasyan 0804610e9f [Mips] Rename the test case.
llvm-svn: 207437
2014-04-28 19:34:46 +00:00