summaryrefslogtreecommitdiffstats
path: root/lld/lib/ReaderWriter
Commit message (Collapse)AuthorAgeFilesLines
...
* Add a newline to an error message.Rui Ueyama2013-12-251-1/+1
| | | | llvm-svn: 198016
* [PECOFF] Set default subsystem to the DLL header.Rui Ueyama2013-12-251-0/+4
| | | | | | | | Subsystem field in the PE/COFF file header has no meanining for the DLL. It looks like MSVC link.exe sets the default subsystem (Windows GUI) to the field if no /subsystem option is specified. llvm-svn: 198015
* Unbreak buildbot.Rui Ueyama2013-12-251-1/+1
| | | | llvm-svn: 198002
* [PECOFF] Use the first definition of an export if specified multiple times.Rui Ueyama2013-12-251-0/+10
| | | | | | | If the same symbol is specified multiple times as arguments of /export, the first definition should be used. llvm-svn: 197998
* [PECOFF] Fix /export option in the .drectve section.Rui Ueyama2013-12-243-4/+11
| | | | | | | /EXPORT option has slightly different semantics if it appears in the .drectve section. This patch implements it. llvm-svn: 197970
* Fix indentation in the MachO writer.Joey Gouly2013-12-231-3/+3
| | | | llvm-svn: 197925
* [mach-o] add MachOLinkingContext::configure(type, arch, os)Nick Kledzik2013-12-211-30/+41
| | | | | | | | | It will configure resonable defaults for other settings in the MachOLinkingContext object based on the parameters. Patch by Joe Ranieri llvm-svn: 197851
* Restore vertical alignment lost by clang-formatNick Kledzik2013-12-205-195/+192
| | | | llvm-svn: 197834
* [PECOFF] Create noname or data symbols as such.Rui Ueyama2013-12-201-2/+8
| | | | | | | | | | | If a symbol in an import library is marked as "data", the linker will not create a jump table entry for the symbol, since jump table makes sense only for a symbol pointing to a function. I don't think NONAME attribute has a meaning when creating an import library. The attribute is emitted for debugging purpose. llvm-svn: 197803
* [PECOFF] Create the import library file.Rui Ueyama2013-12-204-0/+105
| | | | | | | | | | | If the linker is instructed to create a DLL, it will also create an import library (.lib file) to describe the symbols exported by the DLL. This patch is to create the import library file. There is a convenient command "lib.exe" which can create an import library from a module definition file (.def file). The command is used in this patch. llvm-svn: 197801
* [PECOFF] Assign default export ordinals in LinkingContext::verify().Rui Ueyama2013-12-202-16/+17
| | | | | | | | | | | | | | | Default ordinals were assigned in EdataPass, and the assigned values were then discarded in the pass. No code other than EdataPass would not be able to get all of the information about ordinals. That's not ideal since I'm writing code to emit an Import Library file, which also needs ordinals. This is a patch to move the code to assign default ordinals from EdataPass to LinkingContext::verify(), so that assigned ordinals will be available anywhere. No functionality change. llvm-svn: 197797
* Run clang-format on r197727.Rui Ueyama2013-12-2041-620/+513
| | | | llvm-svn: 197788
* [lld] fix unused variable warningsNick Kledzik2013-12-195-12/+4
| | | | llvm-svn: 197737
* [lld] fix build when LLVM_HAS_VARIADIC_TEMPLATES is falseNick Kledzik2013-12-191-0/+9
| | | | llvm-svn: 197734
* [lld] Introduce registry and Reference kind tupleNick Kledzik2013-12-1960-1580/+1754
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The main changes are in: include/lld/Core/Reference.h include/lld/ReaderWriter/Reader.h Everything else is details to support the main change. 1) Registration based Readers Previously, lld had a tangled interdependency with all the Readers. It would have been impossible to make a streamlined linker (say for a JIT) which just supported one file format and one architecture (no yaml, no archives, etc). The old model also required a LinkingContext to read an object file, which would have made .o inspection tools awkward. The new model is that there is a global Registry object. You programmatically register the Readers you want with the registry object. Whenever you need to read/parse a file, you ask the registry to do it, and the registry tries each registered reader. For ease of use with the existing lld code base, there is one Registry object inside the LinkingContext object. 2) Changing kind value to be a tuple Beside Readers, the registry also keeps track of the mapping for Reference Kind values to and from strings. Along with that, this patch also fixes an ambiguity with the previous Reference::Kind values. The problem was that we wanted to reuse existing relocation type values as Reference::Kind values. But then how can the YAML write know how to convert a value to a string? The fix is to change the 32-bit Reference::Kind into a tuple with an 8-bit namespace (e.g. ELF, COFFF, etc), an 8-bit architecture (e.g. x86_64, PowerPC, etc), and a 16-bit value. This tuple system allows conversion to and from strings with no ambiguities. llvm-svn: 197727
* Remove dead code.Rui Ueyama2013-12-191-7/+0
| | | | llvm-svn: 197662
* [PECOFF] Truncate long section name.Rui Ueyama2013-12-171-5/+2
| | | | | | | Executable files do not use a string table, so section names longer than 8 characters are not permitted. Long section names should just be truncated. llvm-svn: 197470
* Remove obsolete comment.Rui Ueyama2013-12-161-2/+1
| | | | llvm-svn: 197375
* [PECOFF] Rename ExecutableWriter -> PECOFFWriter.Rui Ueyama2013-12-161-14/+14
| | | | | | Because it's now able to emit not only executable but DLL. llvm-svn: 197374
* [PECOFF] Add a check for duplicate export ordinals.Rui Ueyama2013-12-161-0/+12
| | | | llvm-svn: 197373
* [PECOFF] Support export-only-by-ordinal exports.Rui Ueyama2013-12-162-9/+16
| | | | | | | If NONAME option is given for an export, that symbol will be exported only by its ordinal. LLD will not emit the symbol name to the export table. llvm-svn: 197371
* [PECOFF] Set OrdinalBase field in the export table.Rui Ueyama2013-12-162-22/+36
| | | | | | | | | | OrdinalBase is an addend to the ordinals. We used to always set 1 to the field. Although it produced a valid a DLL export table, it'd be a waste if the first ordinal does not start with 1 -- we had to have NULL fields at the beginning of the export address table. By setting the ordinal base, we can eliminate the NULL fields. llvm-svn: 197367
* [PECOFF] Make it possible to specify export ordinals.Rui Ueyama2013-12-162-35/+75
| | | | | | | | | | | | | | | | You can specify exported function's ordinal by /export:func,@<number> command line option, but LLD ignored the option until now. This patch implements the feature. Ordinal is basically the index into the exported function address table. So, for example, if /export:foo,@42 is specified, the linker writes foo's address to 42th entry in the address table. Windows supports import-by-ordinal; you can not only import a function by name, but by its ordinal. If you want to allow your DLL users to import your functions by their ordinals, you need to make sure that your functions are always exported with the same ordinals. This is the feature for that situation. llvm-svn: 197364
* [Mips] Explicitly cast ulittle32_t to the uint32_t to fix Visual StudioSimon Atanasyan2013-12-151-1/+1
| | | | | | compile error. llvm-svn: 197344
* Linking of shared libraries for MIPS little-endian 32-bit target.Simon Atanasyan2013-12-1516-20/+917
| | | | | | | | | | | | | | | | | | | | | The following are the most significant peculiarities of MIPS target: - MIPS ABI requires some special tags in the dynamic table. - GOT consists of two parts local and global. The local part contains entries refer locally visible symbols. The global part contains entries refer global symbols. - Entries in the .dynsym section which have corresponded entries in the GOT should be: * Emitted at the end of .dynsym section * Sorted accordingly to theirs GOT counterparts - There are "paired" relocations. One or more R_MIPS_HI16 and R_MIPS_GOT16 relocations should be followed by R_MIPS_LO16 relocation. To calculate result of R_MIPS_HI16 and R_MIPS_GOT16 relocations we need to combine addends from these relocations and paired R_MIPS_LO16 relocation. The patch reviewed by Michael Spencer, Shankar Easwaran, Rui Ueyama. http://llvm-reviews.chandlerc.com/D2156 llvm-svn: 197342
* [PECOFF] Export undecorated symbols from DLL.Rui Ueyama2013-12-143-5/+25
| | | | | | | Symbol names exported from a DLL should be undecorated, not prefixed by an underscore ones. llvm-svn: 197307
* [PECOFF] Simplify EdataPass by sorting atoms from the beginning.Rui Ueyama2013-12-142-21/+11
| | | | llvm-svn: 197306
* [PECOFF] Parse /export optional arguments.Rui Ueyama2013-12-131-3/+3
| | | | | | | /EXPORT command line option can take an ordinal, NONAME flag, and DATA flag. This patch is to parse these optional arguments. llvm-svn: 197217
* Run clang-format on the new files.Rui Ueyama2013-12-132-22/+25
| | | | | | I should have run it before submitting but forgot to do that. Doing it now... llvm-svn: 197214
* [PECOFF] Align .edata fields on natural boundaries.Rui Ueyama2013-12-132-8/+11
| | | | | | | | The only data in .edata whose length varies is the string. This patch moves all the strings to the end of the section, so that 16-bit or 32-bit integers are aligned on correct boundaries. llvm-svn: 197213
* [PECOFF] Create .edata section for the DLL export table.Rui Ueyama2013-12-135-0/+229
| | | | | | | | | | | | | | | | This is the first patch to emit data for the DLL export table. The DLL export table is the data used by the Windows loader to find the address of exported function from DLL. With this patch, LLD is able to emit a valid DLL export table which the Windows loader can interpret and load. The data structure of the DLL export table is described in the Microsoft PE/COFF Specification, section 5.3. DLL support is not complete yet; the linker needs to emit an import library for a DLL, otherwise the linker cannot link against the DLL. We also do not support export-only-by-ordinal yet. llvm-svn: 197212
* [PECOFF] Rename lld::coff -> lld::pecoff.Rui Ueyama2013-12-1310-30/+25
| | | | | | We had lld::coff and lld::pecoff namespaces for no reason. Unify them. llvm-svn: 197201
* [PECOFF] Move a utility function used in a pass to Pass.cpp.Rui Ueyama2013-12-124-7/+54
| | | | | | | The file currently has only one function. Function that is useful both for IdataPass and EdataPass will be added to that file. llvm-svn: 197140
* [PECOFF] Replace DLLNameAtom with COFFStringAtom.Rui Ueyama2013-12-123-19/+28
| | | | | | | DLLNameAtom is an atom whose content is a string. IdataAtom is not going to be the only place we need such atom, so I want to generalize it. llvm-svn: 197137
* [PECOFF] Rename IdataPassFile and move it to Atoms.h.Rui Ueyama2013-12-122-19/+20
| | | | | | | | I'm planning to create a new pass for the DLL export table, and I want to use the class both from IdataPass and the new pass, EdataPass. So move the class to a common place. llvm-svn: 197132
* Run clang-format for PECOFF reader/writer code. No other changes.Rui Ueyama2013-12-117-65/+62
| | | | llvm-svn: 197039
* [PECOFF] Writer: Refactor the chunk class hierarchy.Rui Ueyama2013-12-111-99/+97
| | | | | | | | | | | | | | | | | | | | | | | | | | | Before this patch, we had the following class hierarchy. Chunk -> AtomChunk -> SectionChunk -> GenericSectionChunk -> BaseRelocChunk -> HeaderChunk Chunk represented the generic concept of contiguous range in an output file. AtomChunk represented a chunk consists of atoms. That class hierarchy had many issues: 1) BaseRelocChunk does not really consist of atoms, so inheriting from AtomChunk was plainly wrong, and 2) the hierarchy is unecessarily too deep. This patch correct them. The new hierachy is shown below. Chunk -> SectionChunk -> AtomChunk -> BaseRelocChunk -> HeaderChunk In the new hierarchy, AtomChunk represents a chunk consists of atoms. Other types of sections (currently only BaseRelocChunk) should inherit directly from SectionChunk. llvm-svn: 197038
* [PECOFF] Add "const" qualifiers to BaseRelocChunk methods.Rui Ueyama2013-12-111-7/+7
| | | | | | Also removed unused field. llvm-svn: 197027
* [PECOFF] Writer: Remove BaseRelocAtom.Rui Ueyama2013-12-111-32/+27
| | | | | | No functionality change. llvm-svn: 197025
* [PECOFF] Writer: Remove rawSize().Rui Ueyama2013-12-111-6/+4
| | | | | | | Because sections no longer have trailing NULL bytes, size() and rawSize() now return the same value. llvm-svn: 197020
* [PECOFF] Remove enum for Data Directory atom which no longer exist.Rui Ueyama2013-12-111-4/+2
| | | | llvm-svn: 197019
* [PECOFF] Remove code which is no longer needed because of r197016.Rui Ueyama2013-12-112-60/+6
| | | | llvm-svn: 197018
* [PECOFF] Refactor IdataPass.Rui Ueyama2013-12-115-113/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch is to basically move the functionality to construct Data Directory from IdataPass to WriterPECOFF. Data Directory is a part of the PE/COFF header and contains the addresses of the import tables. We used to represent the link from Data Directory to the import tables as relocation references. The idea behind it is that, because relocation references are processed by the Writer, we wouldn't have to do anything special to fill the addresses of the import tables. I thought that the addresses would be set "automatically". But it turned out that that design made the pass and the writer rather complicated. In order to make relocation references between Data Directory to the import tables, these data structures needed to be represented as Atom. However, because Data Directory is not a section content but a part of the PE/COFF header, it did not fit well as an Atom. So we ended up having complicated code both in IdataPass and the writer. This patch simplifies it. One side effect of this patch is that we now have ".idata.a", ".idata.d" and "idata.t" sections for the import address table, the import directory table, and the import lookup table. The writer looks for the sections by name to find the start addresses of the sections. We probably should have a better way to find a specific atom from the core linking result, but currently using the section name seems to be the easiest way to do that. The Windows loader do not care about the import table's section layout. llvm-svn: 197016
* Simplify code a bit. No functionality change.Rui Ueyama2013-12-111-5/+2
| | | | llvm-svn: 197009
* [PECOFF] Writer: Move SectionChunk's ctor inline.Rui Ueyama2013-12-111-5/+3
| | | | llvm-svn: 197008
* Use "static" instead of anonymous namespace.Rui Ueyama2013-12-111-5/+5
| | | | llvm-svn: 197007
* [PECOFF] Make a member functions non-virtual.Rui Ueyama2013-12-111-1/+1
| | | | llvm-svn: 197006
* [PECOFF] Writer: Remove NULL padding at the end of each section.Rui Ueyama2013-12-111-13/+4
| | | | | | | | If section size is not multiple of 512, the writer added NULL bytes at the end of it to make it so. That is not required by the PE/COFF spec, and the MSVC's linker does not do that too. So we don't need to do that, too. llvm-svn: 197002
* s/NULL/nullptr/Rui Ueyama2013-12-111-1/+1
| | | | llvm-svn: 196994
* [PECOFF] WriterPECOFF: Rename getCharacteristics -> computeCharacteristics.Rui Ueyama2013-12-111-7/+6
| | | | | | | The base class has a member function with the same name. We should avoid it being shadowed. llvm-svn: 196992
OpenPOWER on IntegriCloud