summaryrefslogtreecommitdiffstats
path: root/lld
Commit message (Collapse)AuthorAgeFilesLines
...
* Use a stricter return type in buildSectionOrder. NFC.Rafael Espindola2018-02-141-9/+10
| | | | | | | | | | We sort inside output sections, so all the sections we see should be InputSectionBase. I noticed the patch adding callgraph based section ordering used this type and changing this separately makes the merge easier. llvm-svn: 325094
* Use toString to stringize sections and files.Rui Ueyama2018-02-1311-36/+34
| | | | | | Differential Revision: https://reviews.llvm.org/D43251 llvm-svn: 325065
* Use LLVM's SetVector insteead of unordered_set.Rui Ueyama2018-02-131-3/+2
| | | | | | | | | SetVector guarantees ordering, so with that we can get a deterministic output for error messages. Differential Revision: https://reviews.llvm.org/D43254 llvm-svn: 325064
* [LLD] Implement /guard:[no]longjmpReid Kleckner2018-02-1310-28/+159
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This protects calls to longjmp from transferring control to arbitrary program points. Instead, longjmp calls are limited to the set of registered setjmp return addresses. This also implements /guard:nolongjmp to allow users to link in object files that call setjmp that weren't compiled with /guard:cf. In this case, the linker will approximate the set of address taken functions, but it will leave longjmp unprotected. I used the following program to test, compiling it with different -guard flags: $ cl -c t.c -guard:cf $ lld-link t.obj -guard:cf #include <setjmp.h> #include <stdio.h> jmp_buf buf; void g() { printf("before longjmp\n"); fflush(stdout); longjmp(buf, 1); } void f() { if (setjmp(buf)) { printf("setjmp returned non-zero\n"); return; } g(); } int main() { f(); printf("hello world\n"); } In particular, the program aborts when the code is compiled *without* -guard:cf and linked with -guard:cf. That indicates that longjmps are protected. Reviewers: ruiu, inglorion, amccarth Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D43217 llvm-svn: 325047
* [WebAssembly] Unify concepts of discarded and non-live input chunks. NFC.Sam Clegg2018-02-133-12/+9
| | | | | | | | | It seems redundant to store this information twice. None of the locations where this bit is checked care about the distinction. Differential Revision: https://reviews.llvm.org/D43250 llvm-svn: 325046
* [WebAssembly] Cleanup methods for add synthetic symbols to symbtab. NFC.Sam Clegg2018-02-133-35/+31
| | | | | | | | | | | | These were duplicating (incorrectly) some of the logic for handling conflicts, but since they are only ever added right at the start we can assume no existing symbols. Also rename these methods for clarity. Differential Revision: https://reviews.llvm.org/D43252 llvm-svn: 325045
* Fix coding style error.Rui Ueyama2018-02-131-3/+3
| | | | llvm-svn: 325038
* Use reinterpret_cast<> instead of C-style cast. NFC.Rui Ueyama2018-02-132-3/+3
| | | | | | | | It is currently interpreted as reinterpret_cast<>. Make it explicit. Differential Revision: https://reviews.llvm.org/D43247 llvm-svn: 325033
* Check that Symbol types are trivially destructibleSam Clegg2018-02-132-0/+4
| | | | | | | | | | | | | | This adds an extra level of static safety to our use of placement new to allocate Symbol types. It prevents the accidental addition on a non-trivially-destructible member that could allocate and leak memory. From the spec: Storage occupied by trivially destructible objects may be reused without calling the destructor. Differential Revision: https://reviews.llvm.org/D43244 llvm-svn: 325025
* Use RelType in a few more places. NFC.Rafael Espindola2018-02-132-4/+4
| | | | llvm-svn: 325017
* Add a simpler version of addReloc. NFC.Rafael Espindola2018-02-133-19/+24
| | | | | | Extracted from a patch by Alexander Richardson! llvm-svn: 325016
* Add REQUIRES: zlib to gdb-index.s testReid Kleckner2018-02-131-1/+1
| | | | llvm-svn: 324978
* Do not use Decompressor::isCompressedELFSection. NFC.Rui Ueyama2018-02-121-1/+3
| | | | | | | | | In order to identify a compressed section, we check if a section name starts with ".zdebug" or the section has SHF_COMPRESSED flag. We already use the knowledge in this function. So hiding that check in isCompressedELFSection doesn't make sense. llvm-svn: 324951
* Remove 'z' in .zdebug when decompressing a section.Rui Ueyama2018-02-124-31/+47
| | | | | | | | | | | When decompressing a compressed debug section, we drop SHF_COMPRESSED flag but we didn't drop "z" in ".zdebug" section name. This patch does that for consistency. This change also fixes the issue that .zdebug_gnu_pubnames are not dropped when we are creating a .gdb_index section. llvm-svn: 324949
* s/uncompress/decompress/g.Rui Ueyama2018-02-124-12/+12
| | | | | | | In lld, we use both "uncompress" and "decompress" which is confusing. Since LLVM uses "decompress", we should use the same term. llvm-svn: 324944
* Fixed extra ‘;’ warningGalina Kistanova2018-02-111-1/+1
| | | | llvm-svn: 324830
* Use RelType instead of uint32_t in DynamicReloc. NFCAlexander Richardson2018-02-101-2/+2
| | | | llvm-svn: 324821
* Make a lambda a static function to make the ICF main function shorter.Rui Ueyama2018-02-091-11/+9
| | | | llvm-svn: 324756
* Do not print out removed ICF sections for -verbose.Rui Ueyama2018-02-0910-22/+17
| | | | | | | | | | | GNU gold doesn't print out ICF sections for -verbose. It only shows them for -print-icf-sections. We printed out them for -verbose because we didn't have -print-icf-sections. Now that we have the option, there's no reason to print out for -verbose. Differential Revision: https://reviews.llvm.org/D43100 llvm-svn: 324755
* Make --export-dynamic-symbol to pull out object files from archives.Rui Ueyama2018-02-093-1/+35
| | | | | | | | | | | | | | This is for compatiblity with GNU gold. GNU gold tries to resolve symbols specified by --export-dynamic-symbol. So, if a symbol specified by --export-dynamic-symbol is in an archive file, lld's result is currently different from gold's. Interestingly, that behavior is different for --dynamic-list. I added a new test to ensure that. Differential Revision: https://reviews.llvm.org/D43103 llvm-svn: 324752
* Refactor how we decide which sections to sort.Rafael Espindola2018-02-091-28/+33
| | | | | | | | | | | | | This is a bit more verbose, but it has a few advantages. The logic on what to do with special sections like .init_array is not duplicated. Before we would need keep isKnownNonreorderableSection in sync. I think with this the call graph based sorting can be implemented by "just" returning a new order from buildSectionOrder. llvm-svn: 324744
* Add IMPLEMENTATION NOTES describing lld's .a handling in the man pageEd Maste2018-02-091-1/+42
| | | | | | | | This content is based on the description in NewLLD.rst. Differential Revision: https://reviews.llvm.org/D43072 llvm-svn: 324739
* [WebAssebmly] Remvoe trailing semicolon. NFC.Sam Clegg2018-02-091-1/+1
| | | | llvm-svn: 324716
* [WebAssembly] Remove redundant check global output indexSam Clegg2018-02-091-1/+1
| | | | llvm-svn: 324715
* Remove redundant semicolon.Rui Ueyama2018-02-091-1/+1
| | | | llvm-svn: 324698
* Rename confusing variable names in a test.Rui Ueyama2018-02-091-9/+9
| | | | | | "%tar" looks like a tar archive, but it's actually an .a archive. llvm-svn: 324692
* Use log to print out a verbose message.Rui Ueyama2018-02-094-8/+8
| | | | llvm-svn: 324688
* Remove Config->Verbose because we have errorHandler().Verbose.Rui Ueyama2018-02-084-7/+7
| | | | llvm-svn: 324684
* Fix --print-icf-sections output.Rui Ueyama2018-02-081-1/+1
| | | | | | | Previously, multiple chunks of --print-icf-sections messages were interleaved and didn't make sense. This is because forEachClass is multi-threaded. llvm-svn: 324683
* [ELF] Don't sort non reorderable sections with --symbol-ordering-fileMichael J. Spencer2018-02-082-1/+22
| | | | | | Differential Revision: https://reviews.llvm.org/D43038 llvm-svn: 324656
* Symbols defined in linker scripts should not have dso_local flag set in LTO ↵Dmitry Mikulin2018-02-082-3/+7
| | | | | | | | resolutions. Differential Revision: https://reviews.llvm.org/D43051 llvm-svn: 324559
* Document --build-id=fast in ld.lld.1Ed Maste2018-02-071-1/+6
| | | | | | | | | | Initial ld.lld.1 man page commit in r324512 crossed paths with r324502 which added --build-id=fast, allowing --build-id to be documented as a synonym for --build-id=fast. Catch up with that change in the man page. Differential Revision: https://reviews.llvm.org/D43039 llvm-svn: 324528
* Add ld.lld.1 man page, describing lld's ELF linkerEd Maste2018-02-071-0/+479
| | | | | | | | | | | | | | | One of the FreeBSD requirements for enabling lld as the system linker is that it has a man page. Other FreeBSD developers and I created one using lld's --help output as a starting point. This is an expanded and improved version of that. This man page would benefit from additional content, but it provides basic user-facing coverage of lld's options and serves as a good starting point. Differential Revision: https://reviews.llvm.org/D42963 llvm-svn: 324512
* Add --build-id=fast as a synonym for --build-id.Rui Ueyama2018-02-072-0/+4
| | | | | | | | | | | | When you omit an argument, most options fall back to their defaults. For example, --color-diagnostics is a synonym for --color-diagnostics=auto. We don't have a way to specify the default choice for --build-id, so we can't describe --build-id (without an argument) in that way. This patch adds "fast" for the default build-id choice. Differential Revision: https://reviews.llvm.org/D43032 llvm-svn: 324502
* [ELF][MIPS] Mark the test as required MIPS target support. NFCSimon Atanasyan2018-02-071-0/+2
| | | | llvm-svn: 324468
* [ELF][MIPS] Ignore incorrect version definition index for _gp_disp symbolSimon Atanasyan2018-02-074-0/+35
| | | | | | | | | | | | MIPS BFD linker puts _gp_disp symbol into DSO files and assigns zero version definition index to it. This value means 'unversioned local symbol' while _gp_disp is a section global symbol. We have to handle this bug in the LLD because BFD linker is used for building MIPS toolchain libraries. Differential revision: https://reviews.llvm.org/D42486 llvm-svn: 324467
* [ELF] - Fix BB after r324463.George Rimar2018-02-071-1/+1
| | | | | | Test requires arm, but specified x86. llvm-svn: 324464
* [ELF] - Remove unused synthetic sections correctly.George Rimar2018-02-073-15/+22
| | | | | | | | | | | | | | | | This is PR35740 which now crashes because we remove unused synthetic sections incorrectly. We can keep input section description and corresponding output section live even if it must be empty and dead. This results in a crash because SHF_LINK_ORDER handling code tries to access first section which is nullptr in this case. Patch fixes the issue. Differential revision: https://reviews.llvm.org/D42681 llvm-svn: 324463
* [ELF] - Make defsym to work correctly with reserved symbols.George Rimar2018-02-072-1/+31
| | | | | | | | | | | | Previously --defsym=foo2=etext+2 would produce incorrect value for foo2 because expressions did not work correctly with reserved symbols, section offset was calculated wrong for them. Fixes PR35744. Differential revision: https://reviews.llvm.org/D42911 llvm-svn: 324461
* [ELF] - Allow set CPU string with -plugin-opt=mcpu=<xxx>George Rimar2018-02-073-7/+9
| | | | | | | | | | | | | | Previously we ignored -plugin-opt=mcpu=<xxx> and the only way to set CPU string was to pass -mllvm -mcpu=<xxx> Though clang may pass it with use of plugin options: -plugin-opt=mcpu=x86-64 Since we are trying to be compatible in command line with gold plugin, seems we should support it too. Differential revision: https://reviews.llvm.org/D42956 llvm-svn: 324459
* [ELF] - Add testcase for -debugger-tune=<value>George Rimar2018-02-071-0/+35
| | | | | | | | | | | | | In D42733 we supported different LTO command line options, including -debugger-tune=<value>. Initially debugger-tune support was needed to fix PR36035. Patch adds testcase for this option to check we don't simply ignore it. Differential revision: https://reviews.llvm.org/D42961 llvm-svn: 324457
* [WebAssembly] Add __data_end link-sythentic symbol.Sam Clegg2018-02-0716-2/+104
| | | | | | | | | | | | | | This is similar to _end (See https://linux.die.net/man/3/edata for more) but using our own unique name since our use cases will most likely be different and we want to keep our options open WRT to memory layout. This change will allow is to remove the DataSize from the linking metadata section which is currently being used by emscripten to derive the end of the data. Differential Revision: https://reviews.llvm.org/D42867 llvm-svn: 324443
* Don't set dso_local flag in LTO resolutions for absolute symbols defined in ELFDmitry Mikulin2018-02-073-1/+23
| | | | | | | | | objects, it confuses codegen into generating pc-rel relocations for those symbols, which leads to linker errors. Differential Revision: https://reviews.llvm.org/D42977 llvm-svn: 324435
* Make sure that --no-check-sections doesn't print out warning messages.Rui Ueyama2018-02-071-2/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D42988 llvm-svn: 324434
* Simplify libtool compatibility hack.Rafael Espindola2018-02-071-7/+1
| | | | | | | | | | | | | I tested that if I remove "elf" from the message, building a program that uses libtool prints checking whether to build shared libraries... no but with this patch it still prints checking whether to build shared libraries... yes llvm-svn: 324428
* Convert a use of Config->Static.Rafael Espindola2018-02-062-2/+6
| | | | | | | | | | In lld this was the only use of Config->Static where it meant anything else other than "use .a instead of .so". If a program turns out to not use any dynamic libraries, we should produce the same result with and without -static. llvm-svn: 324421
* Store just argv[0] in Config.Rafael Espindola2018-02-064-9/+9
| | | | | | | Having the full argv there seems in conflict with the desire to parse all command line options in the Driver. llvm-svn: 324418
* Hide the --full-shutdown option.Rafael Espindola2018-02-062-1/+2
| | | | llvm-svn: 324365
* [COFF] LTO does not require a disassembler.Benjamin Kramer2018-02-061-1/+0
| | | | llvm-svn: 324355
* [ELF] - Re-commit r324322 "Use ↵George Rimar2018-02-062-17/+16
| | | | | | | | | | | | | | | | | | | | | | | | | InitTargetOptionsFromCodeGenFlags/ParseCommandLineOptions for parsing LTO options.". With fix: Keep logic that ignores -plugin-opt=mcpu=x86-64 -plugin-opt=thinlto, add checks for those to testcases. Original commit message: [ELF] - Use InitTargetOptionsFromCodeGenFlags/ParseCommandLineOptions for parsing LTO options. gold plugin uses InitTargetOptionsFromCodeGenFlags + ParseCommandLineOptions for parsing LTO options. Patch do the same change for LLD. Such change helps to avoid parsing/whitelisting LTO plugin options again on linker side, what can help LLD to automatically support new -plugin-opt=xxx options passed. Differential revision: https://reviews.llvm.org/D42733 llvm-svn: 324340
OpenPOWER on IntegriCloud