Rafael Espindola
05a3dd2cba
Implement --export-dynamic.
...
llvm-svn: 248347
2015-09-22 23:38:23 +00:00
Rafael Espindola
01205f79a4
Start adding target abstractions.
...
This is just enough to get PLT working on 32 bit x86.
The idea behind using a virtual interface is that it should be easy to
convert any of the functions to template parameters if any turns out to be
performance critical.
llvm-svn: 248308
2015-09-22 18:19:46 +00:00
Rafael Espindola
7167585c94
Remove the Chunk terminology from ELF.
...
llvm-svn: 248229
2015-09-22 00:16:19 +00:00
Rafael Espindola
5805c4f509
Move OutputSectionBase and derived classes out of Writer.cpp.
...
The file was getting a bit too big and OutputSection is a central enough
concept in ELF linking to justify its own file.
llvm-svn: 248214
2015-09-21 21:38:08 +00:00
Davide Italiano
8ca741d51d
[ELF2] Support relocs for local symbols
...
Differential Revision: http://reviews.llvm.org/D12978
llvm-svn: 248196
2015-09-21 19:30:11 +00:00
Rafael Espindola
53d5cea648
Rename SectionChunk to InputSection.
...
This is more consistent with OutputSection. This is also part of removing
the "Chunk" term from the ELF linker, since we just have input/output sections
and program headers.
llvm-svn: 248183
2015-09-21 17:47:00 +00:00
Rafael Espindola
eb79273158
Start adding support for PLT.
...
For now this doesn't support lazy symbol resolution, but is enough to link
and run a program with
jmp foo@PLT
llvm-svn: 248165
2015-09-21 15:11:29 +00:00
Davide Italiano
5445b2de50
[ELF2] Implement support for -discard-locals.
...
This is not on by default, but it may make sense to change it in future.
llvm-svn: 248133
2015-09-20 21:58:12 +00:00
Michael J. Spencer
9779535c5d
[elf2] Relocate against undefined weak symbols.
...
llvm-svn: 248056
2015-09-18 22:26:13 +00:00
Michael J. Spencer
658dccd1c8
[elf2] Relocate against common symbols.
...
llvm-svn: 248054
2015-09-18 22:13:25 +00:00
Michael J. Spencer
9567495154
[elf2] Convert if/else cascade into a covered switch. NFC.
...
llvm-svn: 248049
2015-09-18 21:48:38 +00:00
Rafael Espindola
5c2310c30c
Start adding support for creating the GOT.
...
With this a program can call into a shared library with
jmp *foo@GOTPCREL(%rip)
llvm-svn: 247992
2015-09-18 14:40:19 +00:00
Davide Italiano
b5b47b432b
[ELF2] Fill up local symbols fields correctly.
...
Differential Revision: http://reviews.llvm.org/D12944
llvm-svn: 247960
2015-09-18 01:08:17 +00:00
Rafael Espindola
8315b1c995
Remove dead member variable.
...
llvm-svn: 247949
2015-09-17 21:34:32 +00:00
Michael J. Spencer
2f0082424f
[elf2] Combine adjacent compatible OutputSections in PT_LOADs.
...
llvm-svn: 247925
2015-09-17 19:58:07 +00:00
Rafael Espindola
40102eb27f
Use a MapVector to output symbols in a deterministic order.
...
We used to sort the symbols at the very end, but we need to know the order
earlier so that we can create reference to them in the dynamic relocations.
Thanks to Igor Kudrin for pointing out the problem.
llvm-svn: 247911
2015-09-17 18:26:25 +00:00
Rafael Espindola
67a5da60ed
Add support of Elf_Rel dynamic relocations.
...
llvm-svn: 247888
2015-09-17 14:02:10 +00:00
Denis Protivensky
18add764f0
[ELF2] Fix typo in RelocationSection::hasRelocs method
...
llvm-svn: 247878
2015-09-17 09:54:29 +00:00
Rafael Espindola
eade07ba59
Start adding support for Elf_Rel.
...
I don't intend to add full i686 support right now, just make sure we have all
the infrastructure in place for it.
llvm-svn: 247858
2015-09-16 21:57:07 +00:00
Davide Italiano
6d328d3841
[ELF2] Initial support for local symbols.
...
Symbol table is now populated correctly, but some fields are missing,
they'll be added in the future. This patch also adds --discard-all
flag, which was the default behavior until now.
Differential Revision: http://reviews.llvm.org/D12874
llvm-svn: 247849
2015-09-16 20:45:57 +00:00
Rafael Espindola
2b92d8f184
Move code computing NumEntries to finalize.
...
When DynamicSection is constructed we still don't know if there will be
any dynamic relocations or not.
llvm-svn: 247838
2015-09-16 19:26:31 +00:00
Rafael Espindola
3887ebfc21
Add DT_RELA and DT_RELASZ to the dynamic table.
...
llvm-svn: 247837
2015-09-16 18:52:42 +00:00
Rafael Espindola
19e3889dba
Start creating dynamic relocations.
...
For now we don't create got/plt and only Elf_Rela is supported.
llvm-svn: 247811
2015-09-16 15:54:15 +00:00
Michael J. Spencer
141dd91ac5
[elf2] Simplify overflow checks.
...
llvm-svn: 247768
2015-09-16 02:02:04 +00:00
Michael J. Spencer
75e5fda3de
[elf2] Add R_X86_64_32S.
...
llvm-svn: 247758
2015-09-16 00:24:19 +00:00
Michael J. Spencer
dff84070da
[elf2] Add error checking for the R_X86_64_32 relocation.
...
llvm-svn: 247745
2015-09-15 23:36:30 +00:00
Michael J. Spencer
3c1ac0a17a
[elf2] Relocate absolute symbols.
...
llvm-svn: 247738
2015-09-15 23:12:02 +00:00
Rafael Espindola
e6451d9e74
Replace isa+cast with dyn_cast. NFC.
...
llvm-svn: 247691
2015-09-15 14:08:11 +00:00
Rafael Espindola
a5c97d9025
Add support for R_X86_64_64.
...
llvm-svn: 247688
2015-09-15 13:52:06 +00:00
Rui Ueyama
b73002fb4e
ELF2: Simplify by removing temporary variables.
...
llvm-svn: 247652
2015-09-15 01:03:58 +00:00
Rafael Espindola
c92d28d427
Simplify, NFC.
...
Thanks to Rui for the suggestion.
llvm-svn: 247637
2015-09-14 23:28:02 +00:00
Rafael Espindola
80faee82e6
Add content to the .hash section.
...
This also sets DT_HASH.
With this simple shared libraries created by lld can be loaded by the dynamic
linker.
llvm-svn: 247625
2015-09-14 22:08:55 +00:00
Rui Ueyama
9078f73fa0
Use C++11 member initializers. NFC.
...
llvm-svn: 247613
2015-09-14 20:32:41 +00:00
Rafael Espindola
601771ebc0
Start adding the .hash output section.
...
It is still empty. Content will be added in the next patch.
llvm-svn: 247609
2015-09-14 20:20:34 +00:00
Rafael Espindola
bfcdfb32af
Correctly align sections.
...
We have to align the start, not the end.
This should fix crashes on systems where memcpy enforces the expected
alignment.
llvm-svn: 247599
2015-09-14 19:00:35 +00:00
Rafael Espindola
4340aad144
Start adding support for creating shared libraries.
...
They are not fully functional yet, but this implements enough support for lld
itself to read them.
With that, delete the .so binary we were using for tests and start eating our
own dog food.
llvm-svn: 247487
2015-09-11 22:42:45 +00:00
Rafael Espindola
1d12ab3db1
Fix handling of _start being undefined.
...
We were crashing before.
llvm-svn: 247481
2015-09-11 21:44:55 +00:00
Rafael Espindola
2e9eac13c7
Implement -rpath.
...
llvm-svn: 247475
2015-09-11 21:18:56 +00:00
Rafael Espindola
7010776db7
Implement the -dynamic-linker option.
...
With this dynamic executables can be executed with just ./t instead of
/lib64/ld-2.20.so ./t
llvm-svn: 247446
2015-09-11 18:49:42 +00:00
Rafael Espindola
d67bb26642
Add more information to a comment.
...
llvm-svn: 247408
2015-09-11 13:20:07 +00:00
Rafael Espindola
243d90f549
Add a DT_SYMTAB entry in the dynamic section.
...
With this a trivial shared binary runs with the glibc dynamic linker:
LD_LIBRARY_PATH=. /lib64/ld-2.20.so ./t
llvm-svn: 247370
2015-09-11 01:14:39 +00:00
Rafael Espindola
fb815282d5
Create a dynamic symbol table.
...
For now it includes every symbol in the regular table. Since we don't
create dynamic relocations yet, we don't have a good way of knowing which
symbols are actually needed.
llvm-svn: 247365
2015-09-11 00:30:13 +00:00
Rafael Espindola
24d07fdd27
Cache the bss output section in the writer, not in the symbol table.
...
There is soon going to be two symbol tables, but there will still be only one
output bss.
llvm-svn: 247363
2015-09-11 00:10:11 +00:00
Rafael Espindola
dd34a4d3c5
Make a few details of the string and symbol table private.
...
This is in preparation to adding a dynamic string table.
llvm-svn: 247355
2015-09-10 22:49:06 +00:00
Rafael Espindola
65db630fe7
Fix a warning when building with gcc.
...
It was
/Writer.cpp:119:45: warning: enumeral and non-enumeral type in conditional expression
llvm-svn: 247330
2015-09-10 20:02:22 +00:00
Rafael Espindola
0a2e211ace
Create a PT_LOAD program header for the start of the file.
...
With this a trivial dynamic program works with the musl dynamic linker:
LD_LIBRARY_PATH=. ~/musl/lib/libc.so ./t
llvm-svn: 247290
2015-09-10 15:41:34 +00:00
Rafael Espindola
60252d8feb
Change the load addr into something that works on linux x86_64.
...
With this simple static programs run again.
llvm-svn: 247205
2015-09-09 22:53:55 +00:00
Michael J. Spencer
1d299a8a9d
[elf2] Assign output sections to PHDRs.
...
This is a minimal implementation to produce legal output. Future patches will combine multiple compatible PT_LOADs.
llvm-svn: 247185
2015-09-09 20:48:09 +00:00
Rafael Espindola
778562fc78
Add the DT_NEEDED entries to the dynamic table.
...
llvm-svn: 247181
2015-09-09 20:26:23 +00:00
Rafael Espindola
3f4228f613
Start adding content to the dynamic section.
...
With this patch we create a dynamic string table (it is allocated, unlike
the regular one) and the dynamic section has a DT_STRTAB pointing to it.
llvm-svn: 247155
2015-09-09 15:33:08 +00:00
Rafael Espindola
e438e07856
Create a dynamic segment.
...
It is still empty. I will add content next.
llvm-svn: 247097
2015-09-08 22:55:28 +00:00
Michael J. Spencer
ac5f048e09
[lld][elf2] Address review comments.
...
llvm-svn: 247096
2015-09-08 22:51:46 +00:00
Michael J. Spencer
546c64c733
[lld][elf2] Fix hard coded entry address.
...
llvm-svn: 247089
2015-09-08 22:34:57 +00:00
Rafael Espindola
18608a0a55
Simplify using namespaces and typedefs. NFC.
...
llvm-svn: 247079
2015-09-08 21:57:31 +00:00
Rafael Espindola
b9fe03d4a9
Revert "[lld][elf2] Fix hard coded entry address."
...
This reverts commit r247073.
It broke
lld :: elf2/basic32be.s
lld :: elf2/basic64be.s
llvm-svn: 247077
2015-09-08 21:32:44 +00:00
Michael J. Spencer
8be15899b4
[lld][elf2] Fix hard coded entry address.
...
llvm-svn: 247073
2015-09-08 21:11:25 +00:00
Rafael Espindola
740fafe54d
Start creating the .dynamic section.
...
For now it is always empty.
llvm-svn: 247056
2015-09-08 19:43:27 +00:00
Rafael Espindola
57b2592ace
Don't treat the string table index specially. NFC.
...
We assign the string table section an index like every other section, we can
use it from there.
llvm-svn: 247051
2015-09-08 19:23:30 +00:00
Rafael Espindola
b01b57486d
Bug fix: Assign output section indexes *after* sorting them.
...
llvm-svn: 247037
2015-09-08 18:08:57 +00:00
Rafael Espindola
5f55387251
Every output section should be added to the OutputSecitons vector.
...
Simplify.
llvm-svn: 247032
2015-09-08 17:39:39 +00:00
Rafael Espindola
18173d420e
Start adding support for symbols in shared libraries.
...
llvm-svn: 247019
2015-09-08 15:50:05 +00:00
Rafael Espindola
4f624b9581
Simplify reporting of undefined symbols.
...
llvm-svn: 247016
2015-09-08 14:32:29 +00:00
Rafael Espindola
a4dd7c1d38
Revert "[elf2] Add 32S and 64 relocations (needed for musl)."
...
This reverts commit r246902. It had uncessary use of yaml.
llvm-svn: 247014
2015-09-08 13:52:31 +00:00
Michael J. Spencer
1b3fffa6e0
[elf2] Add 32S and 64 relocations (needed for musl).
...
It wasn't obvious what the assembly was to generate these relocations, so I did the test with yaml.
llvm-svn: 246902
2015-09-05 00:36:03 +00:00
Michael J. Spencer
baae538cc6
[elf2] Correctly handle sections with an alignment of 0. Spec says to treat it as an alignment of 1.
...
llvm-svn: 246901
2015-09-05 00:25:33 +00:00
Michael J. Spencer
f832541066
[elf2] Fix include order.
...
llvm-svn: 246892
2015-09-04 22:48:30 +00:00
Michael J. Spencer
1b348a68e5
[elf2] Add basic archive file support.
...
llvm-svn: 246886
2015-09-04 22:28:10 +00:00
Davide Italiano
ad6c81c628
[ELF2] Writer: Fold variables, use setVisibility(). NFCI.
...
llvm-svn: 246861
2015-09-04 19:42:14 +00:00
Rafael Espindola
f98d6d84cd
Start adding support for shared libraries.
...
This just adds the types and enough support to detect incompatibilities among
shared libraries and object files.
llvm-svn: 246797
2015-09-03 20:03:54 +00:00
Rafael Espindola
8aeb13fec1
Add a helper function for getting the first object file.
...
Also preparation for shared objects. It will become the first ELF file.
llvm-svn: 246796
2015-09-03 19:13:13 +00:00
Rafael Espindola
222edc66d6
Make ObjectFiles private. NFC.
...
Just preparation for adding support for shared libraries.
llvm-svn: 246793
2015-09-03 18:56:20 +00:00
Rafael Espindola
78471f0ec1
Merge visibility from all symbols with the same name.
...
The ELF spec says:
... if any reference to or definition of a name is a symbol with a
non-default visibility attribute, the visibility attribute must be
propagated to the resolving symbol in the linked object. If different
visibility attributes are specified for distinct references to or
definitions of a symbol, the most constraining visibility attribute
must be propagated to the resolving symbol in the linked object. The
attributes, ordered from least to most constraining, are:
STV_PROTECTED, STV_HIDDEN and STV_INTERNAL.
llvm-svn: 246603
2015-09-01 23:12:52 +00:00
Rafael Espindola
ee1364f7f6
Don't leave unused strings in the string table.
...
llvm-svn: 246593
2015-09-01 21:47:21 +00:00
Rafael Espindola
5b3942f54a
Don't include hidden or internal symbols in the symbol table.
...
llvm-svn: 246583
2015-09-01 20:36:51 +00:00
Rafael Espindola
7f37775e56
Every symbol now has an Elf_Sym. Simplify. NFC.
...
llvm-svn: 246581
2015-09-01 20:30:52 +00:00
Rafael Espindola
06c3a6d676
Start recording st_other (i.e. visibility).
...
llvm-svn: 246577
2015-09-01 19:42:38 +00:00
Rafael Espindola
f31f9617ca
Remember the maximum alignment used to refer to a common symbol.
...
llvm-svn: 246517
2015-09-01 01:19:12 +00:00
Rafael Espindola
b56cb9437f
Sort common symbols by alignment.
...
llvm-svn: 246511
2015-09-01 00:16:38 +00:00
Rafael Espindola
ce8c9c0548
Set the correct value for the common symbols.
...
In the relocatable object it is the alignment, but in the linked file it is
a regular address.
llvm-svn: 246505
2015-08-31 22:55:21 +00:00
Rafael Espindola
8b09d68447
Assign common symbols to the .bss output section.
...
llvm-svn: 246503
2015-08-31 22:33:21 +00:00
Rafael Espindola
0518574a73
Start allocating space for common symbols.
...
llvm-svn: 246496
2015-08-31 22:07:18 +00:00
Rafael Espindola
058f343246
Don't allocate space for SHT_NOBITS sections.
...
llvm-svn: 246480
2015-08-31 20:23:57 +00:00
Rafael Espindola
f7d45f0869
Delete SyntheticUndefined.
...
Now that resolved is templated anyway, we can use the regular Undefined.
llvm-svn: 246407
2015-08-31 01:46:20 +00:00
Rafael Espindola
30e1797b38
Turn resolution.s into an exhaustive testcase.
...
Now that we print a symbol table and all symbol kinds are at least declared,
we can test all combinations that don't produce an error.
This also includes a few fixes to keep the test passing:
* Keep the strong symbol in a weak X strong pair
* Handle common symbols.
The common X common case will be finished in a followup patch.
llvm-svn: 246401
2015-08-30 23:17:30 +00:00
Davide Italiano
94f183a696
[ELFv2] Implement R_X86_64_32 relocation.
...
Differential Revision: http://reviews.llvm.org/D12436
llvm-svn: 246362
2015-08-29 13:15:42 +00:00
Rafael Espindola
51d4690b6e
Start adding support for common symbols.
...
For now this just recognizes the special section number.
llvm-svn: 246332
2015-08-28 21:26:51 +00:00
Rafael Espindola
3a63f3fb22
Add support for weak absolute symbols.
...
On ELF being weak is independent of what we call the kind of the symbol. So
this also makes the code simpler.
llvm-svn: 246326
2015-08-28 20:19:34 +00:00
Rafael Espindola
871765c321
Make sure we output symbols in the same order on 32 and 64 bit builds.
...
llvm-svn: 246264
2015-08-28 02:46:41 +00:00
Michael J. Spencer
67bc8d6b3f
[elf2] Add basic relocation support for x86-64.
...
This currently doesn't handle local symbols.
Differential Revision: http://reviews.llvm.org/D11612
llvm-svn: 246234
2015-08-27 23:15:56 +00:00
Rafael Espindola
0e0c1901c9
Start adding support for absolute symbols.
...
llvm-svn: 246147
2015-08-27 12:40:06 +00:00
Rafael Espindola
e11c6d2d6f
Set the symbol size in the symbol table.
...
llvm-svn: 246086
2015-08-26 21:46:24 +00:00
Rafael Espindola
034e2e7a8e
Define types close to use. NFC.
...
llvm-svn: 246085
2015-08-26 21:42:36 +00:00
Rafael Espindola
f3837074cc
Set the symbol value in the symbol table.
...
llvm-svn: 245943
2015-08-25 15:53:17 +00:00
Rafael Espindola
832b93f219
Start recording the section of symbols in the symbol table.
...
Support for more than 64 K sections to follow shortly.
llvm-svn: 245868
2015-08-24 20:06:32 +00:00
Rafael Espindola
e6f52102a3
Remove a duplicated member variable. NFC.
...
This just makes it clear that, for now, there is only one symbol table.
llvm-svn: 245844
2015-08-24 14:48:18 +00:00
Rafael Espindola
1bd885aba4
ELF: Also record the type of undefined symbols.
...
Tested with a weak undefined. Testing with a plain undefined will have to wait
for support for -shared.
llvm-svn: 245069
2015-08-14 16:46:28 +00:00
Rafael Espindola
bd481b8f89
Fix the build with gcc.
...
llvm-svn: 245060
2015-08-14 15:20:34 +00:00
Rafael Espindola
c44d17ad45
Add the type of the symbols to the symbol table.
...
For now only defined symbols are covered. I will add undefined ones in the
next patch.
llvm-svn: 245057
2015-08-14 15:10:49 +00:00
Rafael Espindola
383c323d4d
ELF: Set the correct symbol binding.
...
llvm-svn: 245049
2015-08-14 13:52:36 +00:00
Rafael Espindola
62b81b875a
Start populating the symbol table.
...
With this patch only the name is set. I will set the other fields shortly.
For now the table doesn't include local symbols. This is equivalent to using
--discard-all with gnu ld. This is OK for now since the symbols are not
needed for execution and for testing symbol resolution we only need the
global symbols.
llvm-svn: 245044
2015-08-14 13:07:05 +00:00
Rui Ueyama
8050d32b13
ELF2: Rename a function to make it the same as the COFF's counterpart.
...
llvm-svn: 245030
2015-08-14 05:17:30 +00:00
Rafael Espindola
f763ca3c9c
ELF: Create a symbol table.
...
For now it is empty. I will add the symbols in a followup patch.
llvm-svn: 245008
2015-08-14 02:42:20 +00:00
Rafael Espindola
83b0dc6392
ELF: Drop the Chunk base class.
...
With OutputSection being a virtual interface, each concrete OutputSection
handles only one type of chunk and we don't need a base Chunk class.
So for we have a class that handles input sections and one that handles
the string table, but this extends naturally for other outputs (symbol table,
merging of SHF_MERGE sections, etc.).
llvm-svn: 244972
2015-08-13 22:21:37 +00:00
Rafael Espindola
ebd2108215
Make OutputSection virtual and use that for creating the string table.
...
We were creating the string table in a completely ad hoc way. Now the
string table is an output section and gets its output offset set just like
any other section.
This opens the way for other linker created sections like the symbol table.
llvm-svn: 244969
2015-08-13 22:14:37 +00:00
Rafael Espindola
2db634d8f1
Correctly align output sections.
...
They don't need to be aligned to page boundaries. Only segments need that.
llvm-svn: 244942
2015-08-13 20:24:18 +00:00
Rafael Espindola
0160a281c2
Record the alignment of the output sections.
...
llvm-svn: 244941
2015-08-13 20:13:39 +00:00
Rafael Espindola
ea133eaa39
Delete dead code.
...
llvm-svn: 244938
2015-08-13 19:00:23 +00:00
Rafael Espindola
a175eb6ca6
Template OutputSection only over Is64Bit.
...
This is a bit more c++ code, but:
* It is less machine code: lld's text is 44688 bytes smaller.
* It should be a bit more efficient in the non native endian case.
* It should be a bit more efficient on architectures with slow unaligned access.
llvm-svn: 244934
2015-08-13 18:37:23 +00:00
Rafael Espindola
184d94e009
Define trivial methods inline. NFC.
...
llvm-svn: 244930
2015-08-13 18:25:47 +00:00
Rafael Espindola
64e888ba5f
Set the file offset of zero sized sections.
...
There is no reason not to do it and this matches what gold and bfd ld do.
llvm-svn: 244929
2015-08-13 18:23:43 +00:00
Rafael Espindola
29e8d343e4
Rename addSectionChunk to addChunk now that it can handle any Chunk.
...
llvm-svn: 244919
2015-08-13 17:35:13 +00:00
Rafael Espindola
375a508234
Pass the type and flags to the OutputSection constructor. NFC.
...
This will allow further cleanups.
llvm-svn: 244918
2015-08-13 17:32:30 +00:00
Rafael Espindola
a7471795ae
Take name, type and flags in consideration when concatenating sections.
...
This is mandated by the ELF spec.
llvm-svn: 244911
2015-08-13 17:04:50 +00:00
Rafael Espindola
674b5d570f
Store the offset in the output section, no in the file.
...
That is the value that is stable as the we layout the output sections.
llvm-svn: 244904
2015-08-13 15:54:36 +00:00
Rafael Espindola
ef1ac01c2e
Don't give an address to sections that are not allocated.
...
llvm-svn: 244900
2015-08-13 15:31:17 +00:00
Rafael Espindola
abad6186c3
Place SHF_ALLOC sections first in the output.
...
Having them in the middle of the file complicates the creation of segments.
llvm-svn: 244898
2015-08-13 15:23:46 +00:00
Rafael Espindola
25f51850a4
Delete dead code.
...
llvm-svn: 244896
2015-08-13 14:48:49 +00:00
Rafael Espindola
bdc8f2fb83
Update for llvm api change.
...
llvm-svn: 244849
2015-08-13 00:31:46 +00:00
Rafael Espindola
372889a8e6
Fix an use of uninitialized.
...
Should fix some tests on windows.
llvm-svn: 244834
2015-08-12 23:25:42 +00:00
Rafael Espindola
91009b3856
Fix the alignment of the section headers.
...
Thanks a lot to Rui for noticing it.
llvm-svn: 244711
2015-08-12 01:45:28 +00:00
Rafael Espindola
6b83b90b6a
ELF: Create a string table.
...
For now only the sections are in it, but it already makes the output easier
to read and test.
llvm-svn: 244702
2015-08-12 00:00:24 +00:00
Rafael Espindola
021834046f
Template ELF's OutputSection.
...
This removes what I think is the last hard coded ELF64 structure.
llvm-svn: 244700
2015-08-11 23:34:29 +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
Rafael Espindola
5211c2a1a0
Delete dead code.
...
llvm-svn: 244696
2015-08-11 23:19:06 +00:00
Rafael Espindola
98f6bd09e4
Be a bit more consistent about using uintX_t for offsets and sizes. NFC.
...
llvm-svn: 244694
2015-08-11 23:14:13 +00:00
Rafael Espindola
192e1fa59d
Move the error handling functions to Error.h. NFC.
...
llvm-svn: 244216
2015-08-06 15:08:23 +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
4b7c2fc64e
Add bare minimum to get a working i386 linux program.
...
llvm-svn: 244050
2015-08-05 15:08:40 +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
87ee8dcb64
Use ELFOSABI_NONE. This matches both bfd ld and gold.
...
llvm-svn: 244033
2015-08-05 11:55:52 +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
Rafael Espindola
b89951457d
Remove SymbolTable::getChunks.
...
When we were using a std::sort over all the chunks we needed to put them in a
single storage.
Now that we just iterate over them and use a map to find the output section,
we can avoid allocating the temporary storage.
llvm-svn: 243980
2015-08-04 13:39:30 +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
e44524de65
Use SmallDenseMap instead of std::map where we don't care about order of keys.
...
llvm-svn: 243358
2015-07-28 00:17:25 +00:00
Rui Ueyama
06d7bd2e42
ELF2: Avoid calling std::sort to make output deterministic.
...
llvm-svn: 243232
2015-07-26 00:50:15 +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
f754b1fe12
Put explicit template instantiations in the correct namespace.
...
llvm-svn: 242093
2015-07-14 00:22:00 +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