Commit Graph

7124 Commits

Author SHA1 Message Date
Eugene Leviant 41ca327b5e [ELF] Convert .got.plt section to input section
Differential revision: https://reviews.llvm.org/D26349

llvm-svn: 286443
2016-11-10 09:48:29 +00:00
George Rimar 1a33c0f242 [ELF] - Implemented --symbol-ordering-file option.
Patch allows to pass a symbols file to linker.
LLD will map symbols to sections and sort sections
in output according to symbol ordering file.

That can help to reduce the startup time and/or
amount of pagefaults during startup.

Also, interesting benchmark result was produced by Rafael Espíndola. 
After applying the symbols file for clang he timed compiling 
X86MCTargetDesc.ii to an object file.  

The page faults went from just
56,988 to 56,946 since most faults are not in the binary.
Running time went from 4.403053515 to 4.178112244. 
The speedup seems to be because of better cache
locality.

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

llvm-svn: 286440
2016-11-10 09:05:20 +00:00
Rui Ueyama 35e007515f Add comment and simplify code a bit. NFC.
llvm-svn: 286422
2016-11-10 00:12:28 +00:00
Rui Ueyama 1bdaf3e30c Remove an overloaded function to simplify.
This version of addRegular is almost identical to the other except
it lacked "size" parameter.

llvm-svn: 286416
2016-11-09 23:37:40 +00:00
Rafael Espindola e08e78df6d Make OutputSectionBase a class instead of class template.
The disadvantage is that we use uint64_t instad of uint32_t for some
value in 32 bit files. The advantage is a substantially simpler code,
faster builds and less code duplication.

llvm-svn: 286414
2016-11-09 23:23:45 +00:00
Rui Ueyama 58026af7f0 Simplify parseEmulation. NFC.
llvm-svn: 286406
2016-11-09 22:32:43 +00:00
Rui Ueyama df5d14d6e7 Split OutputSection ctor. NFC.
llvm-svn: 286405
2016-11-09 22:32:42 +00:00
Simon Atanasyan 93214b7018 [ELF][MIPS] Attempt to fix buildbot
llvm-svn: 286401
2016-11-09 21:46:42 +00:00
Simon Atanasyan fa03b0fafa [ELF][MIPS] Convert .MIPS.abiflags section to synthetic input section
Previously, we have both input and output section for .MIPS.abiflags.
Now we have only one class for .MIPS.abiflags, which is MipsAbiFlagsSection.
This class is a synthetic input section.

.MIPS.abiflags sections are handled as regular sections until
the control reaches Writer. Writer then aggregates all sections
whose type is SHT_MIPS_ABIFLAGS to create a single synthesized
input section. The synthesized section is then processed normally
as if it came from an input file.

llvm-svn: 286398
2016-11-09 21:37:06 +00:00
Simon Atanasyan ce02cf0099 [ELF][MIPS] Convert .reginfo and .MIPS.options sections to synthetic input sections
Previously, we have both input and output sections for .reginfo and
.MIPS.options. Now for each such sections we have one synthetic input
sections: MipsReginfoSection and MipsOptionsSection respectively.

Both sections are handled as regular sections until the control reaches
Writer. Writer then aggregates all sections whose type is SHT_MIPS_REGINFO
or SHT_MIPS_OPTIONS to create a single synthesized input section. In that
moment Writer also save GP0 value to the MipsGp0 field of the corresponding
ObjectFile. This value required for R_MIPS_GPREL16 and R_MIPS_GPREL32
relocations calculation.

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

llvm-svn: 286397
2016-11-09 21:36:56 +00:00
Rui Ueyama d43b7e8d10 Disable cpio test on Windows again.
The last fix is unlikely to solve the issue. Reverting it to the
original file.

llvm-svn: 286393
2016-11-09 20:54:01 +00:00
Rui Ueyama 2816452503 Attempt to fix green dragon bot.
llvm-svn: 286392
2016-11-09 20:42:34 +00:00
Rafael Espindola 6ff570a395 Make Discarded a InputSection.
It was quite confusing that it had SectionKind of Regular, but was not
actually a InputSection.

llvm-svn: 286379
2016-11-09 16:55:07 +00:00
George Rimar 470de71177 [ELF] - Add separate form for -R alias.
During link of devel/chrpath (FreeBSD port), found next issue:
/usr/bin/ld: error: unclosed comment in a linker script
/usr/bin/ld: error: line 1: unknown directive: �
/usr/bin/ld: error: ��

Problem was not obvious and the reason was that we did not accept
the separate form of -R. While invocation line contained it:
cc -Wl,-R /usr/local/lib -o prog prog.c

