summaryrefslogtreecommitdiffstats
path: root/lld
Commit message (Collapse)AuthorAgeFilesLines
...
* [Coding style change] Rename variables so that they start with a lowercase ↵Rui Ueyama2019-07-1056-12292/+12292
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | letter This patch is mechanically generated by clang-llvm-rename tool that I wrote using Clang Refactoring Engine just for creating this patch. You can see the source code of the tool at https://reviews.llvm.org/D64123. There's no manual post-processing; you can generate the same patch by re-running the tool against lld's code base. Here is the main discussion thread to change the LLVM coding style: https://lists.llvm.org/pipermail/llvm-dev/2019-February/130083.html In the discussion thread, I proposed we use lld as a testbed for variable naming scheme change, and this patch does that. I chose to rename variables so that they are in camelCase, just because that is a minimal change to make variables to start with a lowercase letter. Note to downstream patch maintainers: if you are maintaining a downstream lld repo, just rebasing ahead of this commit would cause massive merge conflicts because this patch essentially changes every line in the lld subdirectory. But there's a remedy. clang-llvm-rename tool is a batch tool, so you can rename variables in your downstream repo with the tool. Given that, here is how to rebase your repo to a commit after the mass renaming: 1. rebase to the commit just before the mass variable renaming, 2. apply the tool to your downstream repo to mass-rename variables locally, and 3. rebase again to the head. Most changes made by the tool should be identical for a downstream repo and for the head, so at the step 3, almost all changes should be merged and disappear. I'd expect that there would be some lines that you need to merge by hand, but that shouldn't be too many. Differential Revision: https://reviews.llvm.org/D64121 llvm-svn: 365595
* [lld][WebAssembly] Report undefined symbols during scanRelocationsSam Clegg2019-07-097-51/+30
| | | | | | | | | | | | | | | | This puts handling of undefined symbols in a single location. Its also more in line with the ELF backend which only reports undefined symbols based on relocations. One side effect is that we no longer report undefined symbols that are only referenced in GC'd sections. This also fixes a crash reported in the emscripten toolchain: https://github.com/emscripten-core/emscripten/issues/8930. Differential Revision: https://reviews.llvm.org/D64280 llvm-svn: 365553
* [lld][WebAssembly] Fix name of data section in PIC modeSam Clegg2019-07-091-2/+2
| | | | | | | | | | This should always have been ".data". Without this we treat the section as a user-defined section in other places (such as the generation of __start/__stop symbols). Differential Revision: https://reviews.llvm.org/D64439 llvm-svn: 365547
* lld-link: Stop accepting /natvis and /fastfail in .drectve sectionsNico Weber2019-07-091-2/+2
| | | | | | | | link.exe doesn't accept them either. Differential Revision: https://reviews.llvm.org/D64352 llvm-svn: 365478
* [ELF] Assert sizeof(SymbolUnion) <= 80Fangrui Song2019-07-091-0/+5
| | | | | | | | Reviewed By: ruiu Differential Revision: https://reviews.llvm.org/D64077 llvm-svn: 365443
* [ELF][test] Rename tail-merge-string-align2.s to merge-string-align2.sFangrui Song2019-07-091-0/+0
| | | | | | | | | | This test was added by D64200/r365139 to check we don't merge SHF_MERGE|SHF_STRINGS sections with different alignments (that wastes space and can make MergeTailAlignment::Builder out of sync). It has nothing to do with tail merge (-O2), so rename it. llvm-svn: 365442
* [LLD] NFC: Fixed GCC warning in ELF/Arch/RISCV.cppDenis Bakhvalov2019-07-091-1/+2
| | | | | | | | | GCC emits warning on this line: error: enumeral and non-enumeral type in conditional expression [-Werror=extra] Change-Id: I04969cc32e27e310968b88ebaa4e1c4894528d74 llvm-svn: 365434
* Let unaliased Args track which Alias they were created from, and use that in ↵Nico Weber2019-07-093-9/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Arg::getAsString() for diagnostics With this, `clang-cl /source-charset:utf-16 test.cc` now prints `invalid value 'utf-16' in '/source-charset:utf-16'` instead of `invalid value 'utf-16' in '-finput-charset=utf-16'` before, and several other clang-cl flags produce much less confusing output as well. Fixes PR29106. Since an arg and its alias can have different arg types (joined vs not) and different values (because of AliasArgs<>), I chose to give the Alias its own Arg object. For convenience, I just store the alias directly in the unaliased arg – there aren't many arg objects at runtime, so that seems ok. Finally, I changed Arg::getAsString() to use the alias's representation if it's present – that function was already documented as being the suitable function for diagnostics, and most callers already used it for diagnostics. Implementation-wise, Arg::accept() previously used to parse things as the unaliased option. The core of that switch is now extracted into a new function acceptInternal() which parses as the _aliased_ option, and the previously-intermingled unaliasing is now done as an explicit step afterwards. (This also changes one place in lld that didn't use getAsString() for diagnostics, so that that one place now also prints the flag as the user wrote it, not as it looks after it went through unaliasing.) Differential Revision: https://reviews.llvm.org/D64253 llvm-svn: 365413
* Add parentheses to silence warnings.Bill Wendling2019-07-081-3/+2
| | | | llvm-svn: 365397
* [lld] Use -o /dev/null in test when output is not needed.Sam Clegg2019-07-081-1/+1
| | | | | | Fix for feedback nit from rL364998 llvm-svn: 365310
* [lld][WebAssembly] Fix __start/__stop symbols when combining input segmentsSam Clegg2019-07-086-25/+27
| | | | | | | | | | | | We should be generating one __start/__stop pair per output segment not per input segment. The test wasn't catching this because it was only linking a single object file. Fixes PR41565 Differential Revision: https://reviews.llvm.org/D64148 llvm-svn: 365308
* [lld][WebAssembly] Fix typo in error messageSam Clegg2019-07-082-4/+4
| | | | | | Differential Revision: https://reviews.llvm.org/D64315 llvm-svn: 365304
* [WebAssembly] Add static_assert(sizeof(SymbolUnion) <= 96)Fangrui Song2019-07-081-5/+10
| | | | | | | | | | | | | | On Windows, the bitfield layout rule places `ussigned Referenced : 1` at byte offset 40, instead of byte offset 37 on *NIX. The consequence is that sizeof(SymbolUnion) == 104 on Windows while 96 on *NIX. To eliminate this difference, change these unsigned bitfields to bool. Reviewed By: ruiu Differential Revision: https://reviews.llvm.org/D64238 llvm-svn: 365296
* lld, llvm-dlltool, llvm-lib: Use getAsString() instead of getSpelling() for ↵Nico Weber2019-07-056-15/+15
| | | | | | | | | | | | | | | printing unknown args Since OPT_UNKNOWN args never have any values and consist only of spelling (and are never aliased), this doesn't make any difference in practice, but it's more consistent with Arg's guidance to use getAsString() for diagnostics, and it matches what clang does. Also tweak two tests to use an unknown option that contains '=' for additional coverage while here. (The new tests pass fine with the old code too though.) llvm-svn: 365200
* Make joined instances of JoinedOrSeparate flags point to the unaliased args, ↵Nico Weber2019-07-055-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | like all other arg types do This fixes an 8-year-old regression. r105763 made it so that aliases always refer to the unaliased option – but it missed the "joined" branch of JoinedOrSeparate flags. (r162231 then made the Args classes non-virtual, and r169344 moved them from clang to llvm.) Back then, there was no JoinedOrSeparate flag that was an alias, so it wasn't observable. Now /U in CLCompatOptions is a JoinedOrSeparate alias in clang, and warn_slash_u_filename incorrectly used the aliased arg id (using the unaliased one isn't really a regression since that warning checks if the undefined macro contains slash or backslash and only then emits the warning – and no valid use will pass "-Ufoo/bar" or similar). Also, lld has many JoinedOrSeparate aliases, and due to this bug it had to explicitly call `getUnaliasedOption()` in a bunch of places, even though that shouldn't be necessary by design. After this fix in Option, these calls really don't have an effect any more, so remove them. No intended behavior change. (I accidentally fixed this bug while working on PR29106 but then wondered why the warn_slash_u_filename broke. When I figured it out, I thought it would make sense to land this in a separate commit.) Differential Revision: https://reviews.llvm.org/D64156 llvm-svn: 365186
* [LLD][ELF] - Update a test after LLVM change.George Rimar2019-07-051-2/+2
| | | | | | Error reporting changed in r365183 llvm-svn: 365184
* lld-link: Make /debugtype: option work betterNico Weber2019-07-052-5/+11
| | | | | | | | | | | | | | | | | | | - The code tried to pass false to split()'s KeepEmpty parameter, but instead passed it to MaxSplit. As a result, it would never split on commas. This has been broken since the flag was added in r278056. - The code used getSpelling() for getting the argument's values, but getSpelling() always returns the `/debugtype:` prefix without any values. So if any /debugtype: flag was passed, it always resulted in an "unknown option:" warning. (The warning code then used the correct getValue() for printing the invalid option, so the warning looked kind of like it made sense.) This regressed in r342894. Slightly improve the test coverage of this feature (but since I don't know what this flag actually does, there's still no test for the correct semantics), and add a comment to getSpelling() explaining what it does. llvm-svn: 365182
* [WebAssembly] Delete static_assert(sizeof(SymbolUnion) <= 96) to fix Windows ↵Fangrui Song2019-07-051-5/+0
| | | | | | | | | | builds http://lab.llvm.org:8011/builders/sanitizer-windows/builds/47944/steps/stage%201%20build/logs/stdio Needs to figure out later the size on Windows. llvm-svn: 365171
* [WebAssembly] Reorder Symbol fields to make it smallerFangrui Song2019-07-051-25/+31
| | | | | | | | | | | | On 64-bit systems, this decreases sizeof(SymbolUnion) from 112 to 96. Add a static_assert to avoid accidental increases in future. Reviewed By: sbc100 Differential Revision: https://reviews.llvm.org/D64208 llvm-svn: 365169
* [LLD][ELF] - Linkerscript: add a support for expressions for section's fillingGeorge Rimar2019-07-044-29/+46
| | | | | | | | | | | | | | | | | | | Imagine the script: .section: { ... } = FILL_EXPR LLD assumes that FILL_EXPR is a number, and does not allow it to be an expression. Though that is allowed by specification: https://sourceware.org/binutils/docs-2.32/ld/Output-Section-Fill.html This patch adds a support for cases when FILL_EXPR is simple math expression. Fixes https://bugs.llvm.org/show_bug.cgi?id=42482. Differential revision: https://reviews.llvm.org/D64130 llvm-svn: 365143
* [ELF] Allow placing non-string SHF_MERGE sections with different alignments ↵Fangrui Song2019-07-045-49/+115
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | into the same MergeSyntheticSection The difference from D63432/r365015 is that this patch does not place SHF_STRINGS sections with different alignments into the same MergeSyntheticSection. Doing that would: (1) create unnecessary padding and thus waste space. Add a test tail-merge-string-align2.s to check no extra padding is created. (2) make some input sections unaligned when tail merge (-O2) is enabled. The alignment of MergeTailAlignment::Builder was out of sync in D63432. MOVAPS on such unaligned strings can raise SIGSEGV. This should fix PR42289: the Linux kernel has a use case that input files have .rodata.cst32 sections with different alignments. The expectation (and what ld.bfd and gold do) is that in the -r link, there is only one .rodata.cst32 (SHF_MERGE sections with different alignments can be combined), but lld currently creates one for each different alignment. The current merging strategy: 1) Group SHF_MERGE sections by (name, sh_flags, sh_entsize and sh_addralign). Merging is performed among a group, even if -O0 is specified. 2) Create one output section for each group. This is a special case in addInputSec(). This patch changes 1) to: 1) Group SHF_MERGE sections by (name, sh_flags, sh_entsize). Merging is performed among a group, even if -O0 is specified. We will thus create just one .rodata.cst32 . This also improves merging efficiency when sections with the same name but different alignments are combined. Reviewed By: peter.smith Differential Revision: https://reviews.llvm.org/D64200 llvm-svn: 365139
* [ELF] Fix weak-undef-shared.s after r365129Fangrui Song2019-07-041-0/+1
| | | | llvm-svn: 365131
* [ELF] resolveUndefined: ignore undefined symbols in SharedFile for Undefined ↵Fangrui Song2019-07-043-13/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | and SharedSymbol If %t1.o has a weak reference on foo, and %t2.so has a non-weak reference on foo: `ld.lld %t1.o %t2.so -o %t` We incorrectly set the binding of the undefined foo to STB_GLOBAL. Fix this by ignoring undefined symbols in a SharedFile for Undefined and SharedSymbol. This fixes the binding of pthread_once when the program links against both librt.so and libpthread.so ``` a.o: STB_WEAK reference to pthread_once librt.so: STB_GLOBAL reference to pthread_once # should be ignored libstdc++.so: STB_WEAK reference to pthread_once # should be ignored libgcc_s.so.1: STB_WEAK reference to pthread_once # should be ignored ``` The STB_GLOBAL pthread_once issue (not fixed by D63974) can cause a link error when the result DSO is used to link another DSO with -z defs if -lpthread is not specified. (libstdc++.so.6 not having a dependency on libpthread.so is a really nasty hack...) We happened to create a weak undef before D63974 because libgcc_s.so.1 was linked the last and it changed the binding again to weak. Reviewed By: ruiu Differential Revision: https://reviews.llvm.org/D64136 llvm-svn: 365129
* [WebAssembly] Add option to emit passive segmentsThomas Lively2019-07-0312-70/+326
| | | | | | | | | | | | | | | | | | | | | | | Summary: Adds `--passive-segments` and `--active-segments` flags to control what kind of segments are emitted. For now the default is always to emit active segments so this is not a breaking change, but in the future the default will be changed to passive segments when shared memory is requested and active segments otherwise. When passive segments are emitted, corresponding memory.init and data.drop instructions are emitted in a `__wasm_init_memory` function that is automatically called at the beginning of `__wasm_call_ctors`. Reviewers: sbc100, aheejin, dschuff Subscribers: azakai, dschuff, jgravelle-google, sunfish, jfb, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D59343 llvm-svn: 365088
* [ELF][RISCV] Error on R_RISCV_PCREL_LO12_[IS] that point to absolute symbolsFangrui Song2019-07-032-0/+12
| | | | | | | | | | | | | | The referenced symbol is expected to point to an R_RISCV_*_HI20 relocation. An absolute symbol has no associated section, therefore there cannot be a matching R_RISCV_*_HI20. This fixes the crash reported by PR42038. For reference, ld.bfd errors: (.init+0x4): dangerous relocation: %pcrel_lo missing matching %pcrel_hi Differential Revision: https://reviews.llvm.org/D63273 llvm-svn: 365049
* Revert D63432 "[ELF] Allow placing SHF_MERGE sections with different ↵Fangrui Song2019-07-034-86/+49
| | | | | | | | | | | | | | | | alignments into the same MergeSyntheticSection" This reverts r365015. David Zarzycki reported this change broke stage2 and stage3 tests. The root cause is still not very clear, but I guess some SHF_MERGE sections with the same name have different alignments. They were not merged before but were merged after r365015. Something that assumes address uniqueness of such mergeable data caused the bug. llvm-svn: 365048
* [ELF][RISCV] Allow R_RISCV_ADD in relocateNonAlloc()Fangrui Song2019-07-032-1/+7
| | | | | | | | | | | | gcc may generate .debug_info/.debug_aranges/.debug_line/etc that are relocated by R_RISCV_ADD*/R_RISCV_SUB* pairs. Allow R_RISCV_ADD in non-SHF_ALLOC section to fix link errors like: ld.lld: error: print.c:(.debug_frame+0x60): has non-ABS relocation R_RISCV_ADD64 against symbol '.L0 ' Differential Revision: https://reviews.llvm.org/D63259 llvm-svn: 365035
* [ELF] Allow placing SHF_MERGE sections with different alignments into the ↵Fangrui Song2019-07-034-49/+86
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | same MergeSyntheticSection This should fix PR42289: the Linux kernel has a use case that input files have .rodata.cst32 sections with different alignments. The expectation (and what ld.bfd and gold do) is that in the -r link, there is only one .rodata.cst32 (SHF_MERGE sections with different alignments can be combined), but lld currently creates one for each different alignment. The current merging strategy: 1) Group SHF_MERGE sections by (name, sh_flags, sh_entsize and sh_addralign). String merging is performed among a group, even if -O0 is specified. 2) Create one output section for each group. This is a special case in addInputSec(). This patch changes 1) to: 1) Group SHF_MERGE sections by (name, sh_flags, sh_entsize). String merging is performed among a group, even if -O0 is specified. We will thus create just one .rodata.cst32 . This also improves merging efficiency when sections with the same name but different alignments are combined. Reviewed By: ruiu Differential Revision: https://reviews.llvm.org/D63432 llvm-svn: 365015
* Avoid identifiers that are different only in case. NFC.Rui Ueyama2019-07-031-8/+8
| | | | llvm-svn: 365004
* Avoid identifiers that are different only in case. NFC.Rui Ueyama2019-07-035-35/+33
| | | | | | | | Some variables in lld have the same name as functions ignoring case. This patch gives them different names, so that my next patch is easier to read. llvm-svn: 365003
* Revert r364999: [lld] Use -o /dev/null in test when output is not needed.Rui Ueyama2019-07-031-1/+1
| | | | | | | This reverts commit r364999 as it broke a build. Looks like `%t.archive.o` is used two lines below where it was created. llvm-svn: 365001
* [lld] Use -o /dev/null in test when output is not needed.Sam Clegg2019-07-031-1/+1
| | | | | | Feedback nit from rL364998 llvm-svn: 364999
* [ELF] Error on archive with missing indexSam Clegg2019-07-033-2/+17
| | | | | | | | | | | | This matches the wasm lld and GNU ld behavior. The ELF linker has special handling for bitcode archives but if that doesn't kick in we probably want to error out rather than silently ignore the library. Differential Revision: https://reviews.llvm.org/D63781 llvm-svn: 364998
* [ELF][RISCV] Support RISC-V in getBitcodeMachineKindKito Cheng2019-07-033-0/+23
| | | | | | | | | | | Add Triple::riscv64 and Triple::riscv32 to getBitcodeMachineKind for get right e_machine during LTO. Reviewed By: ruiu, MaskRay Differential Revision: https://reviews.llvm.org/D52165 llvm-svn: 364996
* [ELF] Only allow the binding of SharedSymbol to change for the first undef refFangrui Song2019-07-024-25/+72
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes PR42442 t.o has a STB_GLOBAL undef ref to f t2.so has a STB_WEAK undef ref to f t1.so defines f ld.lld t.o t1.so t2.so currently sets the binding of `f` to STB_WEAK. This is not correct because there exists a STB_GLOBAL undef ref from a regular object. The problem is that resolveUndefined() doesn't check if the undef ref is seen for the first time: if (isShared() || isLazy() || (isUndefined() && Other.Binding != STB_WEAK)) Binding = Other.Binding; The isShared() condition should be `isShared() && !Referenced` where Referenced is set to true after an undef ref is seen. In practice, when linking a pthread program with glibc: // a.o #include <pthread.h> pthread_mutex_t mu = PTHREAD_MUTEX_INITIALIZER; int main() { pthread_mutex_unlock(&mu); } {clang,gcc} -fuse-ld=lld a.o -lpthread # libpthread.so is linked before libgcc_s.so.1 The weak undef pthread_mutex_unlock in libgcc_s.so.1 makes the result weak, which diverges from GNU linkers where STB_DEFAULT is used: 23: 0000000000000000 0 FUNC WEAK DEFAULT UND pthread_mutex_lock (Note, if -pthread is used instead, libpthread.so will be linked **after** libgcc_s.so.1 . lld sets the binding to the expected STB_GLOBAL) Similar linking sequences (ld.lld t.o t1.so t2.so) appear to be used by Go, which cause a build error https://github.com/golang/go/issues/31912. Reviewed By: grimar, ruiu Differential Revision: https://reviews.llvm.org/D63974 llvm-svn: 364913
* [ELF][RISCV] Support GD/LD/IE/LE TLS modelsFangrui Song2019-07-017-3/+377
| | | | | | | | | | | | RISC-V psABI doesn't specify TLS relaxation. It can be handled the same way as we handle ARM TLS. RISC-V TLS is even simpler because GD/LD use the same relocation type. Reviewed By: jrtc27, ruiu Differential Revision: https://reviews.llvm.org/D63220 llvm-svn: 364813
* [ELF][RISCV] Support PLT, GOT, copy and relative relocationsFangrui Song2019-07-018-4/+365
| | | | | | | | | | | | | | | | | | | | * Handle initial relocation types: R_RISCV_CALL_PLT and R_RISCV_GOT_HI20. * Produce dynamic relocation types: R_RISCV_COPY, R_RISCV_RELATIVE, R_RISCV_JUMP_SLOT. * Define SymbolRel as R_RISCV_{32,64} * Generate PLT header: it is used by lazy binding PLT in glibc. * R_RISCV_CALL is changed from R_PC to R_PC_PLT. If the target symbol is preemptable, this will suppress an unnecessary "canonical PLT". This behavior is different from ld.bfd but it is agreed the current lld behavior is favored. I have received positive responses from the binutils maintainer that the ABI/binutils implementation can be improved, see: https://github.com/riscv/riscv-elf-psabi-doc/issues/98 https://sourceware.org/bugzilla/show_bug.cgi?id=24685 Many -no-pie/-pie/-shared programs linked against musl or glibc should work with this patch. Reviewed By: jrtc27 Differential Revision: https://reviews.llvm.org/D63076 llvm-svn: 364812
* Cleanup: llvm::bsearch -> llvm::partition_point after r364719Fangrui Song2019-06-302-3/+3
| | | | llvm-svn: 364720
* [COFF] Fix .rsrc sections with differing permissionsMartin Storsjo2019-06-283-11/+26
| | | | | | | | | | | GNU windres, and MS cvtres (unless the /readonly option is passed) produce read-write .rsrc sections, when creating resource object files. This caused the sections to not be added to the precreated RsrcSec, and therefore not be added to the data directory. Differential Revision: https://reviews.llvm.org/D63837 llvm-svn: 364660
* [ELF] Do not produce DT_JMPREL and DT_PLTGOT if .rela.plt is empty.Igor Kudrin2019-06-282-1/+45
| | | | | | | | | | | | | If .rela.plt is mentioned in a linker script, it might be preserved even if it is empty. In that case, LLD created DT_JMPREL and DT_PLTGOT dynamic tags. When the tags exist, a dynamic loader writes values into reserved slots in .got.plt to support lazy symbol resolution. The problem is that, in fact, the linker has not reserved that space, and the writing may occur into the memory allocated for something else. Differential Revision: https://reviews.llvm.org/D63869 llvm-svn: 364639
* Fix lld build on Windows with MSVC due to C2461Michael Liao2019-06-271-2/+2
| | | | | | | | - It seems the same name of class and one of its fields confuses MSVC, https://docs.microsoft.com/en-us/cpp/error-messages/compiler-errors-1/compiler-error-c2461?view=vs-2019 - Patch from Andryeyev, German <german.andryeyev@amd.com> llvm-svn: 364567
* [LLD][ELF] - Replace invalid-e_shnum.s with YAML based version.George Rimar2019-06-273-3/+15
| | | | | | | | | The previous version used a precompiled binary. After this patch, we have no more precompiled binaries in LLD ELF test suite :) llvm-svn: 364529
* [wasm-ld] Add __global_base symbol to mark the value of --global-baseGuanzhong Chen2019-06-265-0/+80
| | | | | | | | | | | | | | | | | | | | | | Summary: This is needed for address sanitizer on Emscripten. As everything in memory starts at the value passed to --global-base, everything before that can be used as shadow memory. This symbol is added so that the library for the ASan runtime can know where the shadow memory ends and real memory begins. This is split from D63742. Reviewers: tlively, aheejin, sbc100 Subscribers: sunfish, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D63833 llvm-svn: 364467
* [LLD][COFF] Case insensitive compares for /nodefaultlibAlexandre Ganea2019-06-263-4/+11
| | | | | | Differential Revision: https://reviews.llvm.org/D63775 llvm-svn: 364438
* Reland D61583 [ELF] Error on relocations to STT_SECTION symbols if the ↵Fangrui Song2019-06-2614-94/+212
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | sections were discarded This restores r361830 "[ELF] Error on relocations to STT_SECTION symbols if the sections were discarded" and dependent commits (r362218, r362497) which were reverted by r364321, with a fix of a --gdb-index issue. .rela.debug_ranges contains relocations of range list entries: // start address of a range list entry // old: 0; after r361830: 0 00000000000033a0 R_X86_64_64 .text._ZN2v88internal7Isolate7factoryEv + 0 // end address of a range list entry // old: 0xe; after r361830: 0 00000000000033a8 R_X86_64_64 .text._ZN2v88internal7Isolate7factoryEv + e If both start and end addresses of a range list entry resolve to 0, DWARFDebugRangeList::isEndOfListEntry() will return true, then the .debug_range decoding loop will terminate prematurely: while (true) { decode StartAddress decode EndAddress if (Entry.isEndOfListEntry()) // prematurely break; Entries.push_back(Entry); } In lld/ELF/SyntheticSections.cpp, readAddressAreas() will read incomplete address ranges and the resulting .gdb_index will be incomplete. For files that gdb hasn't loaded their debug info, gdb uses .gdb_index to map addresses to CUs. The absent entries make gdb fail to symbolize some addresses. To address this issue, we simply allow relocations to undefined symbols in DWARF.cpp:findAux() and let RelocationResolver resolve them. This patch should fix: [1] http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20190603/659848.html [2] https://bugs.chromium.org/p/chromium/issues/detail?id=978067 llvm-svn: 364391
* [WebAssembly] Fix accidental omission from rLLD364367Keno Fischer2019-06-261-0/+1
| | | | | | | | There was another place where handling for this relocation was missing that was accidentally omitted from rLLD364367, causing the newly added test to fail on the buildbots. llvm-svn: 364371
* [lld/WebAssembly] Slightly nicer error message for malformed input filesKeno Fischer2019-06-262-1/+2
| | | | | | | | | | | | | | | | | | | Summary: Before: ``` wasm-ld: error: Relocations not in offset order ``` After ``` wasm-ld: error: While processing `libjulia.so`: Relocations not in offset order ``` At least this way you get to find out which input file is malformed. Reviewers: sbc100 Differential Revision: https://reviews.llvm.org/D63694 llvm-svn: 364368
* [WebAssembly] Fix list of relocations with addends in lldKeno Fischer2019-06-263-9/+22
| | | | | | | | | | | | | Summary: The list of relocations with addend in lld was missing `R_WASM_MEMORY_ADDR_REL_SLEB`, causing `wasm-ld` to generate corrupted output. This fixes that problem and while we're at it pulls the list of such relocations into the Wasm.h header, to avoid duplicating it in multiple places. Reviewers: sbc100 Differential Revision: https://reviews.llvm.org/D63696 llvm-svn: 364367
* [WebAssembly] Error on archives without a symbol indexSam Clegg2019-06-252-4/+25
| | | | | | | | | | | | | | | | | | This is fairly common with wasm since GNU ar (most likely the system ar) doesn't support the wasm object format so user who don't override AR will end up with archives without an index. We don't want to silently ignore this issue. In the future we could choose to instead behave like the ELF backend and read the symbols from each object file in the archive if they are all of the same type. However, error'ing out seem like a conservative approach for now. Fixes: PR42376 Differential Revision: https://reviews.llvm.org/D63739 llvm-svn: 364338
* Revert r362743 "Revert "Revert "Reland D61583 [ELF] Error on relocations to ↵Hans Wennborg2019-06-2512-150/+75
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | STT_SECTION symbols if the sections were discarded""" (In effect, reverting "[ELF] Error on relocations to STT_SECTION symbols if the sections were discarded".) It caused debug info problems in LibreOffice [1] and Chromium/V8 [2]. Reverting until those can be fixed. It also reverts r362497 "STT_SECTION symbol should be defined" on .eh_frame, .debug*, .zdebug* and .gcc_except_table" which was landed as a follow-up to the above. > With -r or --emit-relocs, we warn `STT_SECTION symbol should be defined` > on relocations to discarded section symbol. This was added as an error > in rLLD319404, but was not so effective before D61583 (it turned the > error to a warning). > > Relocations from .eh_frame .debug* .zdebug* .gcc_except_table to > discarded .text are very common and somewhat expected. Don't warn/error > on them. As a reference, ld.bfd has a similar logic in > _bfd_elf_default_action_discarded() to allow these cases. > > Delete invalid-undef-section-symbol.test because what it intended to > check is now covered by the updated comdat-discarded-reloc.s > > Delete relocatable-eh-frame.s because we allow relocations from > .eh_frame as a special case now. And finally it reverts r362218 "[ELF] Replace a dead test in getSymVA() with assert()" as that also depended on the main change reverted here. > Symbols relative to discarded comdat sections are Undefined instead of > Defined now (after D59649 and D61583). The `== &InputSection::Discarded` > test becomes dead. I cannot find a test related to this behavior. [1] http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20190603/659848.html [2] https://bugs.chromium.org/p/chromium/issues/detail?id=978067 llvm-svn: 364321
OpenPOWER on IntegriCloud