Commit Graph

80 Commits

Author SHA1 Message Date
Rui Ueyama 570752c7ac Do not use unique pointers. NFC.
These unique pointers have the exact same lifetime as automatic
variables, so use automatic variables instead.

llvm-svn: 245281
2015-08-18 09:13:25 +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 457c940835 Delete dead code.
llvm-svn: 245056
2015-08-14 14:58:57 +00:00
Rafael Espindola 4c3aa0f228 Delete unused forward declarations.
llvm-svn: 245055
2015-08-14 14:51:11 +00:00
Rafael Espindola 3bf356ee9c Remove unused default values.
llvm-svn: 245053
2015-08-14 14:38:44 +00:00
Rafael Espindola beee25e484 Make these headers as being c++.
llvm-svn: 245050
2015-08-14 14:12:54 +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 5d83ccd55b Make getSectionName non virtual. NFC.
llvm-svn: 244939
2015-08-13 19:18:30 +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 cde251370a Include non-alloca sections in the link.
llvm-svn: 244895
2015-08-13 14:45:44 +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
Rui Ueyama 4f89fdad9f ELF2: Make Defined{Regular,Weak} ctors look the same as other SymbolBody ctors.
llvm-svn: 244701
2015-08-11 23:37:25 +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
Rui Ueyama 880632c458 ELF2: Remove unused global variable.
A global variable "Driver" is to re-entry to the driver to parse a
.drectve section. Because the need is COFF-specific, we don't need
this variable for ELF.

llvm-svn: 244680
2015-08-11 21:45:55 +00:00
Reid Kleckner f7b85e0ce2 Fix mismatched sign comparison
llvm-svn: 244653
2015-08-11 20:06:51 +00:00
Rafael Espindola 76e24ea955 Add support for weak undefined symbols.
llvm-svn: 244640
2015-08-11 17:57:05 +00:00
Rafael Espindola 791e9f9c59 Remove unused templating.
llvm-svn: 244639
2015-08-11 17:51:57 +00:00
Rafael Espindola b13df6582a Add support for weak symbols.
llvm-svn: 244636
2015-08-11 17:33:02 +00:00
Rafael Espindola ae1b23bd61 Use real values for DefindeFirst and DefinedLast.
With this clang notices that switches are fully covered.

llvm-svn: 244632
2015-08-11 17:10:02 +00:00
Rafael Espindola 9247f165ff Delete unused typedef.
llvm-svn: 244628
2015-08-11 16:55:28 +00:00
Rafael Espindola 7c388187c9 Don't report a conflict between two local symbols.
llvm-svn: 244624
2015-08-11 16:30:34 +00:00
Rafael Espindola d8340dae0c Don't depend on getDotSymtabSec. It is going away.
llvm-svn: 244451
2015-08-10 15:12:17 +00:00
Rafael Espindola 1a9344fa26 Use already available symbol tables. NFC.
llvm-svn: 244336
2015-08-07 17:16:28 +00:00
Rafael Espindola df1e05a26c Delete broken code.
This was using a hard coded string table and getting it for every symbol.

The symbol name was already available.

llvm-svn: 244220
2015-08-06 15:33:21 +00:00
Rafael Espindola 49a2ca6ddd bar
llvm-svn: 244219
2015-08-06 15:33:19 +00:00