Commit Graph

8000 Commits

Author SHA1 Message Date
Rui Ueyama f5fce48679 Handle ":" as a regular token character in linker scripts.
This is an alternative to https://reviews.llvm.org/D30500 to simplify the
version definition parser and allow ":" in symbol names.

Differential Revision: https://reviews.llvm.org/D30722

llvm-svn: 297402
2017-03-09 19:23:00 +00:00
George Rimar 0a7412f00b [ELF] - Implemented -znotext
gold linker manual describes them as:

-z text	Do not permit relocations in read-only segments
-z notext Permit relocations in read-only segments (default)

In LLD default is to not permit them. Patch implements -z notext.

Differential revision: https://reviews.llvm.org/D30530

llvm-svn: 297366
2017-03-09 08:48:34 +00:00
George Rimar 1c74c2f2a8 [ELF] - Do not try to create .eh_frame_hdr for relocatable output.
.eh_frame_hdr is a header constructed for .eh_frame sections.
We do not proccess .eh_frame when doing relocatable output,
so should not try to create .eh_frame_hdr too.
Previous behavior without this patch is segfault.

Fixes PR32118.

Differential revision: https://reviews.llvm.org/D30566

llvm-svn: 297365
2017-03-09 08:45:25 +00:00
Rui Ueyama 7d271ae21d Fix wrong assertion failure.
Previously, if you have foo=bar in a definition file, this assertion
could fire because when symbols are read from file they could be mangled.
It seems that due to historical reasons underscore mangling scheme is
really ad-hoc, and I cannot find a clean way to handle this. I had
to just de-mangle symbols to search again.

llvm-svn: 297357
2017-03-09 04:47:33 +00:00
Rui Ueyama bf84c18cc1 Print an error message instead of an assertion failure.
This assertion is failing on a Chromium builder and I cannot figure out why.
This patch let it print out more info.

llvm-svn: 297353
2017-03-09 01:28:50 +00:00
Rafael Espindola 5616adf655 Remove DefinedSynthetic.
With this we have a single section hierarchy. It is a bit less code,
but the main advantage will be in a future patch being able to handle

foo = symbol_in_obj;

in a linker script. Currently that fails since we try to find the
output section of symbol_in_obj.  With this we should be able to just
return an InputSection from the expression.

