Commit Graph

22 Commits

Author SHA1 Message Date
Rui Ueyama fd03cfd27a Instantiate Interp output section only when needed.
This change simplifies interaction between Writer and the linker script
because we can make needsInterpSection() a file-scope function.

llvm-svn: 276261
2016-07-21 11:01:23 +00:00
Rui Ueyama 18f084ff62 Function names should start with lowercase letters.
llvm-svn: 276165
2016-07-20 19:36:41 +00:00
Rafael Espindola 74df5c7eeb Fix build with gcc 6.
llvm-svn: 275972
2016-07-19 12:33:46 +00:00
Eugene Leviant bbe3860244 [ELF] Minimal PHDRS parser and section to segment assignment support
llvm-svn: 275965
2016-07-19 09:25:43 +00:00
George Rimar 5d53d1f42c [ELF] - Make few members of Writer to be global and export them for reuse
Creating sections on linkerscript side requires some methods
that can be reused if are exported from writer.

Patch implements that change.

Differential revision: http://reviews.llvm.org/D20104

llvm-svn: 275162
2016-07-12 08:50:42 +00:00
Rui Ueyama 4f8d21f387 Do not pass Symtab to markLive/doICF since Symtab is globally accessible.
llvm-svn: 268286
2016-05-02 19:30:42 +00:00
Rafael Espindola e0df00b91f Rename elf2 to elf.
llvm-svn: 262159
2016-02-28 00:25:54 +00:00
Rui Ueyama c4aaed9255 ELF2: Implement --gc-sections.
Section garbage collection is a feature to remove unused sections
from outputs. Unused sections are sections that cannot be reachable
from known GC-root symbols or sections. Naturally the feature is
implemented as a mark-sweep garbage collector.

In this patch, I added Live bit to InputSectionBase. If and only
if Live bit is on, the section will be written to the output.
Starting from GC-root symbols or sections, a new function, markLive(),
visits all reachable sections and sets their Live bits. Writer then
ignores sections whose Live bit is off, so that such sections are
excluded from the output.

This change has small negative impact on performance if you use
the feature because making sections means more work. The time to
link Clang changes from 0.356s to 0.386s, or +8%.

It reduces Clang size from 57,764,984 bytes to 55,296,600 bytes.
That is 4.3% reduction.

http://reviews.llvm.org/D13950

llvm-svn: 251043
2015-10-22 18:49:53 +00:00
Rui Ueyama 3ce825ed26 ELF2: Make SymbolTable a template class.
SymbolTable was not a template class. Instead we had switch-case-based
type dispatch to call desired functions. We had to do that because
SymbolTable was created before we know what ELF type objects had been
passed.

Every time I tried to add a new function to the symbol table, I had to
define a dispatcher which consist of a single switch statement.

It also brought an restriction what the driver can do. For example,
we cannot add undefined symbols before any files are added to the symbol
table. That's because no symbols can be added until the symbol table
knows the ELF type, but when it knows about that, it's too late.

In this patch, the driver makes a decision on what ELF type objects
are being handled. Then the driver creates a SymbolTable object for
an appropriate ELF type.

http://reviews.llvm.org/D13544

llvm-svn: 249902
2015-10-09 21:07:25 +00:00
Rui Ueyama 75230398c2 ELF2: De-templatize writeResult for simplicity.
llvm-svn: 249586
2015-10-07 18:29:51 +00:00
Rafael Espindola beee25e484 Make these headers as being c++.
llvm-svn: 245050
2015-08-14 14:12:54 +00:00
Rafael Espindola 52a0f1e8c6 Move more code that is local to Writer.cpp to an anonymous namespace.
llvm-svn: 244697
2015-08-11 23:22:24 +00:00
Rui Ueyama cb8474edae COFF, ELF2: Pass output file path implicitly using Config global variable.
Various parameters are passed implicitly using Config global variable
already. Output file path is no different from others, so there was no
special reason to handle that differnetly.

This patch changes the signature of writeResult(SymbolTable *, StringRef)
to writeResult(SymbolTable *).

llvm-svn: 244180
2015-08-05 23:51:50 +00:00
Rui Ueyama afff74e228 ELF2: Simplify Writer interface.
We are using Writer more like a function instead of a class.
This patch makes it a function to simplify the interface.
All details of Writer class is now hidden from other parts of the linker.

llvm-svn: 244169
2015-08-05 23:24:46 +00:00
Rafael Espindola e7a00e326a For now we only have on Chunk type. Simplify.
The others we have in sight are
* common symbols.
* entries in SHF_MERGE sections.

They will have a substantially different treatment. It is not clear if it is
worth it putting them all in a single list just to dispatch based on the kind on
the other side.

I hope to implement common symbols soon, and then we will be in a position
to have a concrete discussion. For now this is simpler for the the implemented
features.

llvm-svn: 244042
2015-08-05 13:55:34 +00:00
Rafael Espindola 2ffdd4d0e5 The SymbolTable doesn't need to be a template.
It was already using just code that is common to all object files.

llvm-svn: 243985
2015-08-04 14:29:01 +00:00
Michael J. Spencer 44fc1c0a73 [ELF2] Templatize addChunk and handle section flags.
llvm-svn: 243579
2015-07-29 22:14:50 +00:00
Michael J. Spencer 8039dae26d [ELF2] Emit section table.
llvm-svn: 243506
2015-07-29 00:30:10 +00:00
Rui Ueyama 179cd7b82a ELF2: Remove dead code.
llvm-svn: 243231
2015-07-26 00:50:13 +00:00
Michael J. Spencer 84487f1174 [ELF2] Add a new ELF linker based on the new PE/COFF linker.
Differential Revision: http://reviews.llvm.org/D11188

llvm-svn: 243161
2015-07-24 21:03:07 +00:00
Michael J. Spencer bae540e945 Revert ELF port. Posting to mailing list.
llvm-svn: 242118
2015-07-14 04:49:48 +00:00
Michael J. Spencer 8a4145411f Initial ELF port.
This is a direct port of the new PE/COFF linker to ELF.

It can take a single object file and generate a valid executable that executes at the first byte in the text section.

llvm-svn: 242088
2015-07-13 23:48:06 +00:00