Commit Graph

10574 Commits

Author SHA1 Message Date
George Rimar 7bf92be676 [ELF] - Allow LLD to produce file symbols.
This is for PR36716 and
this enables emitting STT_FILE symbols.

Output size affect is minor:
lld binary size changes from 52,883,408 to 52,949,400
clang binary size changes from 83,136,456 to 83,219,600

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

llvm-svn: 329557
2018-04-09 11:43:52 +00:00
Aaron Smith c3b5515e51 [tests] Fix format-binary-non-ascii.s to work with Python 3 on Windows
Some platforms interpret the pound sign as one character. Platforms that use 
Python 2.x actually interpret it as two characters because in the Python 2.x 
version of lit, the string used for the file name is a byte string and the pound 
sign is two bytes.

Patch by Stella Stamenova!

llvm-svn: 329472
2018-04-07 00:55:26 +00:00
Peter Collingbourne 4902508934 COFF: Process /merge flag as we create output sections.
With this we can merge builtin sections.

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

llvm-svn: 329471
2018-04-07 00:46:55 +00:00
Rafael Espindola b4d3dfefb7 Avoid some temporary allocations.
Some system libraries have a lot of versioned symbols. When linking
scylla this brings the number of malloc calls from 49154 to 37944.

llvm-svn: 329453
2018-04-06 20:53:06 +00:00
Benjamin Kramer d726d04f45 [ELF] Don't write to the source directory in test.
llvm-svn: 329384
2018-04-06 10:05:47 +00:00
Rafael Espindola 3bd98b1031 Change which file we print when a symbol cannot be ordered.
Currently there are a few odd things about the warning about symbols
that cannot be ordered. This patch fixes:

* When there is an undefined symbol that resolves to a shared file, we
  were printing the location of the undefined reference.

* If there are multiple comdats, we were reporting them all.

llvm-svn: 329371
2018-04-06 03:36:19 +00:00
Peter Collingbourne f2c0f39b91 COFF: Create output sections early. NFCI.
With this, all output sections are created in one place. This will make
it simpler to implement merging of builtin sections.

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

llvm-svn: 329370
2018-04-06 03:25:49 +00:00
Rafael Espindola 9b6a65b144 Don't ignore addend when a SHF_MERGE section is dead.
This is similar to r329219, but for the entire section. Like r329219 I
don't expect this to have any real impact, it is just more consistent
and simpler.

llvm-svn: 329367
2018-04-06 01:10:33 +00:00
Rui Ueyama 96ba8befa9 [WebAssembly] Remove StackPointerGlobal member variable from the driver.
Since InputGlobal makes a copy of a given object, we can use a temporary
object allocated on the stack here.

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

llvm-svn: 329337
2018-04-05 19:37:48 +00:00
Rui Ueyama ac95bb1d52 [WebAssembly] Remove another trivial accessor.
Differential Revision: https://reviews.llvm.org/D43725

llvm-svn: 329336
2018-04-05 19:37:31 +00:00
Fangrui Song c43eff6208 [ELF] Add CHECK to test/ELF/undef-start.s
llvm-svn: 329333
2018-04-05 19:20:33 +00:00
Rui Ueyama 4e150c4c88 Make "Size" column in the map file one characters shorter.
Previously, "size" column is 9 characters long which is too long
at least for 32-bit (because at maximum it needs 8 columns). This
patch make it one column shorter than before. That's also a reasonable
default for 64-bit.

llvm-svn: 329317
2018-04-05 17:20:18 +00:00
Rui Ueyama 16a130bc78 Fix column size in the map file.
Size can be narrow, but LMA should be the same width as VMA.

llvm-svn: 329312
2018-04-05 16:45:37 +00:00
Rafael Espindola 5f8e77afb5 Initialize OutputOff to zero.
We have a dedicated Live bit, so we don't need a special value and we
were not accounting for in at least one place.

llvm-svn: 329307
2018-04-05 15:56:04 +00:00
Eugene Leviant 57225ac179 [ELF] Don't add NOLOAD sections to segment
Differential revision: https://reviews.llvm.org/D45264