CPIO file produced contained /usr/local/lib file. 
Which looks because of reasons above
contained inside the content of whole lib folder, 
and it then was passed as an input and
proccessed as linker script.

llvm-svn: 286378
2016-11-09 16:38:15 +00:00
Rafael Espindola 77dbe9a405 Add a convenience getObj method. NFC.
llvm-svn: 286370
2016-11-09 14:39:20 +00:00
George Rimar 1feb2f7d93 [ELF] - Enable reproduce-error.s under windows.
Differential revision: https://reviews.llvm.org/D26445

llvm-svn: 286364
2016-11-09 13:55:30 +00:00
Peter Smith 8339bbd759 [ELF] ARM and AArch64 undefined weak reference values
The ARM 32 and 64-bit ABI does not use 0 for undefined weak references
that are used in PC relative relocations. In particular:
- A branch relocation to an undefined weak resolves to the next
  instruction. Effectively making the branch a no-op
- In all other cases the symbol resolves to the place so that S + A - P
  resolves to A.

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

llvm-svn: 286353
2016-11-09 10:22:29 +00:00
George Rimar 25143dfd48 [ELF] - Ignore -stats command line option.
llvm-svn: 286348
2016-11-09 08:59:59 +00:00
Rafael Espindola 04a2e348bb Split Header into individual fields.
This is similar to what was done for InputSection.

With this the various fields are stored in host order and only
converted to target order when writing.

llvm-svn: 286327
2016-11-09 01:42:41 +00:00
Rui Ueyama edc183e437 Simplify getLocation() function.
All tests pass without the first parameter, so I guess we don't need it.

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

llvm-svn: 286287
2016-11-08 20:30:19 +00:00
Rafael Espindola 0811385d24 Store the size the same way as any other OutputSection. NFC.
llvm-svn: 286286
2016-11-08 20:25:44 +00:00
Rui Ueyama 9c5a69d2ac Rename a function to avoid function overloading. NFC.
llvm-svn: 286282
2016-11-08 20:02:23 +00:00
Rafael Espindola 8f9026baff Don't add null and discarded sections to the global list.
Avoids having to skip them multiple times.

llvm-svn: 286261
2016-11-08 18:23:02 +00:00
Eugene Leviant 166c99b37e [ELF] Attempt to fix buildbot (duplicate _gp symbol)
llvm-svn: 286247
2016-11-08 16:44:48 +00:00
Eugene Leviant 825e538559 [ELF] Better error reporting for duplicate symbol
Differential revision: https://reviews.llvm.org/D26397

llvm-svn: 286244
2016-11-08 16:26:32 +00:00
Rafael Espindola 73c3a36b9f Remove dead arguments. NFC.
llvm-svn: 286242
2016-11-08 15:51:00 +00:00
George Rimar 9602637030 [ELF] - Fix mistype. NFC.
Thanks to Malcolm Parsons who pointed on that.

llvm-svn: 286239
2016-11-08 15:26:21 +00:00
Rafael Espindola c0e47fbfb2 Delete the InterpSection class.
We can just use a regular InputSection.

llvm-svn: 286237
2016-11-08 14:56:27 +00:00
Rafael Espindola 1a5411238e Revert "[ELF] Make InputSection<ELFT>::writeTo virtual"
This reverts commit r286100.

This saves 8 bytes of every InputSection.

llvm-svn: 286235
2016-11-08 14:47:16 +00:00
Rafael Espindola 682a5bc2c1 Delete the CommonSection class.
With the current infrastructure it can be just an ordinary
InputSection like the real .bss sections.

llvm-svn: 286234
2016-11-08 14:42:34 +00:00
Eugene Leviant c5079dc3cc [ELF] Test case update (orphan.s)
llvm-svn: 286226
2016-11-08 11:11:23 +00:00
Eugene Leviant bae1c656bb [ELF] Heuristic for placing orphan section
Differential revision: https://reviews.llvm.org/D25325

llvm-svn: 286225
2016-11-08 10:44:48 +00:00
George Rimar d700c357d4 [ELF] - Fixed mistype. NFC.
llvm-svn: 286220
2016-11-08 07:46:52 +00:00
Davide Italiano ba8761bc7f [LTO] Don't leak BitcodeFiles. Found by the asan bot.
llvm-svn: 286194
2016-11-08 01:46:02 +00:00
Davide Italiano 089f0e7488 [ELF] Don't leak the ".data" section. Fixes an asan failure.
llvm-svn: 286193
2016-11-08 01:42:38 +00:00
Davide Italiano e7fd0be1b4 [ELF] Use the SystemV hash in libObject instead of rolling our own.
llvm-svn: 286158
2016-11-07 21:56:56 +00:00
Eugene Leviant 0a8f1fe6f7 [ELF] Make InputSection<ELFT>::writeTo virtual
Differential revision: https://reviews.llvm.org/D26281

