Commit Graph

27 Commits

Author SHA1 Message Date
Eugene Leviant ff23d3e741 [ELF] Convert PltSection to input section
Differential revision: https://reviews.llvm.org/D26842

llvm-svn: 287346
2016-11-18 14:35:03 +00:00
Eugene Leviant b96e809c7f [ELF] Convert HashTableSection to input section
Differential revision: https://reviews.llvm.org/D26834

llvm-svn: 287326
2016-11-18 09:06:47 +00:00
Eugene Leviant be809a7125 [ELF] Convert GnuHashTableSection to input section
Differential revision: https://reviews.llvm.org/D26792

llvm-svn: 287322
2016-11-18 06:44:18 +00:00
Simon Atanasyan b8bfec686f [ELF][MIPS] Remove 'mips' word from MipsGotSection fields and methods names. NFC
Also add new comments with MIPS GOT description.

llvm-svn: 287264
2016-11-17 21:49:14 +00:00
Eugene Leviant 9230db94b7 [ELF] Convert SymbolTableSection to input section
Differential revision: https://reviews.llvm.org/D26740

llvm-svn: 287216
2016-11-17 09:16:34 +00:00
Rui Ueyama 729ac793a2 Rename a function so that that starts with a lowercase letter.
llvm-svn: 287202
2016-11-17 04:10:09 +00:00
Simon Atanasyan 725dc14bb2 [ELF][MIPS] Add MipsGotSection to handle MIPS GOT
MIPS GOT handling is very different from other targets so it is better
to keep the code in the separatre section class MipsGotSection. This
patch introduces the new section and moves all MIPS specific code from
GotSection to the new class. I did not rename fields and methods in the
MipsGotSection class to reduce the diff and plan to do that by the
separate commit.

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

llvm-svn: 287150
2016-11-16 21:01:02 +00:00
Eugene Leviant a96d9027a3 [ELF] Convert RelocationSection to input section
Differential revision: https://reviews.llvm.org/D26669

llvm-svn: 287092
2016-11-16 10:02:27 +00:00
Eugene Leviant 6380ce2212 [ELF] Convert DynamicSection to input section.
This patch introduces the following changes:
- DynamicSection now inherits InputSection<ELFT> and was moved
  to SyntheticSections.h/.cpp.
- Link and Entsize fields of DynamicSection are propagated to 
  its output section
- In<ELFT>::SyntheticSections was removed.
- Finalization of synthetic sections was removed from 
  OutputSection<ELFT>::finalize. Now finalizeSyntheticSections is
  used instead.

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

llvm-svn: 286950
2016-11-15 12:26:55 +00:00
Eugene Leviant 22eb026886 [ELF] Convert StringTableSection to input section
Differential revision: https://reviews.llvm.org/D26549

llvm-svn: 286799
2016-11-14 09:16:00 +00:00
Eugene Leviant 17afb64d4f [ELF] Set 'Live = true' in SyntheticSection ctor. NFC.
llvm-svn: 286588
2016-11-11 13:03:58 +00:00
Eugene Leviant ad4439e802 [ELF] Convert .got section to input section
Differential revision: https://reviews.llvm.org/D26498

llvm-svn: 286580
2016-11-11 11:33:32 +00:00
Rui Ueyama 3da3f06dd3 Include version string into ".comment" section.
Summary:
This patch adds a ".comment" section to an output. The comment
section contains the linker's version string. You can now
find out whether a binary is created by LLD or not using objdump
command like this.

  $ objdump -s -j .comment foo

  foo:     file format elf64-x86-64

  Contents of section .comment:
   0000 00474343 3a202855 62756e74 7520342e  .GCC: (Ubuntu 4.
   0010 382e342d 32756275 6e747531 7e31342e  8.4-2ubuntu1~14.
   ...
   00c0 766d2f74 72756e6b 20323835 38343629  vm/trunk 285846)
   00d0 004c696e 6b65723a 204c4c44 20342e30  .Linker: LLD 4.0
   00e0 2e302028 7472756e 6b203238 36343036  .0 (trunk 286406
   00f0 2900                                 ).

Compilers emits .comment section as well, so the output contains
both compiler and linker information.

Alternative considered:

I first tried to add a SHT_NOTE section because GNU gold does that.
A NOTE section starts with a header which contains content type.
It turned out that ld.gold sets type NT_GNU_GOLD_VERSION to their
NOTE section. So the NOTE type is only for GNU gold (surprise!)

Next, I tried to create ".linker-version" section. However, it seems
that reusing the existing ".comment" section is better because 1)
other tools already know about .comment section and is able to strip
it and 2) the result contans not only linker info but also compiler
info.

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

llvm-svn: 286496
2016-11-10 20:20:37 +00:00
Rafael Espindola 0e876cfb2e Replace duplicated '16' with a named constant.
Thanks to Michael Spencer for the suggestion.

llvm-svn: 286462
2016-11-10 15:41:34 +00:00
Eugene Leviant 12e8a92acd [ELF] Make SyntheticSection::writeTo pure virtual. NFC.
llvm-svn: 286445
2016-11-10 12:50:59 +00:00
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
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
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 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 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 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
Rui Ueyama e288eef322 Convert Out::InterpSection to In::InterpSection.
Differential Revision: https://reviews.llvm.org/D26225

llvm-svn: 285851
2016-11-02 18:58:44 +00:00
Rui Ueyama 6dc7fcbec4 Create SyntheticSections.cpp.
We are going to have many more classes for linker-synthesized
input sections, so it's worth to be added to a separate file
than to the file for regular input sections.

llvm-svn: 285740
2016-11-01 20:28:21 +00:00