llvm-svn: 329281
2018-04-05 13:23:59 +00:00
George Rimar f9936e1fc9 [ELF] - Eliminate Target::isPicRel method.
As was mentioned in comments for D45158,
isPicRel's name does not make much sense,
because what this method does is checks if
we need to create the dynamic relocation or not.

Instead of renaming it to something different,
we can 'isPicRel' completely.

We can reuse the getDynRel method.
They are logically very close, getDynRel can just return
R_*_NONE in case no dynamic relocation should be produced
and that would simplify things and avoid functionality
correlation/duplication with 'isPicRel'.

The patch does this change.

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

llvm-svn: 329275
2018-04-05 12:07:20 +00:00
George Rimar e88b76a989 [ELF] - Reveal more information in -Map file about assignments.
Currently, LLD print symbol assignment commands to the map file,
but it does not do that for assignments that are outside of the section
descriptions. Such assignments can affect the layout though.

The patch implements the following:

* Teaches LLD to print symbol assignments outside of section declaration.
* Teaches LLD to print PROVIDE/HIDDEN/PROVIDE hidden commands.

In case when symbol is not provided, nothing will be printed.

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

llvm-svn: 329272
2018-04-05 11:25:58 +00:00
George Rimar ee01b1d390 [ELF] - Print LMA in a -Map file.
Currently, LLD prints VA, but not LMA in a map file.
It seems can be useful to print both to reveal layout
details and patch implements it.

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

llvm-svn: 329271
2018-04-05 10:51:06 +00:00
Rafael Espindola 7bd45502fe Initialize OffsetMap earlier.
Now that getSectionPiece uses OffsetMap, it is advantageous to
initialize it earlier.

llvm-svn: 329242
2018-04-05 00:01:57 +00:00
Rui Ueyama 5a9529f4a2 Do not show alignment 0 because that is equivalent to 1.
Differential Revision: https://reviews.llvm.org/D44991

llvm-svn: 329233
2018-04-04 21:25:37 +00:00
Peter Collingbourne 05f0bae318 COFF: Sort non-discardable sections at the same time as other sections. NFC.
This makes the sort order a little clearer.

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

llvm-svn: 329227
2018-04-04 20:30:37 +00:00
Hans Wennborg 2a6943ca14 Fix the test some more after r329221
llvm-svn: 329224
2018-04-04 19:55:45 +00:00
Hans Wennborg e6cf0a3d9f Fix test after r329221
It seems I accidentally overspecified the section size in my previous
commit, whereas it was previously carefully left out.

llvm-svn: 329222
2018-04-04 19:36:27 +00:00
Hans Wennborg 9a9fc78744 COFF: Layout sections in the same order as link.exe
One place where this seems to matter is to make sure the .rsrc section comes
after .text. The Win32 UpdateResource() function can change the contents of
.rsrc. It will move the sections that come after, but if .text gets moved, the
entry point header will not get updated and the executable breaks. This was
found by a test in Chromium.

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

llvm-svn: 329221
2018-04-04 19:15:55 +00:00
Rafael Espindola f7c5a10e55 Don't ignore addend in getOffset.
We were ignoring the addend if the piece was dead. I don't expect this
to make a difference in any real world situations, but it is simpler
anyway.

llvm-svn: 329219
2018-04-04 19:13:30 +00:00
George Rimar 785a79133b [ELF] - X86_64: Use white list for relocations checked by isPicRel.
isPicRel is used to check if we want to create the dynamic relocations.
Not all of the dynamic relocations we create are passing through this
check, but those that are, probably better be whitelisted.

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

llvm-svn: 329203
2018-04-04 15:21:21 +00:00
George Rimar 55d717805b [ELF] - Use early return. NFC.
llvm-svn: 329180
2018-04-04 12:36:21 +00:00
George Rimar 4d2740c6ed [ELF] - Cleanup. NFCI.
Rename field, added comments.

This is splitted from the D44894. 
Requested to be committed as independent cleanup.

llvm-svn: 329162
2018-04-04 09:39:05 +00:00
George Rimar 94e148c830 [ELF] - Rename checkSectionOverlap() to checkSections(). NFC.
Renaming was requested in post commit review for D43820.

