summaryrefslogtreecommitdiffstats
path: root/lld/lib/ReaderWriter/PECOFF
Commit message (Collapse)AuthorAgeFilesLines
...
* temporary commit.Rui Ueyama2014-05-091-0/+61
| | | | llvm-svn: 208427
* [PECOFF] Split LocallyImportedSymbolFile into two classes.Rui Ueyama2014-05-081-29/+36
| | | | | | | I have a plan to use VirtualArchiveFile in this file in the near future. This change should improve the readability by itself, too. llvm-svn: 208365
* Re-submit r207884: Remove dead codeRui Ueyama2014-05-051-1/+0
| | | | | | Differential Revision: http://reviews.llvm.org/D3599 llvm-svn: 207989
* Revert "Remove dead code."Rui Ueyama2014-05-021-0/+1
| | | | | | This reverts commit r207884 which was prematurely committed by accident. llvm-svn: 207886
* Remove dead code.Rui Ueyama2014-05-021-1/+0
| | | | | | | | | | | | | | | isAlias always returns false and no one is using it. It was originally added Atom to query if an atom is an alias for another atom, assuming that alias atoms are different from normal atoms. We now support atom aliasing, but the way that's implemented is in a different way than what isAlias assumed. An alias atom is just a regular defined atom with no content, and it has a layout- before edge to alias-to atom so that they are layed out at the same location in the result. So this is dead code, and it doesn't make much sense to keep it. llvm-svn: 207884
* [PECOFF] Support =internalName syntax in .def file.Rui Ueyama2014-05-022-2/+3
| | | | | | | | | | | Export definitions in a module definition file is as follows: exportedname[=internalname] [@ordinal [NONAME]] [PRIVATE] [DATA] Previously we did not support =internalname, so users couldn't export symbols from a DLL with a different name. llvm-svn: 207827
* [PECOFF] Drop stdcall's atsign suffix only.Rui Ueyama2014-05-011-2/+4
| | | | | | | You can omit @number suffix when specifying /export option, but you can do that only for stdcall functions. llvm-svn: 207809
* Fix FreeBSD buildbots.Rui Ueyama2014-05-011-1/+1
| | | | llvm-svn: 207802
* [PECOFF] Do not call addDllExport to mutate export descriptors.Rui Ueyama2014-05-011-4/+4
| | | | | | This is more efficient than before. llvm-svn: 207791
* [PECOFF] Fix exported symbol name.Rui Ueyama2014-05-012-3/+13
| | | | | | | | When creating a .lib file, we should strip the leading underscore, but should not strip stdcall atsign suffix. Otherwise produced .lib files cannot be linked. llvm-svn: 207729
* [PECOFF] Add a test for lib.exe subcommand.Rui Ueyama2014-05-011-18/+43
| | | | | | | | | | | | Previously the input file for the lib.exe command would be removed as soon as the command exits, so we couldn't write a test to check the file contents are correct. This patch adds /lldmoduledeffile: option to retain a copy of the temporary file at the given file path, so that you can see the file if you want. llvm-svn: 207727
* [PECOFF] Fix priority of locally imported symbols.Rui Ueyama2014-04-301-1/+2
| | | | | | | | | | | | | | | | Linker should create _imp_ symbols for local use only when such symbols cannot be resolved in any other way. If it overrides real imported symbols, such symbols remain virtually unresolved without error, causing odd issues. I observed that a program linked with LLD entered an infinite loop before reaching main() because of this issue. This patch moves the virtual file creating _imp_ symbols to the very end of the input file list. Previously, the file is at the end of the library file group. Linker might revisit the group many times, so it was not really at the end of the input file list. llvm-svn: 207605
* [PECOFF] /export accepts non-decorated symbols.Rui Ueyama2014-04-291-1/+8
| | | | | | | You usually have to specify the exact name of a symbol to export it, but for stdcall functions you can omit the @numbers suffix. llvm-svn: 207491
* [PECOFF] Fix _imp_ implicit symbols.Rui Ueyama2014-04-292-20/+88
| | | | | | | | | | | | | | | | | | | | | | | Implicit symbol for local use implemented in r207141 was not fully compatible with MSVC link.exe. In r207141, I implemented the feature in such way that implicit symbols are defined only when they are exported with /EXPORT option. After that I found that implicit symbols are defined not only for dllexported symbols but for all defined symbols. Actually _imp_ implicit symbols have no relationship with the dllexport feature. You could add _imp_ to any symbol to get a pointer to the symbol, whether the symbol is dllexported or not. It looks pretty weird to me but that's what we want if link.exe behaves that way. Here is a bit about the implementation: Creating all implicit symbols beforehand is going to be a huge waste of resource. This feature is rarely used, and MSVC link.exe even prints out a warning message when it finds this feature is being used. So we create implicit symbols on demand. There is an archive file that creates implicit symbols when they are needed. llvm-svn: 207476
* [PECOFF] Add /IMPLIB command line option.Rui Ueyama2014-04-252-7/+9
| | | | | | This option is to override the default import file path. llvm-svn: 207175
* [PECOFF] Assign unique ordinals to __imp_ symbols.Rui Ueyama2014-04-251-4/+10
| | | | llvm-svn: 207168
* [PECOFF] Do not copy-construct ExportDesc.Rui Ueyama2014-04-241-1/+1
| | | | llvm-svn: 207154
* [PECOFF] Define implicit symbols for exported ones.Rui Ueyama2014-04-241-0/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch is to fix a compatibility issue with MSVC link.exe as to use of dllexported symbols inside DLL. A DLL exports two symbols for a function. One is non-decorated one, and the other is with __imp_ prefix. The former is a function that you can directly call, and the latter is a pointer to the function. These dllexported symbols are created by linker for programs that link against the DLL. So, I naturally believed that __imp_ symbols become available when you once create a DLL and link against it, but they don't exist until then. And that's not true. MSVC link.exe is smart enough to allow users to use __imp_ symbols locally. That is, if a symbol is specified with /export option, it implicitly creates a new symbol with __imp_ prefix as a pointer to the exported symbol. This feature allows the following program to be linked and run, although _imp__hello is not defined in this code. #include <stdio.h> __declspec(dllexport) void hello(void) { printf("Hello\n"); } extern void (*_imp__hello)(void); int main() { _imp__hello(); return 0; } MSVC link.exe prints out the following warning when linking it. LNK4217: locally defined symbol _hello imported in function _main Using __imp_ symbols locally is I think not a good coding style. One should just take an address using "&" operator rather than appending __imp_ prefix. However, there are programs in the wild that depends on this link.exe's behavior, so we need this feature. llvm-svn: 207141
* [PECOFF] Allow symbols not starting with '_' in x86Rui Ueyama2014-04-241-1/+2
| | | | | | | | Not all symbols are decorated with an underscore in x86. You can write undecorated symbols in assembly, for example. Thus this assertion is too strong. llvm-svn: 207125
* [PECOFF] Skip IMAGE_SYM_DEBUG sections correctly.Rui Ueyama2014-04-221-6/+8
| | | | | | | | | We don't use sections with IMAGE_SYM_DEBUG attribute so we basically want to the symbols for them when reading symbol table. When we skip them, we need to skip auxiliary symbols too. Otherwise weird error would happen because aux symbols would be interpreted as regular ones. llvm-svn: 206931
* [Modules] Fix potential ODR violations by sinking the DEBUG_TYPEChandler Carruth2014-04-223-6/+6
| | | | | | | | | | definition below all of the header #include lines, LLD edition. IF you want to know more details about this, you can see the recent commits to Debug.h in LLVM. This is just the LLD segment of a cleanup I'm doing globally for this macro. llvm-svn: 206851
* [PECOFF] Fix common symbol alignment.Rui Ueyama2014-04-091-0/+8
| | | | | | Differential Revision: http://reviews.llvm.org/D3322 llvm-svn: 205826
* Rename getInputGraph() and getNextFile().Rui Ueyama2014-04-041-1/+2
| | | | | | | | | Seems getSomething() is more common naming scheme than just a noun to get something, so renaming these members. Differential Revision: http://llvm-reviews.chandlerc.com/D3285 llvm-svn: 205589
* Add empty() to atom_collection.Rui Ueyama2014-04-031-1/+1
| | | | | | | | | "x.empty()" is more idiomatic than "x.size() == 0". This patch is to add such method and use it in LLD. Differential Revision: http://llvm-reviews.chandlerc.com/D3279 llvm-svn: 205558
* Rename insertOneElementAt -> insertElementAt.Rui Ueyama2014-04-011-2/+1
| | | | | | | insertElementsAt() is removed, so "One" in insertOneElementAt() no longer make much sense. Rename it for brevity. llvm-svn: 205372
* [ELF] Support --defsym option to define an absolute symbol.Rui Ueyama2014-03-281-2/+3
| | | | | | | | | | | | | | | | | This patch is to support --defsym option for ELF file format/GNU-compatible driver. Currently it takes a symbol name followed by '=' and a number. If such option is given, the driver sets up an absolute symbol with the specified address. You can specify multiple --defsym options to define multiple symbols. GNU LD's --defsym provides many more features. For example, it allows users to specify another symbol name instead of a number to define a symbol alias, or it even allows a symbol plus an offset (e.g. --defsym=foo+3) to define symbol- relative alias. This patch does not support that, but will be supported in subsequent patches. Differential Revision: http://llvm-reviews.chandlerc.com/D3208 llvm-svn: 205029
* [PECOFF] Fix -Wsign-compare warning.Simon Atanasyan2014-03-191-1/+1
| | | | llvm-svn: 204223
* [PECOFF] Support yet another new type of weak symbol.Rui Ueyama2014-03-181-1/+3
| | | | | | | | | | COMDAT_SELECT_LARGEST is a COMDAT type that make linker to choose the largest definition from among all of the definition of a symbol. If the size is the same, the choice is arbitrary. Differential Revision: http://llvm-reviews.chandlerc.com/D3011 llvm-svn: 204172
* Fix lld buildAlexey Samsonov2014-03-181-12/+8
| | | | llvm-svn: 204122
* [PECOFF] Data type of SectionNumber is now unsigned (r203986).Rui Ueyama2014-03-151-4/+2
| | | | | | So we don't need static_cast's to convert it from signed to unsigned. llvm-svn: 203992
* [PECOFF] Handle large objects having more than 32768 sections.Rui Ueyama2014-03-141-2/+4
| | | | | | | The COFF spec says that the SectionNumber field in the symbol table is 16 bit signed type, but MSVC treats the field as if it is unsigned. llvm-svn: 203901
* Replace OwningPtr with std::unique_ptr.Ahmed Charles2014-03-132-7/+6
| | | | | | | | This results in some simplifications to the code where an OwningPtr had to be used with the previous api and then ownership moved to a unique_ptr for the rest of lld. llvm-svn: 203809
* [PECOFF] Handle objects with unknown machine type header value.Rui Ueyama2014-03-131-0/+3
| | | | | | | | | An object whose machine type header value is unknown looks a bit odd but is valid. If an object contains only machine-type-independent data, you can leave the type field unspecified. Some files in oldname.lib are such object files. llvm-svn: 203752
* [Cleanup] Sort includes.Ahmed Charles2014-03-121-6/+6
| | | | llvm-svn: 203666
* [PECOFF] Support a new type of weak symbol.Rui Ueyama2014-03-071-1/+3
| | | | | | | | | | | | | | | Summary: COMDAT_SELECT_SAME_SIZE is a COMDAT type that I presume exist only in COFF. The semantics of the type is that linker should merge such COMDAT sections if their sizes are the same. Otherwise it's an error. Reviewers: Bigcheese, shankarke, kledzik CC: llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D2996 llvm-svn: 203308
* Add "override" to member functions where appropriate.Rui Ueyama2014-03-059-116/+117
| | | | llvm-svn: 202998
* [PECOFF] Sort x64 exception handler table.Rui Ueyama2014-03-041-4/+34
| | | | | | | | | Just like x86 exception handler table, the table for x64 needs to be sorted so that runtime can binary search on it. Unlike x86, the table entry for x64 has multiple fields, and they need to be sorted according to its BeginAddress field. This patch also fixes a bug in relocations. llvm-svn: 202874
* [C++11] Work around an incompatibility between llvm::tie and std::tie.Benjamin Kramer2014-03-021-1/+1
| | | | llvm-svn: 202645
* [C++11] Switch from LLVM_FINAL to just "final" now that all of LLVM isChandler Carruth2014-03-021-1/+1
| | | | | | requiring MSVC 2012 or newer. llvm-svn: 202626
* [PECOFF] Sort SEH table entries according to its value.Rui Ueyama2014-02-281-0/+21
| | | | | | | | | It looks like the contents of the table need to be sorted according to its value, so that the runtime can find the entry by binary search. I'm not 100% sure if we really have to do that, but at least I can say it's safe to do because the contents of .sxdata is just a list of exception handlers' RVAs. llvm-svn: 202550
* [PECOFF] Set "Exception Table" field in PE32+ header.Rui Ueyama2014-02-281-0/+3
| | | | llvm-svn: 202527
* [PECOFF] Add a test for /SAFESEH:NO for non-x86 machine type.Rui Ueyama2014-02-271-0/+7
| | | | llvm-svn: 202322
* [PECOFF] Emit Load Configuration and SEH Table for x86.Rui Ueyama2014-02-266-4/+206
| | | | | | | | | | | | | | | | | | | | | | | | | | If all input files are compatible with Structured Exception Handling, linker is supposed to create an exectuable with a table for SEH handlers. The table consists of exception handlers entry point addresses. The basic idea of SEH in x86 Microsoft ABI is to list all valid entry points of exception handlers in an read-only memory, so that an attacker cannot override the addresses in it. In x86 ABI, data for exception handling is mostly on stack, so it's volnerable to stack overflow attack. In order to protect against it, Windows runtime uses the table to check a return address, to ensure that the address is really an valid entry point for an exception handler. Compiler emits a list of exception handler functions to .sxdata section. It also emits a marker symbol "@feat.00" to indicate that the object is compatible with SEH. SEH is a relatively new feature for COFF, and mixing SEH-compatible and SEH-incompatible objects will result in an invalid executable, so is the marker. If all input files are compatible with SEH, LLD emits a SEH table. SEH table needs to be pointed by Load Configuration strucutre, so when emitting a SEH table LLD emits it too. The address of a Load Configuration will be stored to the file header. llvm-svn: 202248
* [PECOFF] Add a utility function to add DIR32 relocation.Rui Ueyama2014-02-262-4/+16
| | | | llvm-svn: 202217
* [PECOFF] Fix DLLCharacteristics field.Rui Ueyama2014-02-261-1/+3
| | | | | | IMAGE_DLL_CHARACTERISTICS_NO_SEH flag should be set only when SEH is disabled. llvm-svn: 202215
* [COFF] Refactor .drectve section handling. No functionality change.Rui Ueyama2014-02-251-7/+18
| | | | llvm-svn: 202113
* [lld] Include reference kind in cycle detector debug outputNico Rieck2014-02-241-1/+1
| | | | | | | | This restores the debug output to how it was before r197727 broke it. This went undetected because the corresponding test was never run due to broken feature detection. llvm-svn: 202079
* [PECOFF] Fix uninitialized variableNico Rieck2014-02-231-1/+2
| | | | llvm-svn: 201970
* [PECOFF] Implement /SAFESEH option.Rui Ueyama2014-02-211-4/+24
| | | | | | | LLD now prints an error message if /SAFESEH option is specified and one or more input files are not compatible with SEH. llvm-svn: 201900
* Update for llvm api change.Rafael Espindola2014-02-101-4/+4
| | | | llvm-svn: 201109
OpenPOWER on IntegriCloud