aboutsummaryrefslogtreecommitdiff
path: root/lld
AgeCommit message (Collapse)AuthorFilesLines
2019-08-14[LLD] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere19-37/+37
Now that we've moved to C++14, we no longer need the llvm::make_unique implementation from STLExtras.h. This patch is a mechanical replacement of (hopefully) all the llvm::make_unique instances across the monorepo. Differential revision: https://reviews.llvm.org/D66259 llvm-svn: 368936
2019-08-14[ELF] --gdb-index: fix odd variable name cUs after r365730 and replace ↵Fangrui Song1-7/+6
lower_bound with partition_point. NFC llvm-svn: 368845
2019-08-14[ELF][test] Update silent-ignore.testFangrui Song1-3/+5
Some options are implemented now: --no-warn-common : r263413 --allow-shlib-undefined : r352826 Some are ignored but were not reflected in this test. llvm-svn: 368837
2019-08-14[MinGW] Correct handling different forms of a few optionsMartin Storsjo2-10/+16
Support the equals form of the long --entry=<symbol> option, add a test for the -e<symbol> form. Add tests for single dash forms of -exclude-all-symbols and -export-all-symbols. Support single-dash forms of -out-implib and -output-def, support the equals form of --output-def=<file>. (We previously had a test to explicitly disallow -out-implib, but it turns out that GNU ld actually does support it just fine, despite also matching the -o<file> option.) Disallow the double-dashed --u form, add a test for -u<symbol>. Differential Revision: https://reviews.llvm.org/D66066 llvm-svn: 368816
2019-08-14[MinGW] Restructure Options.td to use multiclass where sensible. NFC.Martin Storsjo1-33/+29
Differential Revision: https://reviews.llvm.org/D66065 llvm-svn: 368815
2019-08-14[MinGW] Remove stray/inconsistent comment chars in test file. NFC.Martin Storsjo1-8/+8
Test directives don't need to be in comments in this file. llvm-svn: 368814
2019-08-14[ELF] Initialize 2 fields of Symbol in SymbolTable::insertFangrui Song2-0/+6
A new symbol is added to elf::symtab in 3 steps: 1) SymbolTable::insert creates a placeholder. 2) Symbol::mergeProperties 3) Symbol::replace Fields referenced by steps 2) and 3) should be initialized in SymbolTable::insert. `traced` and `referenced` were missed previously. This did not cause problems because compilers generated code that initialized them (bit fields) to 0. Reviewed By: grimar Differential Revision: https://reviews.llvm.org/D66130 llvm-svn: 368784
2019-08-13[lld][WebAssembly] Allow linking of pic code into static binariesSam Clegg8-14/+165
Summary: See https://github.com/emscripten-core/emscripten/issues/9013 Subscribers: dschuff, jgravelle-google, aheejin, sunfish, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D65922 llvm-svn: 368719
2019-08-13[lld][test] Update test to print ELF note description dataJordan Rupprecht1-0/+1
llvm-svn: 368710
2019-08-13[ELF] Don't special case symbolic relocations with 0 addend to ifunc in ↵Fangrui Song6-63/+63
writable locations Currently the following 3 relocation types do not trigger the creation of a canonical PLT (which changes STT_GNU_IFUNC to STT_FUNC and redirects all references): 1) GOT-generating (`needsGot`) 2) PLT-generating (`needsPlt`) 3) R_ABS with 0 addend in a writable location. This is used for for ifunc function pointers in writable sections such as .data and .toc. This patch deletes case 3) to simplify the R_*_IRELATIVE generating logic added in D57371. Other advantages: * It is guaranteed no more than 1 R_*_IRELATIVE is created for an ifunc. * PPC64: no need to special case ifunc in toc-indirect to toc-relative relaxation. See D65755 The deleted elf::addIRelativeRelocs demonstrates that one-pass scan through relocations makes several optimizations difficult. This is something we can think about in the future. Reviewed By: peter.smith Differential Revision: https://reviews.llvm.org/D65995 llvm-svn: 368661
2019-08-13[ELF] Simplify handling of exportDynamic and isPreemptibleFangrui Song4-23/+29
In Writer::includeInDynSym(), exportDynamic is used by a Defined with protected or default visibility, to record whether it is required to be exported into .dynsym. It is set when any of the following conditions hold: 1) There is an interposable symbol from a DSO (Undefined or SharedSymbol with default visibility) 2) If -shared or --export-dynamic is specified, any symbol in an object file/bitcode sets this property, unless suppressed by canBeOmittedFromSymbolTable(). 3) --dynamic-list when producing an executable 4) protected symbol from a DSO preempted by copy relocation/canonical PLT when --ignore-{data,function}-address-equality is specified 5) ifunc is exported when -z ifunc-noplt is specified Bullet points 4) and 5) are irrelevant in this patch. Bullet 3) does not play well with 1) and 2). When -shared is specified, exportDynamic of most symbols is true. This makes it incapable to record --dynamic-list marked symbols. We thus have obscure: if (!config->shared) b->exportDynamic = true; else if (b->includeInDynsym()) b->isPreemptible = true; This patch adds another bit `Symbol::inDynamicList` to record 3). We can thus simplify handleDynamicList() by unifying the DSO and executable cases. It also allows us to simplify isPreemptible - now the field is only used in finalizeSections() and later stages. Reviewed By: peter.smith Differential Revision: https://reviews.llvm.org/D66091 llvm-svn: 368659
2019-08-13[ELF] Rename odd variable names "New" after r365730. NFCFangrui Song6-38/+35
New -> newSym or newFlags Reviewed By: atanasyan Differential Revision: https://reviews.llvm.org/D66127 llvm-svn: 368651
2019-08-13[ELF][test] Add dynamic-list-preempt2.sFangrui Song1-0/+29
When producing a DSO, the isPreemptible property of a Defined with default or protected visibility is affected by the --dynamic-list file, but not by interposable symbols in other DSOs. llvm-svn: 368649
2019-08-13[lld] Remove unnecessary "class Lazy"Bob Haarman1-1/+0
llvm-svn: 368644
2019-08-12[ELF] Remove unnecessary assignment to `isPreemptible` in replaceWithDefined()Fangrui Song1-1/+0
After r368535, it is no longer used in the handling of VER_NDX_LOCAL. Drop it. llvm-svn: 368550
2019-08-11[ELF] Remove redundant isDefined() in Symbol::computeBinding() and delete ↵Fangrui Song2-5/+3
one redundant call site After r367869, VER_NDX_LOCAL can only be assigned to Defined and CommonSymbol. CommonSymbol becomes Defined after replaceCommonSymbols(), thus `versionId == VER_NDX_LOCAL` will imply `isDefined()`. In maybeReportUndefined(), computeBinding() is called when the symbol is unknown to be Undefined. computeBinding() != STB_LOCAL will always be true. llvm-svn: 368536
2019-08-11[ELF] Remove redundant !isPreemptible in Symbol::computeBinding()Fangrui Song1-1/+1
!isPreemptible was added in r343668 to fix PR39104: symbols redefined by replaceWithDefined() might be incorrectly considered STB_LOCAL if a version script specified `local: *;`. After r367869 (`config->defaultSymbolVersion` was removed), we will assign VER_NDX_LOCAL to only regular Defined and CommonSymbol, not Defined created by replaceWithDefined() (because scanVersionScript() is called before scanRelocations()). The !isPreemptible is thus redundant and can be deleted. llvm-svn: 368535
2019-08-11[ELF] Remove unnecessary assignment to `used` in replaceWithDefinedFangrui Song1-1/+0
`Symbol::used` is used by Undefined and SharedSymbol to record if a .symtab entry is needed. It is of no use for Defined. llvm-svn: 368533
2019-08-09[ELF] For VS-style diagnostics, prefer printing full paths in the header.Igor Kudrin7-8/+54
The filename part in the message header is used by Visual Studio to fill Error List so that a user can click on an item and jump to the mentioned location. If we use only the name of a source file and not the full path, Visual Studio might be unable to find the right file or, even worse, show a wrong one. Differential Revision: https://reviews.llvm.org/D65875 llvm-svn: 368409
2019-08-09[ELF] Expand regions for gaps due to explicit addressFangrui Song2-0/+26
If the dot gets moved by an explicit section address, an empty gap between sections could be created. The encompassing region for the section being parsed needs to be expanded to include the gap. Differential Revision: https://reviews.llvm.org/D65722 Patch by Gabriel Smith! llvm-svn: 368379
2019-08-09DebugInfo: Explicitly handle errors when parsing unit DIEsDavid Blaikie2-4/+6
This ensures these errors produce a non-zero exit and improves the context (providing the name of the input object and section being parsed). llvm-svn: 368378
2019-08-09ELF: Move sections referred to by __start_/__stop_ symbols into the main ↵Peter Collingbourne2-0/+55
partition. In the case where C identifier sections have SHF_LINK_ORDER they will most likely be placed in the same partition as the section that they are associated with. But unless this happens to be the main partition, this will cause them to be excluded from the range covered by the __start_ and __stop_ symbols, which may lead to incorrect program behaviour. So we need to move them all into the main partition so that they will be covered by the __start_ and __stop_ symbols. We may want to refine this approach later and allow different __start_/__stop_ symbol values for different partitions. This would only make sense for relocations from SHT_NOTE sections since they are duplicated into each partition. Differential Revision: https://reviews.llvm.org/D65909 llvm-svn: 368375
2019-08-08[lld][WebAssembly] Don't create optional symbols when outputing an object fileSam Clegg1-25/+27
Summary: This was a bug in rL368310. I'm working on a test case now. Differential Revision: https://reviews.llvm.org/D65985 llvm-svn: 368369
2019-08-08[WebAssembly][lld] control __data_end export with config->sharedGuanzhong Chen1-1/+3
Summary: Emscripten expects `__data_end` to show up in PIC code as long as it's not linked with `--shared`. Currently, Emscripten breaks with latest LLVM because `__data_end` is controlled by `config->isPic` instead of `config->shared`.` Reviewers: tlively, sbc100 Reviewed By: sbc100 Subscribers: dschuff, jgravelle-google, aheejin, sunfish, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D65980 llvm-svn: 368361
2019-08-08[lld][WebAssembly] Use createGlobalVariable helper function. NFC.Sam Clegg1-12/+2
Differential Revision: https://reviews.llvm.org/D65911 llvm-svn: 368325
2019-08-08[lld][WebAssembly] Add optional symbols after input file handlingSam Clegg6-24/+35
This allows undefined references in input files be resolved by the optional symbols. Previously we were doing this before input file reading which means it was working only for command line symbols references (i.e. -u or --export). Also use addOptionalDataSymbol for __dso_handle and make all optional symbols hidden by default. Differential Revision: https://reviews.llvm.org/D65920 llvm-svn: 368310
2019-08-08[ELF][AArch64] Delete two unused RUN lines from aarch64-movw-tprel.s after ↵Fangrui Song1-2/+0
D65882 llvm-svn: 368298
2019-08-08[ELF][AArch64] Support for movz, movk tprel relocationsPeter Smith3-0/+94
This patch Implements the R_AARCH64_TLSLE_MOVW_TPREL_G*[_NC]. These are logically the same calculation as the existing TLSLE relocations with the result written back to mov[nz] and movk instructions. A typical code sequence is: movz x0, #:tprel_g2:foo // bits [47:32] of R_TLS with overflow check movk x0, #:tprel_g1_nc:foo // bits [31:16] of R_TLS with no overflow check movk x0, #:tprel_g0_nc:foo // bits [15:0] of R_TLS with no overflow check This type of code sequence is usually used with a large code model. Differential Revision: https://reviews.llvm.org/D65882 Fixes: PR42853 llvm-svn: 368293
2019-08-07gdb-index: Wire up str_offsets section to avoid incorrect error message ↵David Blaikie3-1/+12
about offsets_base There's still a need for a deeper fix to the way libDebugInfoDWARF error messages are propagated up to lld - if lld had exited non-zero on this error message we would've found the issue sooner. llvm-svn: 368229
2019-08-07Add a test demonstrating DWARF parse failures are not causing lld to exit ↵David Blaikie1-0/+30
non-zero This bug was/is masking other issues - committing this to demonstrate the problem/track fixing it. llvm-svn: 368220
2019-08-07API update for change to LLVM's lib/DebugInfo/DWARFDavid Blaikie3-21/+21
llvm-svn: 368190
2019-08-07Try to fix windows build bots after r368153.Igor Kudrin1-2/+2
llvm-svn: 368169
2019-08-07[ELF] Fix splitting messages for duplicate symbols.Igor Kudrin2-2/+41
D65213 (rL367536) does not work for the case when a source file path includes subdirectories. Differential Revision: https://reviews.llvm.org/D65810 llvm-svn: 368153
2019-08-07Handle /align option.Rui Ueyama4-4/+60
Differential Revision: https://reviews.llvm.org/D65736 llvm-svn: 368145
2019-08-07Simplify error message output. NFC.Rui Ueyama1-16/+13
Differential Revision: https://reviews.llvm.org/D65855 llvm-svn: 368144
2019-08-07[ELF][X86] Add --no-show-raw-insn and -soname to some i386 testsFangrui Song7-136/+138
llvm-svn: 368142
2019-08-07Re-submit r367649: Improve raw_ostream so that you can "write" colors using ↵Rui Ueyama10-86/+73
operator<< The original patch broke buildbots, perhaps because it changed the default setting whether colors are enabled or not. llvm-svn: 368131
2019-08-06[WebAssembly] Fix null pointer in createInitTLSFunctionGuanzhong Chen2-176/+186
Summary: `createSyntheticSymbols`, which creates `WasmSym::InitTLS`, is only called when `!config->relocatable`, but this condition is not checked when calling `createInitTLSFunction`. This diff checks `!config->relocatable` before calling `createInitTLSFunction`. Fixes https://github.com/emscripten-core/emscripten/issues/9155. Reviewers: tlively, aheejin, kripken, sbc100 Subscribers: dschuff, jgravelle-google, sunfish, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D65785 llvm-svn: 368078
2019-08-06[ELF][PPC] Don't relax ifunc toc-indirect accesses to toc-relativeFangrui Song2-1/+25
Fixes PR42759. ``` // If ifunc is taken address in -fPIC code, it may have a toc entry .section .toc,"aw",@progbits .quad ifunc // ifunc may be defined as STT_GNU_IFUNC in another object file .type ifunc, %gnu_indirect_function ``` If ifunc is non-preemptable (e.g. when linking an executable), the toc entry will be relocated by R_PPC64_IRELATIVE. R_*_IRELATIVE represents the symbolic value of a non-preemptable ifunc (not associated with a canonical PLT) in a writable location. It has an unknown value at link time, so we cannot apply toc-indirect to toc-relative relaxation. Reviewed By: luporl, sfertile Differential Revision: https://reviews.llvm.org/D65755 llvm-svn: 368057
2019-08-06[ELF][ARM] Fix /DISCARD/ of section with .ARM.exidx sectionPeter Smith2-1/+50
The combineEhSections runs, by design, before processSectionCommands so that input exception sections like .ARM.exidx and .eh_frame are not assigned to OutputSections. Unfortunately if /DISCARD/ removes InputSections that have associated .ARM.exidx sections without discarding the .ARM.exidx synthetic section then we will end up crashing when trying to sort the InputSections in ascending address order. We fix this by filtering out the sections that have been discarded prior to processing the InputSections in finalizeContents(). fixes pr42890 Differential Revision: https://reviews.llvm.org/D65759 llvm-svn: 368041
2019-08-06[ELF] Make binding (weak or non-weak) logic consistent for Undefined and ↵Fangrui Song4-19/+20
SharedSymbol This is a case missed by D64136. If %t1.o has a weak reference on foo, and %t2.so has a non-weak reference on foo: ``` 0. ld.lld %t1.o %t2.so # ok; STB_WEAK; accepted since D64136 1. ld.lld %t2.so %t1.o # undefined symbol: foo; STB_GLOBAL 2. gold %t1.o %t2.so # ok; STB_WEAK 3. gold %t2.so %t1.o # undefined reference to 'foo'; STB_GLOBAL 4. ld.bfd %t1.o %t2.so # undefined reference to `foo'; STB_WEAK 5. ld.bfd %t2.so %t1.o # undefined reference to `foo'; STB_WEAK ``` It can be argued that in both cases, the binding of the undefined foo should be set to STB_WEAK, because the binding should not be affected by referenced from shared objects. --allow-shlib-undefined doesn't suppress errors (3,4,5), but -shared or --noinhibit-exec allows ld.bfd/gold to produce a binary: ``` 3. gold -shared %t2.so %t1.o # ok; STB_GLOBAL 4. ld.bfd -shared %t2.so %t1.o # ok; STB_WEAK 5. ld.bfd -shared %t1.o %t1.o # ok; STB_WEAK ``` If %t2.so has DT_NEEDED entries, ld.bfd will load them (lld/gold don't have the behavior). If one of the DSO defines foo and it is in the link-time search path (e.g. DT_NEEDED entry is an absolute path, via -rpath=, via -rpath-link=, etc), `ld.bfd %t1.o %t2.so` and `ld.bfd %t1.o %t2.so` will not error. In this patch, we make Undefined and SharedSymbol share the same binding computing logic. Case 1 will be allowed: ``` 0. ld.lld %t1.o %t2.so # ok; STB_WEAK; accepted since D64136 1. ld.lld %t2.so %t1.o # ok; STB_WEAK; changed by this patch ``` In the future, we can explore the option that turns both (0,1) into errors if --no-allow-shlib-undefined (default when linking an executable) is in action. Reviewed By: ruiu Differential Revision: https://reviews.llvm.org/D65584 llvm-svn: 368038
2019-08-06[MachO] Update LLD to use 64-bit offsets with DataExtractor (3/5)Igor Kudrin1-6/+6
Differential Revision: https://reviews.llvm.org/D65639 llvm-svn: 368032
2019-08-05[ELF][test] Reorganize some tls-*.s testsFangrui Song14-245/+176
Some tls-*.s tests do not test generic TLS behavior but rather are x86 specific. Rename them to i386-*.s or x86-64-*.s Delete tls-static.s: covered by tls-opt.s Delete tls-opt-no-plt.s: add --implicit-check-not=.plt to x86-64-tls-gdie.s to cover it Rename tls-dynamic-i686.s to i386-tls-dynamic.s Rename tls-i686.s to i386-tls-le.s Rename tls-opt-i686.s to i386-tls-opt.s Rename tls-opt-iele-i686-nopic.s to i386-tls-opt-iele-nopic.s Rename tls-dynamic.s to x86-64-tls-dynamic.s . IE should be split off in the future. Rename tls-error.s to x86-64-reloc-tpoff32-error.s Rename tls-opt-gdie.s to x86-64-tls-gdie.s Rename tls-opt-x86_64-noplt.s to x86-64-tls-opt-noplt.s Rename tls-opt-local.s => x86-64-tls-ie-opt-local.s . It can be merged with x86-64-tls-ie-local.s in the future. llvm-svn: 367877
2019-08-05[ELF] Consistently prioritize non-* wildcards overs "*" in version scriptsFangrui Song10-70/+91
We prioritize non-* wildcards overs VER_NDX_LOCAL/VER_NDX_GLOBAL "*". This patch generalizes the rule to "*" of other versions and thus fixes PR40176. I don't feel strongly about this GNU linkers' behavior but the generalization simplifies code. Delete `config->defaultSymbolVersion` which was used to special case VER_NDX_LOCAL/VER_NDX_GLOBAL "*". In `SymbolTable::scanVersionScript`, custom versions are handled the same way as VER_NDX_LOCAL/VER_NDX_GLOBAL. So merge `config->versionScript{Locals,Globals}` into `config->versionDefinitions`. Overall this seems to simplify the code. In `SymbolTable::assign{Exact,Wildcard}Versions`, `sym->verdefIndex == config->defaultSymbolVersion` is changed to `verdefIndex == UINT32_C(-1)`. This allows us to give duplicate assignment diagnostics for `{ global: foo; };` `V1 { global: foo; };` In test/linkerscript/version-script.s: vs_index of an undefined symbol changes from 0 to 1. This doesn't matter (arguably 1 is better because the binding is STB_GLOBAL) because vs_index of an undefined symbol is ignored. Reviewed By: ruiu Differential Revision: https://reviews.llvm.org/D65716 llvm-svn: 367869
2019-08-05Changing representation of .cv_def_range directives in Codeview debug info ↵Nilanjana Basu1-3/+3
assembly format for better readability llvm-svn: 367867
2019-08-05Revert "Changing representation of .cv_def_range directives in Codeview ↵Nilanjana Basu1-3/+3
debug info assembly format for better readability" This reverts commit a885afa9fa8cab3b34f1ddf3d21535f88b662881. llvm-svn: 367861
2019-08-05Changing representation of .cv_def_range directives in Codeview debug info ↵Nilanjana Basu1-3/+3
assembly format for better readability llvm-svn: 367850
2019-08-05[MinGW] Add an lld specific option for requesting to delay load librariesMartin Storsjo3-0/+8
With GNU tools, delayload is handled completely differently. (One creates a specific delayload import library using dlltool and then links against it instead of the normal import library.) Instead of requiring using -Xlink=-delayload:lib.dll, we can provide an lld specific option for this. Differential Revision: https://reviews.llvm.org/D65728 llvm-svn: 367837
2019-08-05[COFF] Omit automatically imported symbols from the symbol tableMartin Storsjo3-3/+20
These symbols actually point to the symbol's IAT entry, which obviously is different from the symbol itself (which is imported from a different module and doesn't exist in the current one). Omitting this symbol helps gdb inspect automatically imported symbols, see https://sourceware.org/bugzilla/show_bug.cgi?id=24574 for discussion on the matter. Surprisingly, those extra symbols don't seem to be an issue for gdb when the sources have been built with clang, only with gcc. The actual logic in gdb that this depends on still is unknown, but omitting these symbols from the symbol table is the right thing to do in any case. Differential Revision: https://reviews.llvm.org/D65727 llvm-svn: 367836
2019-08-05Rename F_{None,Text,Append} to OF_{None,Text,Append}. NFCFangrui Song10-13/+13
F_{None,Text,Append} are kept for compatibility since r334221. llvm-svn: 367800