llvm-svn: 329159
2018-04-04 09:24:31 +00:00
George Rimar 4f98e0bc03 [ELF] - Revert r329060 "Simplify createFiles. NFCI."
Was requested during post commit review.

llvm-svn: 329155
2018-04-04 08:13:28 +00:00
Rui Ueyama 20b3423715 Fix manifestinput-error.test on Windows 10.
Patch by Alexandre Ganea.

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

llvm-svn: 329132
2018-04-03 23:12:28 +00:00
Rui Ueyama 90f13ed0e4 Return early. NFC.
llvm-svn: 329126
2018-04-03 22:39:12 +00:00
Rui Ueyama d35b839c3f Merge two `if`s and add a few blank lines. NFC.
llvm-svn: 329125
2018-04-03 22:39:04 +00:00
Rui Ueyama 265dbe4666 Inline a small test file.
llvm-svn: 329124
2018-04-03 22:38:56 +00:00
Rafael Espindola 6cd7af51e1 Inline initOffsetMap.
In the lld perf builder r328686 had a negative impact in
stalled-cycles-frontend. Somehow that stat is not showing on my
machine, but the attached patch shows an improvement on cache-misses,
which is probably a reasonable proxy.

My working theory is that given a large input the pieces vector is out
of cache by the time initOffsetMap runs.

Both finalizeContents implementation have a convenient location for
initializing the OffsetMap, so this seems the best solution.

llvm-svn: 329117
2018-04-03 21:38:18 +00:00
Rui Ueyama c6bf37d56d Instead of using std::copy, clear the vector first and add new elements. NFC.
Differential Revision: https://reviews.llvm.org/D45227

llvm-svn: 329107
2018-04-03 20:08:45 +00:00
Peter Collingbourne bca630bd61 ELF: Use a vector of pairs to sort sections ordered using --symbol-ordering-file.
This improved performance by 0.5-1% linking Chromium for Android.

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

llvm-svn: 329106
2018-04-03 19:45:10 +00:00
Rui Ueyama 61b67abe89 Fix buildbots.
r329092 broke buildbots.

llvm-svn: 329103
2018-04-03 18:59:31 +00:00
Rafael Espindola 03d7a1bc46 Add a test for an issue fixed in r329092.
We were setting IsUsedInRegularObj in lazy symbols only used from IR.

llvm-svn: 329101
2018-04-03 18:35:46 +00:00
Rui Ueyama cc013f62c1 Make fetchIfLazy only fetch an object file. NFC.
Previously, fetchIfLazy did more than the name says. Now, setting
to UsedInRegularObj is moved to another function.

llvm-svn: 329092
2018-04-03 18:01:18 +00:00
Bob Haarman 8c63bafdd3 [lld] fix data race in ELF/ICF.cpp
Summary:
r328610 fixed a data race in the COFF linker. This change makes a
similar fix to the ELF linker.

Reviewers: ruiu, pcc, rnk

Reviewed By: ruiu

Subscribers: emaste, llvm-commits, arichardson

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

llvm-svn: 329088
2018-04-03 17:27:39 +00:00
George Rimar 1ef746ba21 [ELF] - Eliminate Lazy class.
Patch removes Lazy class which
is just an excessive layer.

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

llvm-svn: 329086
2018-04-03 17:16:52 +00:00
George Rimar 1fc9f39bd5 [ELF] - Check that output sections fit in address space.
Added checks to test that we do not produce
output where VA of sections overruns the address
space available.

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

llvm-svn: 329063
2018-04-03 12:39:28 +00:00
George Rimar 8fcd04b786 [ELF] - Fix the comment. NFC.
llvm-svn: 329062
2018-04-03 12:28:53 +00:00
George Rimar bc1d58a6b1 [ELF] - Relax checks for R_386_8/R_386_16 relocations.
This fixes PR36927.

The issue is next. Imagine we have -Ttext 0x7c and code below.

.code16
.global _start
_start:
movb $_start+0x83,%ah

So we have R_386_8 relocation and _start at 0x7C.
Addend is 0x83 == 131. We will sign extend it to 0xffffffffffffff83.

