summaryrefslogtreecommitdiffstats
path: root/lld/ELF
Commit message (Collapse)AuthorAgeFilesLines
...
* [PPC64] Add support for local-exec TLS modelZaara Syeda2018-06-083-2/+46
| | | | | | | | | | | | | | | | | | | This patch adds the relocations needed support the local-exec TLS model: R_PPC64_TPREL16 R_PPC64_TPREL16_HA R_PPC64_TPREL16_LO R_PPC64_TPREL16_HI R_PPC64_TPREL16_DS R_PPC64_TPREL16_LO_DS R_PPC64_TPREL16_HIGHER R_PPC64_TPREL16_HIGHERA R_PPC64_TPREL16_HIGHEST R_PPC64_TPREL16_HIGHESTA Differential Revision: https://reviews.llvm.org/D47598 llvm-svn: 334304
* Expand comments.Rui Ueyama2018-06-081-6/+27
| | | | llvm-svn: 334250
* [ThinLTO/lld] Document constant bool ModuleSummaryIndex parameter (NFC)Teresa Johnson2018-06-061-1/+1
| | | | | | Makes this consistent with other ModuleSummaryIndex constructor calls. llvm-svn: 334141
* Correct aligment computation for shared object symbols.Han Shen2018-06-062-7/+3
| | | | | | | | | | The original computation for shared object symbol alignment is wrong when st_value equals 0. It is very unusual for dso symbols to have st_value equal 0. But when it happens, it causes obscure run time bugs. Differential Revision: https://reviews.llvm.org/D47602 llvm-svn: 334135
* Do not show unrelated "-m is missing" error message.Rui Ueyama2018-06-051-0/+3
| | | | | | | | | | | | | | Previously, "-m is missing" error message is shown if you pass a nonexistent file or don't pass any file at all to lld, as shown below: $ ld.lld nonexistent.o ld.lld: error: cannot open nonexistent.o: No such file or directory ld.lld: error: target emulation unknown: -m or at least one .o file required This patch eliminates the second error message because it's not related and even inaccurate (you passed a .o file though it didn't exist). llvm-svn: 334024
* [ELF] - Also use DW_AT_linkage_name when gathering information about ↵George Rimar2018-06-041-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | variables for error messages. Currently, when LLD do a lookup for variables location, it uses DW_AT_name attribute. That is not always enough. Imagine code: namespace A { int bar = 0; } namespace Z { int bar = 1; } int hoho; In this case there are 3 variables and their debug attributes are following: A::bar has: DW_AT_name [DW_FORM_string] ("bar") DW_AT_linkage_name [DW_FORM_strp] ( .debug_str[0x00000006] = "_ZN1A3barE") Z::bar has: DW_AT_name [DW_FORM_string] ("bar") DW_AT_linkage_name [DW_FORM_strp] ( .debug_str[0x0000003f] = "_ZN1Z3barE") hoho has: DW_AT_name [DW_FORM_strp] ( .debug_str[0x0000004a] = "hoho") and has NO DW_AT_linkage_name attribute. Because it would be the same as DW_AT_name and DWARF producers avoids emiting excessive data. Hence LLD should also use DW_AT_linkage_name when it is available. (currently, LLD fails to report location correctly because thinks that A::bar and Z::bar are the same things) Differential revision: https://reviews.llvm.org/D47373 llvm-svn: 333880
* ELF: Ignore argument after --plugin.Peter Collingbourne2018-06-011-1/+1
| | | | | | | | | | | | | | Clang passes --plugin /path/to/LLVMgold.so to the linker when -flto is passed. After r333607 we only ignore --plugin as a joined argument, which means that the following argument (/path/to/LLVMgold.so) is interpreted as an input file. This means that either every LTO'd program ends up being linked with the gold plugin or we error out if the plugin does not exist. The fix is to use Eq to ignore both --plugin=foo and --plugin foo as before. Differential Revision: https://reviews.llvm.org/D47657 llvm-svn: 333793
* Show choices of multiple-choice options in `ld.lld --help` message.Rui Ueyama2018-06-011-13/+17
| | | | | | Differential Revision: https://reviews.llvm.org/D47656 llvm-svn: 333792
* [PPC64] Add support for initial-exec TLS modelZaara Syeda2018-06-011-0/+12
| | | | | | | | | | | | | This patch adds the relocations needed support the initial-exec TLS model: R_PPC64_GOT_TPREL16_HA R_PPC64_GOT_TPREL16_LO_DS R_PPC64_GOT_TPREL16_DS R_PPC64_GOT_TPREL16_HI R_PPC64_TLS Differential Revision: https://reviews.llvm.org/D47455 llvm-svn: 333769
* Print out "Alias for -foo" instead of repeating the same help message for -foo.Rui Ueyama2018-05-311-47/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since aliases don't actually need name, I removed it from Options.td to keep the definitions concise. Before: -( Ignored for compatibility with GNU unless you pass --warn-backrefs -) Ignored for compatibility with GNU unless you pass --warn-backrefs --allow-multiple-definition Allow multiple definitions --apply-dynamic-relocs Apply dynamic relocations to place --as-needed Only set DT_NEEDED for shared libraries if used --auxiliary=<value> Set DT_AUXILIARY field to the specified name --Bdynamic Link against shared libraries --Bshareable Build a shared object ... After: -( Alias for --start-group -) Alias for --end-group --allow-multiple-definition Allow multiple definitions --apply-dynamic-relocs Apply dynamic relocations to place --as-needed Only set DT_NEEDED for shared libraries if used --auxiliary=<value> Set DT_AUXILIARY field to the specified name --Bdynamic Link against shared libraries (default) --Bshareable Alias for --shared ... Differential Revision: https://reviews.llvm.org/D47588 llvm-svn: 333694
* Fix rpath-link handlingTaiju Tsuiki2018-05-311-1/+1
| | | | | | | | | | | | | | | | Summary: After r333596, rpath-link no longer consumes the following argument, and the path argument left by it confuses LLD. Reviewers: espindola, ruiu Reviewed By: ruiu Subscribers: ruiu, emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D47591 llvm-svn: 333686
* [PPC64] Support R_PPC64_GOT_TLSLD16 relocations.Sean Fertile2018-05-314-1/+14
| | | | | | | | | Add support for the R_PPC64_GOT_TLSLD16 relocations used to build the address of the tls_index struct used in local-dynamic tls. Differential Revision: https://reviews.llvm.org/D47538 llvm-svn: 333681
* Rename R_TLSGD/R_TLSLD to add _GOT_FROM_END. NFC.Sean Fertile2018-05-314-13/+14
| | | | | | | | | getRelocTargetVA for R_TLSGD and R_TLSLD RelExprs calculate an offset from the end of the got, so adjust the names to reflect this. Differential Revision: https://reviews.llvm.org/D47379 llvm-svn: 333674
* Remove name from unused options. NFC.Rui Ueyama2018-05-311-22/+22
| | | | | | This change makes it impossible to use these options in code. llvm-svn: 333655
* Fix formatting. NFC.Rui Ueyama2018-05-311-5/+5
| | | | llvm-svn: 333654
* Attempt to fix a buildbot.Rui Ueyama2018-05-311-1/+1
| | | | | | | Broken buildbot log: http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/30855/steps/build/logs/stdio llvm-svn: 333648
* Fix a wrong `ld.lld --help` message.Rui Ueyama2018-05-311-1/+1
| | | | llvm-svn: 333647
* Implement --{push,pop}-state.Rui Ueyama2018-05-312-0/+21
| | | | | | | | | | | | | | | | | | | | --push-state implemented in this patch saves the states of --as-needed, --whole-archive and --static. It saves less number of flags than GNU linkers. Since even GNU linkers save different flags, no one seems to care about the details. In this patch, I tried to save the minimal number of flags to not complicate the implementation and the siutation. I'm not personally happy about adding the --{push,pop}-state flags though. That options seem too hacky to me. However, gcc started using the options since GCC 8 when GNU ld is available at the build time. Therefore, lld is no longer a drop-in replacmenet for GNU linker for that machine without supporting the flags. Fixes https://bugs.llvm.org/show_bug.cgi?id=34567 Differential Revision: https://reviews.llvm.org/D47542 llvm-svn: 333646
* Add "(default)" to default optionsRui Ueyama2018-05-301-24/+24
| | | | | | | | This improves the help message shown for `ld.lld --help`. Differential Revision: https://reviews.llvm.org/D47562 llvm-svn: 333607
* Simplify `ld.lld --help` message.Rui Ueyama2018-05-301-79/+67
| | | | | | | | | | | | | | | | | | | | Previously, we printed out two lines of help messages for `--foo bar` and `--foo=bar` like this: --soname=<value> Set DT_SONAME --soname <value> Set DT_SONAME --sort-section=<value> Specifies sections sorting rule when linkerscript is used --sort-section <value> Specifies sections sorting rule when linkerscript is used This change eliminates duplicate lines that doesn't contain `=` for such options like this. --soname=<value> Set DT_SONAME --sort-section=<value> Specifies sections sorting rule when linkerscript is used Differential Revision: https://reviews.llvm.org/D47558 llvm-svn: 333596
* [ELF] Group LTO options together. NFC.Sam Clegg2018-05-301-3/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D47512 llvm-svn: 333505
* [PPC64] Support General-Dynamic tls.Sean Fertile2018-05-294-4/+21
| | | | | | | | | Adds handling of all the relocation types for general-dynamic thread local storage. Differential Revision: https://reviews.llvm.org/D47325 llvm-svn: 333420
* Fix retpoline PLT for x86-64 when used for >4GB address.Rui Ueyama2018-05-251-1/+1
| | | | | | Previously, we wrote only the least significant 32 bits. llvm-svn: 333313
* Add a comment for retpoline PLT.Rui Ueyama2018-05-251-0/+9
| | | | llvm-svn: 333312
* Fix a bug that we truncated GOTPLT entries to 32 bits.Rui Ueyama2018-05-251-1/+1
| | | | llvm-svn: 333294
* [PPC64] Set the IRelative relocation type.Sean Fertile2018-05-241-0/+1
| | | | | | | Set the IRelative relocation type and extend the related test to verify. Differential Revision: https://reviews.llvm.org/D46877 llvm-svn: 333203
* [PPC64] Add .toc section after .got sectionZaara Syeda2018-05-241-2/+9
| | | | | | | | | | | | | | | | | | | | PPC64 maintains a compiler managed got in the .toc section. When accessing a global variable through got-indirect access, a .toc entry is created for the variable. The relocation for the got-indirect access will refer to the .toc section rather than the symbol that is actually accessed. The .toc entry contains the address of the global variable. We evaluate the offset from r2 (which is the TOC base) to the address of the toc entry for the global variable. Currently, the .toc is not near the .got. This causes errors because the offset from r2 to the toc section is too large. The linker needs to add all the .toc input sections to the .got output section, merging the compiler managed got with the linker got. This ensures that the offsets from the TOC base to the toc entries are not too large. This patch puts the .toc section right after the .got section. Differential Revision: https://reviews.llvm.org/D45833 llvm-svn: 333199
* Revert "[ELF] Simplify. NFC"Fangrui Song2018-05-231-2/+2
| | | | | | This reverts commit cc6f052261096dc9d4c9d3123e37b023c3e171df. llvm-svn: 333099
* ELF: Do not ICF sections named with a C identifier.Peter Collingbourne2018-05-231-0/+6
| | | | | | | | | | A user program may enumerate sections named with a C identifier using __start_* and __stop_* symbols. We cannot ICF any such sections because that could change program semantics. Differential Revision: https://reviews.llvm.org/D47242 llvm-svn: 333054
* ELF: Do not ICF two sections with different output sections.Peter Collingbourne2018-05-235-4/+12
| | | | | | | | | | Note that this doesn't do the right thing in the case where there is a linker script. We probably need to move output section assignment before ICF to get the correct behaviour here. Differential Revision: https://reviews.llvm.org/D47241 llvm-svn: 333052
* ELF: Allow ICF on .data.rel.ro sections.Peter Collingbourne2018-05-221-2/+7
| | | | | | Differential Revision: https://reviews.llvm.org/D47234 llvm-svn: 333040
* Code cleanup in preparation for adding LTO for wasm. NFC.Sam Clegg2018-05-222-29/+8
| | | | | | | | | | | | | | - Move some common code into Common/rrorHandler.cpp and Common/Strings.h. - Don't use `fatal` when incompatible bitcode files are encountered. - Rename NameRef variable to just Name See D47162 Differential Revision: https://reviews.llvm.org/D47206 llvm-svn: 333021
* Move code to improve readability. NFC.Rui Ueyama2018-05-221-1/+1
| | | | llvm-svn: 332995
* Simplify. NFC.Rui Ueyama2018-05-221-9/+5
| | | | | | We can directly assign to a std::pair without std::tie. llvm-svn: 332994
* [ELF] Simplify. NFCFangrui Song2018-05-221-2/+2
| | | | llvm-svn: 332952
* Handle --plugin-opt= options as alias options.Rui Ueyama2018-05-223-54/+77
| | | | | | | | | | Previously, we had a loop to iterate over options starting with `--plugin-opt=` and parse them by hand. But we can make OptTable do that job for us. Differential Revision: https://reviews.llvm.org/D47167 llvm-svn: 332935
* Fix typo.Rui Ueyama2018-05-211-1/+2
| | | | llvm-svn: 332859
* [ELF] Update due to API change in .debug_line parsingJames Henderson2018-05-211-3/+6
| | | | | | | | | | See r332845. Reviewed by: grimar Differential Revision: https://reviews.llvm.org/D46832 llvm-svn: 332846
* Mitigate relocation overflow [part 2 of 2]Han Shen2018-05-181-7/+19
| | | | | | | | | _init_array_start/end are placed at 0 if no ".init_array" presents, this causes .text relocation against them become more prone to overflow. This CL sets ".init_array" address to that of ".text" to mitigate the situation. Review: https://reviews.llvm.org/D46200 llvm-svn: 332688
* Fix typo in error message.Rui Ueyama2018-05-171-1/+1
| | | | llvm-svn: 332658
* Make ALIGN work with -r in linker scriptsRui Ueyama2018-05-171-4/+5
| | | | | | | | | | | | Patch by Mark Kettenis. Make ALIGN work in linker scripts used with the -r option. This works in GNU ld (ld.bfd) and is used to generate the "random gap" object for linking the OpenBSD kernel. Differential Revision: https://reviews.llvm.org/D46839 llvm-svn: 332656
* Improve error message for -thinlto-object-suffix-replace and simplify code.Rui Ueyama2018-05-174-48/+51
| | | | llvm-svn: 332643
* [ELF] - Do not crash when do --gc-sections for non-allocatable metadata ↵George Rimar2018-05-171-4/+10
| | | | | | | | | | | | | | | | sections. Currently, LLD marks all non-allocatable sections except SHF_REL[A] as Live when doing GC. This can be a reason of the crash when SHF_LINK_ORDER sections are involved, because their parents can be dead. We should do GC for them correctly. The patch implements it. Differential revision: https://reviews.llvm.org/D46880 llvm-svn: 332589
* [ELF] PowerOpen ABI -> Power Architecture 64-bit v2 ABI. NFCFangrui Song2018-05-171-5/+6
| | | | | | | | | | Reviewers: sfertile, espindola Subscribers: emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D46904 llvm-svn: 332572
* Add support for ThinLTO plugin option thinlto-object-suffix-replaceRumeet Dhindsa2018-05-165-2/+30
| | | | | | Differential Revision: https://reviews.llvm.org/D46608 llvm-svn: 332527
* [lld] Make helpers static. NFC.Benjamin Kramer2018-05-152-4/+4
| | | | llvm-svn: 332408
* [lld] Mitigate relocation overflow [part 1 of 2].Han Shen2018-05-151-5/+16
| | | | | | | | | | | This CL places .dynsym and .dynstr at the beginning of SHF_ALLOC sections. We do this to mitigate the possibility that huge .dynsym and .dynstr sections placed between ro-data and text sections cause relocation overflow. Differential Revision: https://reviews.llvm.org/D45788 llvm-svn: 332374
* [ELF] Implement --keep-unique optionPeter Smith2018-05-154-4/+24
| | | | | | | | | | | | | | The --keep-unique <symbol> option is taken from gold. The intention is that <symbol> will be prevented from being folded by ICF. Although not specifically mentioned in the documentation <symbol> only matches global symbols, with a warning if the symbol is not found. The implementation finds the Section defining <symbol> and removes it from the set of sections considered for ICF. Differential Revision: https://reviews.llvm.org/D46755 llvm-svn: 332332
* [ELF][PPC64] Fix getRelExpr for R_PPC64_REL64Zaara Syeda2018-05-141-0/+1
| | | | | | | | | The relocation R_PPC64_REL64 should return R_PC for getRelExpr since it computes S + A - P. Differential Revision: https://reviews.llvm.org/D46766 llvm-svn: 332259
* [ELF][PPC64] Fix getRelExpr for R_PPC64_REL32Zaara Syeda2018-05-141-0/+1
| | | | | | | | | The relocation R_PPC64_REL32 should return R_PC for getRelExpr since it computes S + A - P. Differential Revision: https://reviews.llvm.org/D46586 llvm-svn: 332252
OpenPOWER on IntegriCloud