llvm-svn: 286100
2016-11-07 09:04:06 +00:00
George Rimar 828787a059 [ELF] - Change argument of computeHash to MutableArrayRef. NFC.
This fixes casting warning and removes the need of that cast at all.

llvm-svn: 286065
2016-11-06 08:39:46 +00:00
George Rimar 5020971ea1 [ELF] - Fix linux BB after r286061.
llvm-svn: 286064
2016-11-06 08:26:53 +00:00
George Rimar 364b59e266 [ELF] - Implemented threaded --build-id computation
Patch switches computing of --build-id hash to tree.

This is the way when input data is splitted by chunks,
hash is computed for each one in threaded/non-threaded way.
At the end hash is conputed for result tree.

With or without -threads the result hash is the same.

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

llvm-svn: 286061
2016-11-06 07:42:55 +00:00
Rui Ueyama 1c7868292c Fix build breakage.
llvm-svn: 286054
2016-11-05 23:14:54 +00:00
Rui Ueyama e8a6102fa9 Rewrite CommonInputSection as a synthetic input section.
A CommonInputSection is a section containing all common symbols.
That was an input section but was abstracted in a different way
than the synthetic input sections because it was written before
the synthetic input section was invented.

This patch rewrites CommonInputSection as a synthetic input section
so that it behaves better with other sections.

llvm-svn: 286053
2016-11-05 23:05:47 +00:00
Simon Atanasyan 9e0297b8bc [ELF][MIPS] N32 ABI support
In short the patch introduces support for linking object file conform
MIPS N32 ABI [1]. This ABI is similar to N64 ABI but uses 32-bit
pointer size.

The most non-trivial requirement of this ABI is one more relocation
packing format. N64 ABI puts multiple relocation type into the single
relocation record. The N32 ABI uses series of successive relocations
with the same offset for this purpose. In this patch, new function
`mergeMipsN32RelTypes` handle this case and "convert" N32 relocation to
the N64 relocation so the rest of the code keep unchanged.

For now, linker does not support series of relocations applied to sections
without SHF_ALLOC bit. Probably later I will add the support or insert
some sort of assert into the `relocateNonAlloc` routine to catch this
case.

[1] ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/MIPS-N32-ABI-Handbook.pdf

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

llvm-svn: 286052
2016-11-05 22:58:01 +00:00
Rui Ueyama 8c6a5aaf15 Create a vector containing all input sections.
Previously, we do this piece of code to iterate over all input sections.

  for (elf::ObjectFile<ELFT> *F : Symtab.getObjectFiles())
    for (InputSectionBase<ELFT> *S : F->getSections())

It turned out that this mechanisms doesn't work well with synthetic
input sections because synthetic input sections don't belong to any
input file.

This patch defines a vector that contains all input sections including
synthetic ones.

llvm-svn: 286051
2016-11-05 22:37:59 +00:00
Eugene Zelenko 22886a2853 Fix some Clang-tidy modernize-use-default and Include What You Use warnings; other minor fixes.
Differential revision: https://reviews.llvm.org/D26320

llvm-svn: 286030
2016-11-05 01:00:56 +00:00
Rui Ueyama 3a6f331d2d Fix buildbot.
llvm-svn: 286028
2016-11-04 23:26:29 +00:00
Rui Ueyama a9ee8d6ecc Don't gc .interp section.
This change fixes a bug that was introduced by r285851.
r285851 converted .interp section as an output section to an input
section. But I forgot to make it a "Live" section, so if -gc-section
is given, it was garbage collected.

llvm-svn: 286025
2016-11-04 22:25:39 +00:00
Rui Ueyama eb943e8031 Revert r285968: Always use parallel_for_each because it falls back to std::for_each.
It turned ou that we actually want to call std::for_each even if
threading is supported. Unless --thread is given, LLD shouldn't use
more than one threads.

llvm-svn: 286004
2016-11-04 18:22:36 +00:00
Rui Ueyama 6294a240dc Fix -Wcast-qual warnings.
llvm-svn: 286001
2016-11-04 17:41:29 +00:00
Eugene Zelenko e568b91510 Fix some Clang-tidy modernize-use-default and Include What You Use warnings; other minor fixes.
Differential revision: https://reviews.llvm.org/D26293

llvm-svn: 286000
2016-11-04 17:39:46 +00:00