Now, 0xffffffffffffff83 + 0x7c gives us 0xFFFFFFFFFFFFFFFF.
Techically 0x83 + 0x7c == 0xFF, we do not exceed 1 byte value, but
currently LLD errors out, because we use checkUInt<8>.

Let's try to use checkInt<8> now and the following code to see if it can help (no):
main.s:
.byte foo

input.s:
.globl foo
.hidden foo
foo = 0xff

Here, foo is 0xFF. And addend is 0x0. Final value is 0x00000000000000FF.
Again, it fits one byte well, but with checkInt<8>,
we would error out it, so we can't use it.

What we want to do is to check that the result fits 1 byte well.
Patch changes the check to checkIntUInt to fix the issue.

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

llvm-svn: 329061
2018-04-03 12:19:04 +00:00
George Rimar bfbeecdc5d [ELF] - Simplify createFiles. NFCI.
Groups paired options together.

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

llvm-svn: 329060
2018-04-03 12:06:29 +00:00
George Rimar c6735c23d2 [ELF] - X86_64: don't allow 8/16 bit dynamic relocations.
Having 8/16 bits dynamic relocations is incorrect.

Both gold and bfd (built from latest sources) disallow
that too.

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

llvm-svn: 329059
2018-04-03 11:58:23 +00:00
George Rimar 624e163f53 [ELF] - Remove dead declaration. NFC.
llvm-svn: 329058
2018-04-03 10:40:39 +00:00
Rafael Espindola 95f8d303ab Use OffsetMap in getSectionPiece.
OffsetMap maps to a SectionPiece index, but we were not taking
advantage of that in getSectionPiece.

With this patch both getOffset and getSectionPiece use OffsetMap and
the binary search is moved to findSectionPiece.

llvm-svn: 329044
2018-04-03 04:06:14 +00:00
Rui Ueyama 24a47201fd Merge LazyArchive::fetch() and ArchiveFile::getMember(). NFC.
They are to pull out an object file for a symbol, but for a historical
reason the code is written in two separate functions. This patch
merges them.

llvm-svn: 329039
2018-04-03 02:06:57 +00:00
Rui Ueyama 7d6131a898 Inline two trivial functions that are called only once. NFC.
llvm-svn: 329034
2018-04-02 23:58:50 +00:00
Rafael Espindola 3e7d6fc2c6 Define TrapInst for ppc64.
This is nice for testing since it is the first TrapInst whose bytes
are not all the same.

llvm-svn: 329014
2018-04-02 21:11:13 +00:00
Sean Fertile 227d4399bf [PPC64] Minor changes for Plt relocations.
The Plt relative relocations are R_PPC64_JMP_SLOT in the V2 abi, and we only
reserve 2 double words instead of 3 at the start of the array of PLT entries for
lazy linking.

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

llvm-svn: 329006
2018-04-02 19:47:21 +00:00
Sean Fertile af95629deb [PPC64] Write plt stubs for ElfV2 abi
Add the default version of a plt stub for the V2 Elf abi.

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

llvm-svn: 329004
2018-04-02 19:17:12 +00:00
Sean Fertile 6bf3fe124e [PPC] Add a test for toc-relative access on ppc64le.
Adds a simple test for accessing a local global variable in the ElfV2 abi.
Checks that the toc base used is the expected offset from the .TOC. symbol,
and that the offsets for the global are calculated relative to the toc base.

llvm-svn: 328982
2018-04-02 15:42:07 +00:00
George Rimar 5b31b6f12d [ELF] - cref.s: check that we print symbols from archives. NFCI.
This is consistent with bfd and we already supported it,
though test did not contain the explicit check.

llvm-svn: 328967
2018-04-02 11:28:44 +00:00
Fangrui Song ef61d85fc9 [ELF] Simplify read32. NFC
llvm-svn: 328908
2018-03-30 23:13:00 +00:00
Peter Collingbourne 5ea6d50af1 ELF: Place ordered sections in the middle of the unordered section list on targets with limited-range branches.
It generally does not matter much where we place sections ordered
by --symbol-ordering-file relative to other sections. But if the
ordered sections are hot (which is the case already for some users
of --symbol-ordering-file, and is increasingly more likely to be
the case once profile-guided section layout lands) and the target
has limited-range branches, it is beneficial to place the ordered
sections in the middle of the output section in order to decrease
the likelihood that a range extension thunk will be required to call
a hot function from a cold function or vice versa.

