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