llvm-svn: 297313
2017-03-08 22:36:28 +00:00
Rafael Espindola fcd208fdb3 Use uint32_t for alignment in more places, NFC.
llvm-svn: 297305
2017-03-08 19:35:29 +00:00
Rui Ueyama 007c002cb6 Revert r297008: [ELF] - Make Bss and BssRelRo sections to be synthetic (#2).
This reverts commit r297008 because it's reported that that
change broke AArch64 bots.

llvm-svn: 297297
2017-03-08 17:24:24 +00:00
Rafael Espindola 5e434b3f11 Remove unnecessary template.
llvm-svn: 297293
2017-03-08 16:08:36 +00:00
Rafael Espindola e1294091d3 Remove unnecessary template. NFC.
llvm-svn: 297292
2017-03-08 16:03:41 +00:00
Rafael Espindola 35ae65ee2b Rename one of the getOffset methods.
It is sufficiently different in that it returns an offset in the input
file, not the output section.

llvm-svn: 297290
2017-03-08 15:57:17 +00:00
Rafael Espindola 76b6bd355d Remove unnecessary template. NFC.
llvm-svn: 297287
2017-03-08 15:44:30 +00:00
Rafael Espindola c86b2cddc8 Convert a few more uses of uintX_t to uint64_t.
llvm-svn: 297286
2017-03-08 15:34:04 +00:00
Rafael Espindola 9371bab55a Convert a few uses of uintX_t to uint64_t.
llvm-svn: 297282
2017-03-08 15:21:32 +00:00
Rafael Espindola bdd2e3e36c Remove redundant member of InputSectionBase. NFC.
With this InputSectionBase is now 144 bytes.

llvm-svn: 297278
2017-03-08 14:12:52 +00:00
Peter Smith 1ec42d9a76 Finalize content of synthetic sections prior to Thunk Creation
This change moves the calls to finalizeContent() for each synthetic section
before createThunks(). This will allow us to assign addresses prior to
calling createThunks(). As addition of thunks may add to the static
symbol table and may affect the size of the mips got section we introduce a
couple of additional member functions to update these values.
    
Differential revision: https://reviews.llvm.org/D29983

llvm-svn: 297277
2017-03-08 14:06:24 +00:00
Rui Ueyama 9accea6feb Pass archive files to link.exe if they contain at least one native object file.
Some archive files created during chromium build contains both BC
and native files. If that's the case, we want to pass the archive
file to link.exe. Otherwise, the MSVC linker would complain that
there's an unresolved symbol in a given set of files.

I cannot explain why link.exe doesn't complain about the presence
of bitcode files in this case, but it seems link.exe doesn't touch BC.

llvm-svn: 297229
2017-03-07 21:26:10 +00:00
Rui Ueyama e0341db179 Do not pass archive files containing bitcode files to the MSVC Linker.
If /msvclto is specified, we compile bitcode files and pass it to the
MSVC linker, stripping all bitcode files. We haven't stripped archive
files, because I was thinking that the MSVC linker wouldn't touch files
in archive files. When we pass an object file to link.exe, all symbols
have been resolved already, so link.exe shoulnd't need any of the files
in archives.

It turns out that even though link.exe doesn't need to do that, it
seems to try to read each file in all archives. And if there's a non-
COFF file in an archive, it exists with an error message. So we need
to remove archives from the command line too.

llvm-svn: 297191
2017-03-07 19:45:53 +00:00
Rafael Espindola 8bb4087f88 Use 32 bits for alignment.
This is consistent with what we do for input sections.

llvm-svn: 297152
2017-03-07 15:51:09 +00:00
Rafael Espindola c8de15bdda Rename remaining uses of Addralign to Alignment.
llvm-svn: 297146
2017-03-07 15:11:21 +00:00
Rafael Espindola 3770763cda Rename Addralign to Alignment.
It now matches the name used in InputSectionBase.

llvm-svn: 297144
2017-03-07 14:55:52 +00:00
Peter Smith 24fb250cad Fix Mips LA25 Thunks where Caller and Callee in different OS
This change fixes a bug in which the Mips LA25 Thunks are always assigned
to the same Output section as the caller and not the callee as expected.

Differential Revision: https://reviews.llvm.org/D30637

llvm-svn: 297135
2017-03-07 09:45:04 +00:00
Rui Ueyama af6198d96d Remove Config->Rela and define Config->isRela() instead.
llvm-svn: 297108
2017-03-07 00:43:53 +00:00
Rui Ueyama df8eb17d21 Remove Config->Mips64EL and define Config->isMips64EL() instead.
llvm-svn: 297107
2017-03-07 00:43:33 +00:00
Rafael Espindola 2a80e1180e Make Discarded a InputSectionBase.
NFC, just a bit simpler.

llvm-svn: 297087
2017-03-06 22:36:19 +00:00
Rafael Espindola 5c02b741eb Detemplate EhInputSection. NFC.
llvm-svn: 297077
2017-03-06 21:17:18 +00:00
Evgeniy Stepanov 5ac5542544 Fix -Werror build error.
tools/lld/ELF/Symbols.cpp:215:13: error: unused variable 'S'
[-Werror,-Wunused-variable]
  if (auto *S = dyn_cast<SharedSymbol>(this)

llvm-svn: 297063
2017-03-06 20:27:38 +00:00
Rafael Espindola 6119b865ec Detemplate merge (input and synthetic) sections. NFC.
llvm-svn: 297061
2017-03-06 20:23:56 +00:00
Rafael Espindola 77408b067c Convert two uses of uintX_t. NFC.
llvm-svn: 297059
2017-03-06 20:04:47 +00:00
Rafael Espindola 692b2f88d3 Fully precise gc handling of __start and __stop symbols.
This puts us at parity with bfd, which could already gc this case.

I noticed the sections not being gced when linking a modified freebsd
kernel. A section that was not gced and not mentioned in the linker
script would end up breaking the expected layout. Since fixing the gc
is relatively simple and an improvement, that seems better than trying
to hack the orphan placement code.

There are 173 input section in the entire link whose names are valid C
identifiers, so this is probably not too performance critical.

llvm-svn: 297049
2017-03-06 18:48:18 +00:00
Rui Ueyama 967fc1cef4 Fix -Wc++11-narrowing.
llvm-svn: 297012
2017-03-06 15:16:18 +00:00
George Rimar c215a2ac40 [ELF] - Make Bss and BssRelRo sections to be synthetic (#2).
In compare with D30458, this makes Bss/BssRelRo to be pure
synthetic sections.

That removes CopyRelSection class completely, making
Bss/BssRelRo to be just regular synthetics.

SharedSymbols involved in creating copy relocations are
converted to DefinedRegular, what also simplifies things.

Differential revision: https://reviews.llvm.org/D30541

llvm-svn: 297008
2017-03-06 14:37:45 +00:00
Zachary Turner 1e021a162e [Windows] Remove the #include <eh.h> hack.
Prior to MSVC 2015 we had to manually include this header any
time we were going to include <thread> or <future> due to a
bug in MSVC's STL implementation.  This has been fixed in MSVC
for some time now, and we require VS 2015 minimum, so we can
remove this across all subprojects.

llvm-svn: 296906
2017-03-03 20:21:59 +00:00
Zachary Turner d9dc2829ea [Support] Move Stream library from MSF -> Support.
After several smaller patches to get most of the core improvements
finished up, this patch is a straight move and header fixup of
the source.

Differential Revision: https://reviews.llvm.org/D30266

llvm-svn: 296810
2017-03-02 20:52:51 +00:00
Rafael Espindola 066d3d2141 Pass a callback to resolveReloc. NFC.
This is consistent with rest of the file and opens the way for a
relocation keeping multiple sections alive.

llvm-svn: 296788
2017-03-02 19:29:28 +00:00
Rafael Espindola e937a828c4 Simplify test by producing an executable.
llvm-svn: 296786
2017-03-02 19:19:59 +00:00
Rui Ueyama 8139eab3c3 Simplify. NFC.
llvm-svn: 296773
2017-03-02 17:55:29 +00:00
George Rimar 3397948515 [ELF] - Fix version-script-extern-exact.s testcase
Previously it would not catch if exact symbol name
matching would change behavior to pattern matching.

llvm-svn: 296740
2017-03-02 11:03:58 +00:00
Sylvestre Ledru b307a0b949 Improve the documentation. Patch from genewitch. Found on https://github.com/llvm-mirror/lld/pull/5
llvm-svn: 296739
2017-03-02 10:40:24 +00:00
Peter Collingbourne 1fd02112df Address a few nits pointed out by Sean.
llvm-svn: 296728
2017-03-02 02:24:31 +00:00
Peter Collingbourne ab76a19afb LTO: When creating a local cache, create the cache directory if it does not already exist.
Differential Revision: https://reviews.llvm.org/D30519

llvm-svn: 296726
2017-03-02 02:02:38 +00:00
Rafael Espindola 4368bdb270 Make gc a bit more aggressive.
We were not gcing any section whose name was a C identifier. Both gold
and bfd only keep those if they are used.

To avoid having to create the __start/__stop symbols early or doing
string lookups in resolvedReloc, this patch just looks for undefined
symbols __start/__stop to decide if a section is needed or not.

llvm-svn: 296723
2017-03-02 01:50:34 +00:00
Peter Collingbourne 53aa7c131e Add missing test dependency.
llvm-svn: 296703
2017-03-01 23:11:58 +00:00
Peter Collingbourne e02775f068 ELF: Add ThinLTO caching support.
This patch adds an option named --thinlto-cache-dir, which specifies the
path to a directory in which to cache native object files for ThinLTO
incremental builds.

Differential Revision: https://reviews.llvm.org/D30509

llvm-svn: 296702
2017-03-01 23:00:10 +00:00
Rui Ueyama ac2d815a2a Split GdbIndexBuilder class into non-member functions.
That class had three member functions, and all of them are just reader
methods that did not depend on class members, so they can be just non-
member functions.

Probably we should reorganize the functions themselves because their
return types doesn't make much sense to me, but for now I just moved
these functions out of the class.

llvm-svn: 296700
2017-03-01 22:54:50 +00:00
Rui Ueyama aab18c0cfc Remove useless variables and declarations.
llvm-svn: 296695
2017-03-01 22:24:46 +00:00
Rui Ueyama 97d7a74b35 Replace `auto` with its real type.
llvm-svn: 296694
2017-03-01 22:24:25 +00:00
Rui Ueyama e5e320de06 Style fix.
llvm-svn: 296689
2017-03-01 22:03:17 +00:00
Rui Ueyama a4d9a22ba2 Reduce nesting. NFC.
llvm-svn: 296688
2017-03-01 22:02:57 +00:00
Rui Ueyama e02cc60c72 Do not inherit LoadedObjectInfo.
GdbIndexBuilder class inherited LoadedObjectInfo, but that's not necessary.

llvm-svn: 296687
2017-03-01 22:02:37 +00:00