That is what this patch does. After D44966 it reduces the size of
Chromium for Android's .text section by 60KB.

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

llvm-svn: 328905
2018-03-30 21:36:54 +00:00
Rumeet Dhindsa 7588a8e89d Initialize Elf Header to zero to ensure that bytes not assigned any value later on are initialized properly.
Differential Revision: https://reviews.llvm.org/D44986

llvm-svn: 328902
2018-03-30 20:49:34 +00:00
Peter Collingbourne 5e3ee94562 ELF: Try to create last thunk section at ThunkSectionSpacing bytes before the end.
Now that we have the ability to create short thunks, it is beneficial
for thunk sections to be surrounded by ThunkSectionSpacing bytes
of code on both sides in order to increase the likelihood that the
distance from the thunk to the target will be sufficiently small to
allow for the creation of a short thunk. This is currently the case
for most thunks that we create, except for the last one, which could,
depending on the size of the output section, potentially appear near
the end and therefore have a relatively small amount of code after it.

This patch moves the last thunk section to ThunkSectionSpacing bytes
before the end of the output section, as long as the section is larger
than 2*ThunkSectionSpacing bytes. It reduces the size of Chromium
for Android's .text section by 32KB.

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

llvm-svn: 328889
2018-03-30 18:32:24 +00:00
Rui Ueyama 5f8c3e85aa Fix Windows buildbots.
llvm-svn: 328882
2018-03-30 17:49:51 +00:00
Rui Ueyama 5aab635e10 Improve error message for an unknown --plugin-opt.
Before:

  $ ld.lld --plugin-opt=-foo
  ld.lld: --Unknown command line argument '-abc'

After:

  $ ld.lld --plugin-opt=-foo
  ld.lld: --plugin-opt: ld.lld --Unknown command line argument '-abc'

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

llvm-svn: 328880
2018-03-30 17:22:44 +00:00
Nico Weber a764379458 [lld-link] Add comment explaining that /FIXED behavior is correct despite contradicting MSDN.
Also add a test for /FIXED.
https://reviews.llvm.org/D45087

llvm-svn: 328879
2018-03-30 17:17:04 +00:00
Nico Weber 0945ad6643 [lld-link] Let /PROFILE imply /OPT:REF /OPT:NOICF /INCREMENTAL:NO /FIXED:NO
/FIXED:NO is always the default, so that part needs no work.

Also test the interaction of /ORDER: with /INCREMENTAL.

https://reviews.llvm.org/D45091

llvm-svn: 328877
2018-03-30 17:14:50 +00:00
Rui Ueyama 0961218c10 [WebAssembly] Error if both --export-table and --import-table are specified.
Differential Revision: https://reviews.llvm.org/D45001

llvm-svn: 328873
2018-03-30 16:06:14 +00:00
Nico Weber 8ee3b06f82 Simplify test more.
llvm-svn: 328863
2018-03-30 13:48:11 +00:00
Nico Weber 4fb8799f74 Simplify test.
As of rL215127, FileCheck has an -allow-empty flag,
so this could be used instead of writing a dummy line.
But it looks like the log is never empty now, so not
even that is needed.

llvm-svn: 328862
2018-03-30 13:44:15 +00:00
Rui Ueyama 5a67a6ec4a Re-implement --just-symbols as a regular object file.
I tried a few different designs to find a way to implement it without
too much hassle and settled down with this. Unlike before, object files
given as arguments for --just-symbols are handled as object files, with
an exception that their section tables are handled as if they were all
null.

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

llvm-svn: 328852
2018-03-30 01:15:36 +00:00
Peter Collingbourne 4653b0021e Add missing REQUIRES: arm.
llvm-svn: 328847
2018-03-29 23:08:32 +00:00
Peter Collingbourne 015d30c807 ELF: Add support for short thunks on ARM.
A short thunk uses a direct branch (b or b.w) instruction, and is used
when the target has the same thumbness as the thunk and is within
direct branch range (32MB for ARM, 16MB for Thumb-2). Reduces the
size of Chromium for Android's .text section by around 160KB.

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

llvm-svn: 328846
2018-03-29 22:43:52 +00:00
Rui Ueyama f001ead490 Do not use template for check{Int,UInt,IntUInt,Alignment}.
Template is just unnecessary.

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

llvm-svn: 328843
2018-03-29 22:40:52 +00:00
Peter Collingbourne c5391ce51e ELF: Allow thunks to change size. NFCI.
Differential Revision: https://reviews.llvm.org/D44962

llvm-svn: 328841
2018-03-29 22:32:13 +00:00
Rui Ueyama 5706161806 Simplify. NFC.
llvm-svn: 328817
2018-03-29 19:51:53 +00:00
Zachary Turner 3203e27473 [MSF] Default to FPM2, and always mark FPM pages allocated.
There are two FPMs in an MSF file, the idea being that for
incremental updates you can write to the alternate one and then
atomically swap them on commit.  LLVM defaulted to using FPM1
on the first commit, but this differs from Microsoft's behavior
which is to default to using FPM2 on the first commit.  To
eliminate some byte-level file differences, this patch changes
LLVM's default to also be FPM2.

Additionally, LLVM was trying to be "smart" about marking FPM
pages allocated.  In addition to marking every page belonging
to the alternate FPM as unallocated, LLVM also marked pages at
the end of the main FPM which were not needed as unallocated.

In order to match the behavior of Microsoft-generated PDBs, we
now always mark every FPM block as allocated, regardless of
whether it is in the main FPM or the alt FPM, and regardless of
whether or not it describes blocks which are actually in the file.

This has the side benefit of simplifying our code.

llvm-svn: 328812
2018-03-29 18:34:15 +00:00
Rui Ueyama fb1db6ae43 Exit early from a loop. NFC.
This patch fixes an issue introduced in r328810 which made the algorithm
to always run the loop O(n^2) times, though we can break early. The
output remains the same.

llvm-svn: 328811
2018-03-29 18:29:12 +00:00
Rui Ueyama 09fcdbc131 Refactor Writer::checkNoOverlappingSections. NFC.
This patch rewrites the function to remove lambda callbacks and use
of template. The algorithm is the same as before.

llvm-svn: 328810
2018-03-29 18:24:01 +00:00
George Rimar 7d0be9aff9 [ELF] - Add missing check calls to the tests.
llvm-svn: 328794
2018-03-29 14:57:29 +00:00
Andrew Ng fe1d346f99 [ELF] Fix X86 & X86_64 PLT retpoline padding
The PLT retpoline support for X86 and X86_64 did not include the padding
when writing the header and entries. This issue was revealed when linker
scripts were used, as this disables the built-in behaviour of filling
the last page of executable segments with trap instructions. This
particular behaviour was hiding the missing padding.

Added retpoline tests with linker scripts.

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

llvm-svn: 328777
2018-03-29 14:03:01 +00:00
Rui Ueyama efe9af9f07 Rename NonLocal -> Global.
NonLocal is technically more accurate, but we already use the term
"Global" to specify the non-local part of the symbol table, and
Local <-> Global is easier to digest.

llvm-svn: 328740
2018-03-28 22:55:40 +00:00
Rui Ueyama 6a1ca2627a Move code so that the code matches with a comment. NFC.
llvm-svn: 328739
2018-03-28 22:47:53 +00:00
Rafael Espindola c8f774b393 Strip @VER suffices from the LTO output.
This fixes pr36623.

The problem is that we have to parse versions out of names before LTO
so that LTO can use that information.

When we get the LTO produced .o files, we replace the previous symbols
with the LTO produced ones, but they still have @ in their names.

We could just trim the name directly, but calling parseSymbolVersion
to do it is simpler.

llvm-svn: 328738
2018-03-28 22:45:39 +00:00
Rui Ueyama 2ce7401505 Unloop a for-loop so that we can comment on each symbol. NFC.
llvm-svn: 328736
2018-03-28 22:09:40 +00:00
Rui Ueyama e86c7956d6 Merge nested "if"s. NFC.
llvm-svn: 328733
2018-03-28 21:53:10 +00:00
Peter Collingbourne cebab4a639 ELF: Make required Thunk methods pure virtual and remove an unused argument. NFC.
Also make certain Thunk methods non-const as this will be required for
an upcoming change.

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

llvm-svn: 328732
2018-03-28 21:33:31 +00:00
Nicholas Wilson fc90b30dc2 [WebAssembly] Name Config members after commandline argument. NFC
This addresses a late review comment from D44427/rLLD328643

llvm-svn: 328700
2018-03-28 12:53:29 +00:00
George Rimar fd11560f6e [ELF] - Linkerscript: support MIN and MAX.
Sample for the OVERLAY command from the spec 
(https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/4/html/Using_ld_the_GNU_Linker/sections.html)
uses MAX command that we do not support currently:

. = 0x1000 + MAX (SIZEOF (.text0), SIZEOF (.text1));

This patch implements support for MIN and MAX.

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

llvm-svn: 328696
2018-03-28 11:33:00 +00:00
Rafael Espindola 816127ea17 Initialize OffsetMap in a known location.
This is a small optimization and avoids the need to use call_once.

llvm-svn: 328686
2018-03-28 03:20:18 +00:00
Rafael Espindola 92eba0e14a Define a trivial method inline.
llvm-svn: 328685
2018-03-28 03:14:11 +00:00
Rafael Espindola 5a7ca96e2d Store live offsets as uint32_t.
We don't support input merge sections larger than 4gb, so these can be
uint32_t.

llvm-svn: 328684
2018-03-28 02:32:31 +00:00
Fangrui Song 2458863e28 [ELF] Fix offsets in comment of tls-got.s
llvm-svn: 328679
2018-03-28 00:03:21 +00:00
Nicholas Wilson 874eedd779 [WebAssembly] Add export/import for function pointer table
This enables callback-style programming where the JavaScript environment
can call back into the Wasm environment using a function pointer
received from the module.

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

llvm-svn: 328643
2018-03-27 17:38:51 +00:00
Rafael Espindola 35aad41c1b Force SHF_MERGE optimizations with -r.
Some tools (dwarfdump for example) get confused by the current -O0 -r
output since it has multiple copies of .debug_str.

We cannot just merge sections with the same name as they can have
different sh_entsize.

We could have duplicated logic for merging sections based on name and
sh_entsize, but it seems better to just use the existing logic by
enabling optimizations.

llvm-svn: 328640
2018-03-27 17:09:23 +00:00
Rafael Espindola 22458ea7aa Add a passing test.
I noticed that we were not testing this while working on another patch.

llvm-svn: 328631
2018-03-27 16:10:01 +00:00
Andrew Ng ae0a7735b9 [ELF] Disable ICF for synthetic sections
The Data member of synthetic section's is not valid and empty. The Data
member is required to be valid by ICF as it is used by ICF to determine
the equality of section contents. Therefore, exclude synthetic sections
from ICF.

Fixes bug PR36910.

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

llvm-svn: 328624
2018-03-27 14:10:07 +00:00
Bob Haarman 3ddeb33e00 [lld] fix data race in ICF.cpp
Summary: Fixes PR36823.

Reviewers: ruiu, pcc, rnk

Reviewed By: ruiu

Subscribers: llvm-commits

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

llvm-svn: 328610
2018-03-27 06:08:35 +00:00
Rui Ueyama bc0d3b4e0f Remove extraneous local variable. NFC.
llvm-svn: 328605
2018-03-27 02:53:08 +00:00
Rui Ueyama b3e2f74517 Update comments.
llvm-svn: 328604
2018-03-27 02:52:58 +00:00
David Blaikie ddcd856147 Fix for header rename in LLVM
llvm-svn: 328594
2018-03-26 23:43:29 +00:00
Rui Ueyama b391288af7 Refactor SharedFile::parseRest. NFC.
SharedFile::parseRest function grew organically and got a bit hard to
understand. This patch refactor it. This patch also adds comments.

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

llvm-svn: 328579
2018-03-26 19:57:38 +00:00
Rafael Espindola 9c2c938521 Reduce code duplication a bit.
Thanks to George Rimar for pointing it out.

llvm-svn: 328571
2018-03-26 18:55:33 +00:00