summaryrefslogtreecommitdiffstats
path: root/lld/ELF
Commit message (Collapse)AuthorAgeFilesLines
...
* [ELF] Fix typo in header guard. NFC.Sam Clegg2019-05-161-2/+2
| | | | llvm-svn: 360832
* [LLD][ELF] Add the -z ifunc-noplt optionFangrui Song2019-05-143-2/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Patch by Mark Johnston! Summary: When the option is configured, ifunc calls do not go through the PLT; rather, they appear as regular function calls with relocations referencing the ifunc symbol, and the resolver is invoked when applying the relocation. This is intended for use in freestanding environments where text relocations are permissible and is incompatible with the -z text option. The option is motivated by ifunc usage in the FreeBSD kernel, where ifuncs are used to elide CPU feature flag bit checks in hot paths. Instead of replacing the cost of a branch with that of an indirect function call, the -z ifunc-noplt option is used to ensure that ifunc calls carry no hidden overhead relative to normal function calls. Test Plan: I added a couple of regression tests and tested the FreeBSD kernel build using the latest lld sources. To demonstrate the effects of the change, I used a micro-benchmark which results in frequent invocations of a FreeBSD kernel ifunc. The benchmark was run with and without IBRS enabled, and with and without -zifunc-noplt configured. The observed speedup is small and consistent, and is significantly larger with IBRS enabled: https://people.freebsd.org/~markj/ifunc-noplt/noibrs.txt https://people.freebsd.org/~markj/ifunc-noplt/ibrs.txt Reviewed By: ruiu, MaskRay Differential Revision: https://reviews.llvm.org/D61613 llvm-svn: 360685
* [ELF] --gdb-index: fix SIGSEGV when a DWARFAddressRange has invalid SectionIndexFangrui Song2019-05-141-0/+2
| | | | | | | | | | See D61891: llvm had a bug that might create invalid (DW_AT_low_pc,DW_AT_high_pc) pairs or range list entries due to missing DW_AT_addr_base. Reviewed By: ruiu Differential Revision: https://reviews.llvm.org/D61889 llvm-svn: 360679
* Move SymbolTable::addFile to InputFiles.cpp.Rui Ueyama2019-05-145-86/+95
| | | | | | | | | | | | | | | | | The symbol table used to be a container of vectors of input files, but that's no longer the case because the vectors are moved out of SymbolTable and are now global variables. Therefore, addFile doesn't have to belong to any class. This patch moves the function out of the class. This patch is a preparation for my RFC [1]. [1] http://lists.llvm.org/pipermail/llvm-dev/2019-April/131902.html Differential Revision: https://reviews.llvm.org/D61854 llvm-svn: 360666
* [ELF] Full support for -n (--nmagic) and -N (--omagic) via common pagePeter Smith2019-05-138-18/+67
| | | | | | | | | | | | | | | | | | | | | | The -n (--nmagic) disables page alignment, and acts as a -Bstatic The -N (--omagic) does what -n does but also marks the executable segment as writeable. As page alignment is disabled headers are not allocated unless explicit in the linker script. To disable page alignment in LLD we choose to set the page sizes to 1 so that any alignment based on the page size does nothing. To set the Target->PageSize to 1 we implement -z common-page-size, which has the side effect of allowing the user to set the value as well. Setting the page alignments to 1 does mean that any use of CONSTANT(MAXPAGESIZE) or CONSTANT(COMMONPAGESIZE) in a linker script will return 1, unlike in ld.bfd. However given that -n and -N disable paging these probably shouldn't be used in a linker script where -n or -N is in use. Differential Revision: https://reviews.llvm.org/D61688 llvm-svn: 360593
* [PPC64] Define getThunkSectionSpacing() based on the range of R_PPC64_REL24Fangrui Song2019-05-101-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Suggested by Sean Fertile and Peter Smith. Thunk section spacing decrease the total number of thunks. I measured a decrease of 1% or less in some large programs, with no perceivable slowdown in link time. Override getThunkSectionSpacing() to enable it. 0x2000000 is the farthest point R_PPC64_REL24 can reach. I tried several numbers and found 0x2000000 works the best. Numbers near 0x2000000 work as well but let's just use the simpler number. As demonstrated by the updated tests, this essentially changes placement of most thunks to the end of the output section. We leverage this property to fix PR40740 reported by Alfredo Dal'Ava Júnior: The output section .init consists of input sections from several object files (crti.o crtbegin.o crtend.o crtn.o). Sections other than the last one do not have a terminator. With this patch, we create the thunk after the last .init input section and thus fix the issue. This is not foolproof but works quite well for such sections (with no terminator) in practice. Reviewed By: ruiu, sfertile Differential Revision: https://reviews.llvm.org/D61720 llvm-svn: 360405
* [LLD][NFC] Refactor: BuildID hash size now computed in one place.Ben Dunbobbin2019-05-092-25/+19
| | | | | | Differential Revision: https://reviews.llvm.org/D61078 llvm-svn: 360316
* [ELF] Initialize Target before it may be dereferenced by findAux when ↵Fangrui Song2019-05-091-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | reporting "duplicate symbol" error for (InputFile *F : Files) Symtab->addFile<ELFT>(F); // if there is a duplicate symbol error ... Target = getTarget(); When parsing .debug_info in the object file (for better diagnostics), DWARF.cpp findAux may dereference the null pointer Target auto *DR = dyn_cast<Defined>(&File->getRelocTargetSym(Rel)); if (!DR) { // Broken debug info may point to a non-defined symbol, // some asan object files may also contain R_X86_64_NONE RelType Type = Rel.getType(Config->IsMips64EL); if (Type != Target->NoneRel) /// Target is null Move the assignment of Target to an earlier place to fix this. Reviewed By: ruiu Differential Revision: https://reviews.llvm.org/D61712 llvm-svn: 360305
* [WebAssembly] Handle command line options consistently with the ELF backend.Sam Clegg2019-05-082-2/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D61645 llvm-svn: 360266
* [mips] Fix ld instruction in PLT entries on MIPS64Simon Atanasyan2019-05-071-2/+4
| | | | | | | | | | | Use `ld` and `daddiu` instructions in MIPS64 PLT records. That fixes a segmentation fault. Patch by Qiao Pengcheng. Differential Revision: https://reviews.llvm.org/D61586 llvm-svn: 360187
* Add typo correction for command-line flags to ELF and COFF lld driversNico Weber2019-05-071-2/+8
| | | | | | | | | | | | For lld-link, unknown '/'-style flags are treated as filenames on POSIX systems, so only '-'-style flags get typo correction for now. This matches clang-cl. PR37006. Differential Revision: https://reviews.llvm.org/D61443 llvm-svn: 360145
* [ELF] Reorder BitcodeFiles.empty() to call thinLTOCreateEmptyIndexFiles() in ↵Fangrui Song2019-05-073-15/+8
| | | | | | | | | | | | | | | | | only one place It makes the --plugin-opt=obj-path= and --plugin-opt=thinlto-index-only= behavior more consistent - the files will be created in the BitcodeFiles.empty() case, but I assume whether it behaves this way is not required by anyone. LTOObj->run() cannot run with empty BitcodeFiles. There would be an error: ld.lld: error: No available targets are compatible with triple "" Differential Revision: https://reviews.llvm.org/D61635 llvm-svn: 360129
* [PPC64] toc-indirect to toc-relative relaxationFangrui Song2019-05-077-14/+130
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is based on D54720 by Sean Fertile. When accessing a global symbol which is not defined in the translation unit, compilers will generate instructions that load the address from the toc entry. If the symbol is defined, non-preemptable, and addressable with a 32-bit signed offset from the toc pointer, the address can be computed directly. e.g. addis 3, 2, .LC0@toc@ha # R_PPC64_TOC16_HA ld 3, .LC0@toc@l(3) # R_PPC64_TOC16_LO_DS, load the address from a .toc entry ld/lwa 3, 0(3) # load the value from the address .section .toc,"aw",@progbits .LC0: .tc var[TC],var can be relaxed to addis 3,2,var@toc@ha # this may be relaxed to a nop, addi 3,3,var@toc@l # then this becomes addi 3,2,var@toc ld/lwa 3, 0(3) # load the value from the address We can delete the test ppc64-got-indirect.s as its purpose is covered by newly added ppc64-toc-relax.s and ppc64-toc-relax-constants.s Reviewed By: ruiu, sfertile Differential Revision: https://reviews.llvm.org/D60958 llvm-svn: 360112
* [ELF] Place SHT_NOTE sections with the same alignment into one PT_NOTEFangrui Song2019-05-031-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: While the generic ABI requires notes to be 8-byte aligned in ELF64, many vendor-specific notes (from Linux, NetBSD, Solaris, etc) use 4-byte alignment. In a PT_NOTE segment, if 4-byte aligned notes are followed by an 8-byte aligned note, the possible 4-byte padding may make consumers fail to parse the 8-byte aligned note. See PR41000 for a recent report about .note.gnu.property (NT_GNU_PROPERTY_TYPE_0). (Note, for NT_GNU_PROPERTY_TYPE_0, the consumers should probably migrate to PT_GNU_PROPERTY, but the alignment issue affects other notes as well.) To fix the issue, don't mix notes with different alignments in one PT_NOTE. If compilers emit 4-byte aligned notes before 8-byte aligned notes, we'll create at most 2 segments. sh_size%sh_addralign=0 is actually implied by the rule for linking unrecognized sections (in generic ABI), so we don't have to check that. Notes that match in name, type and attribute flags are concatenated into a single output section. The compilers have to ensure sh_size%sh_addralign=0 to make concatenated notes parsable. An alternative approach is to create a PT_NOTE for each SHT_NOTE, but we'll have to incur the sizeof(Elf64_Phdr)=56 overhead every time a new note section is introduced. Reviewers: ruiu, jakehehrlich, phosek, jhenderson, pcc, espindola Subscribers: emaste, arichardson, krytarowski, fedor.sergeev, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D61296 llvm-svn: 359853
* [ELF] --plugin-opt=thinlto-index-only: create empty index files even if all ↵Fangrui Song2019-05-023-19/+25
| | | | | | | | | | | | | | | | | | | bitcode files are lazy Summary: The gold plugin behavior (creating empty index files for lazy bitcode files) was added in D46034, but it missed the case when there is no non-lazy bitcode files, e.g. ld.lld -shared crti.o crtbeginS.o --start-lib bitcode.o --end-lib ... crti.o crtbeginS.o are not bitcode, but our distributed build system wants bitcode.o.thinlto.bc to confirm all expected outputs are created based on all of the modules provided to the linker. Differential Revision: https://reviews.llvm.org/D61420 llvm-svn: 359788
* [LLD] Emit dynamic relocations for references to script symbols in -pie linksBen Dunbobbin2019-05-011-5/+5
| | | | | | | | | | https://reviews.llvm.org/D55423 caused LLD to stop emitting dynamic relocations for references to script symbols in -pie links. This patch fixes that regression. https://reviews.llvm.org/D61298 llvm-svn: 359683
* [LLD][ELF] /DISCARD/ output sections should not be orphansAndrew Ng2019-04-301-0/+1
| | | | | | | | | | /DISCARD/ output sections were being treated as orphans. As a result, if a /DISCARD/ output section has been assigned a PHDR, it could cause incorrect assignment of sections to segments. Differential Revision: https://reviews.llvm.org/D61186 llvm-svn: 359565
* [LLD][ELF] Fix getRankProximity to "ignore" not live sectionsAndrew Ng2019-04-301-3/+2
| | | | | | | | | | This is a follow up to r358979 which made findOrphanPos only consider live sections. Unfortunately, this required change to getRankProximity, used by findOrphanPos, was missed. Differential Revision: https://reviews.llvm.org/D61197 llvm-svn: 359554
* [LLD][ELF] - Do not remove empty sections referenced in LOADADDR/ADDR commands.George Rimar2019-04-263-3/+12
| | | | | | | | | | | | | | | This is https://bugs.llvm.org//show_bug.cgi?id=38750. If script references empty sections in LOADADDR/ADDR commands .empty : { *(.empty ) } .text : AT(LOADADDR (.empty) + SIZEOF (.empty)) { *(.text) } then an empty section will be removed and LOADADDR/ADDR will evaluate to null. It is not that user may expect from using of the generic script, what is a common case. Differential revision: https://reviews.llvm.org/D54621 llvm-svn: 359279
* [ELF] Change std::max<uint64_t> to uint32_t for section alignmentFangrui Song2019-04-261-3/+3
| | | | | | | | | | | | | Summary: We use `uint32_t SectionBase::Alignment` and `uint32_t PhdrEntry::p_align` despite alignments being 64 bits in ELF64. Fix the std::max template arguments accordingly. The currently 160-byte InputSection will become 168 bytes if we make SectionBase::Alignment uint64_t. Differential Revision: https://reviews.llvm.org/D61171 llvm-svn: 359268
* [ELF] Delete a redundant SHT_NOBITS -> SHT_PROGBITS after D60131Fangrui Song2019-04-241-1/+0
| | | | | | Differential Revision: https://reviews.llvm.org/D61006 llvm-svn: 359099
* [PPC64] Consider localentry offset when computing branch distanceFangrui Song2019-04-241-1/+4
| | | | | | | | | | | | | | | Summary: We don't take localentry offset into account, and thus may fail to create a long branch when the gap is just a few bytes smaller than 2^25. relocation R_PPC64_REL24 out of range: 33554432 is not in [-33554432, 33554431] relocation R_PPC64_REL24 out of range: 33554436 is not in [-33554432, 33554431] Fix that by adding the offset to the symbol VA. Differential Revision: https://reviews.llvm.org/D61058 llvm-svn: 359094
* [ELF] Fix a gcc -Wextra warningFangrui Song2019-04-241-2/+2
| | | | | | | | | | Extracted from D61046. warning: enumeral and non-enumeral type in conditional expression [-Wextra] Cast SHF_ALLOC to avoid that. llvm-svn: 359070
* [ELF] Change default output section type to SHT_PROGBITSAndrew Ng2019-04-231-1/+1
| | | | | | | | | | | | This fixes an issue where a symbol only section at the start of a PT_LOAD segment, causes incorrect alignment of the file offset for the start of the segment which results in the output of an invalid ELF. SHT_PROGBITS was the default output section type in the past. Differential Revision: https://reviews.llvm.org/D60131 llvm-svn: 358981
* [ELF] Change findOrphanPos to only consider live sectionsAndrew Ng2019-04-231-4/+7
| | | | | | | | | | This patch changes the behaviour of findOrphanPos to only consider live sections when placing orphan sections. This used to be how it behaved in the past. Differential Revision: https://reviews.llvm.org/D60273 llvm-svn: 358979
* [PPC64] Allow R_PPC64_DTPREL* to preemptable local-dynamic symbolsFangrui Song2019-04-233-5/+3
| | | | | | | | Similar to D60945. Differential Revision: https://reviews.llvm.org/D60994 llvm-svn: 358950
* Use llvm::stable_sortFangrui Song2019-04-239-46/+38
| | | | | | | | | Make some small adjustment while touching the code: make parameters const, use less_first(), etc. Differential Revision: https://reviews.llvm.org/D60989 llvm-svn: 358943
* [LLD][ELF] - Do not forget to use ch_addralign field after decompressing the ↵George Rimar2019-04-221-0/+2
| | | | | | | | | | | | | sections. LLD did not use ELF::Chdr::ch_addralign for decompressed sections. This resulted in a broken output. Fixes https://bugs.llvm.org/show_bug.cgi?id=40482. Differential revision: https://reviews.llvm.org/D60959 llvm-svn: 358885
* [LLD][ELF] - Handle quoted strings in the linker scripts correctly.George Rimar2019-04-221-1/+1
| | | | | | | | | | | | | | This is the https://bugs.llvm.org/show_bug.cgi?id=41356, Seems it is kind of unusual case but it is possible to have sections that require quotes for their namings. Like "aaa bbb". This patch adds support for those. Differential revision: https://reviews.llvm.org/D60901 llvm-svn: 358874
* [ELF][X86] Allow R_386_TLS_LDO_32 and R_X86_64_DTPOFF{32,64} to preemptable ↵Fangrui Song2019-04-225-9/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | local-dynamic symbols Summary: Fixes PR35242. A simplified reproduce: thread_local int i; int f() { return i; } % {g++,clang++} -fPIC -shared -ftls-model=local-dynamic -fuse-ld=lld a.cc ld.lld: error: can't create dynamic relocation R_X86_64_DTPOFF32 against symbol: i in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output In isStaticLinkTimeConstant(), Syn.IsPreemptible is true, so it is not seen as a constant. The error is then issued in processRelocAux(). A symbol of the local-dynamic TLS model cannot be preempted but it can preempt symbols of the global-dynamic TLS model in other DSOs. So it makes some sense that the variable is not static. This patch fixes the linking error by changing getRelExpr() on R_386_TLS_LDO_32 and R_X86_64_DTPOFF{32,64} from R_ABS to R_DTPREL. R_PPC64_DTPREL_* and R_MIPS_TLS_DTPREL_* need similar fixes, but they are not handled in this patch. As a bonus, we use `if (Expr == R_ABS && !Config->Shared)` to find ld-to-le opportunities. R_ABS is overloaded here for such STT_TLS symbols. A dedicated R_DTPREL is clearer. Differential Revision: https://reviews.llvm.org/D60945 llvm-svn: 358870
* [ELF][X86] Rename R_RELAX_TLS_GD_TO_IE_END to R_RELAX_TLS_GD_TO_IE_GOTPLTFangrui Song2019-04-223-4/+4
| | | | | | | | | | Summary: This relocation type is used by R_386_TLS_GD. Its formula is the same as R_GOTPLT (e.g R_X86_64_GOT{32,64} R_386_TLS_GOTIE). Rename it to be clearer. Differential Revision: https://reviews.llvm.org/D60941 llvm-svn: 358868
* [LLD][ELF] - A fix for "linker script assignment loses relative nature of ↵George Rimar2019-04-181-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | section" bug. This is https://bugs.llvm.org//show_bug.cgi?id=39857. I added the comment with much more details to the bug page, the short version is below. The following script and code demonstrates the issue: aliasto__text = __text; SECTIONS { .text 0x1000 : { __text = . ; *(.text) } } ... call aliasto__text LLD fails with "cannot refer to absolute symbol: aliasto__text" error. It happens because at the moment of scanning the relocations we do not yet assign the correct/final/any section value for the symbol aliasto__text. I made a change to Relocations.cpp to fix that. Also, I had to remove the symbol-location.s test case completely, because now it does not trigger any error. Since now all linker scripts symbols are resolved to constants, no errors can be triggered at all it seems. I checked that it is consistent with the behavior of bfd and gold (they do not trigger errors for the case from symbol-location.s), so it should be OK. I.e. at least it is probably not the best possible, but natural behavior we obtained. Differential revision: https://reviews.llvm.org/D55423 llvm-svn: 358652
* [ELF] Respect NonAlloc when copying flags from the previous sectionsFangrui Song2019-04-182-1/+3
| | | | | | | | | | | | | | | | Summary: If the output section contains only symbol assignments, we copy flags from the previous sections. Don't set SHF_ALLOC if NonAlloc is true. We also have to change the type from SHT_NOBITS to SHT_PROGBITS. In ld.bfd, bfd_elf_get_default_section_type maps non-alloctable sections to SHT_PROGBITS. Non-alloctable SHT_NOBITS sections do not make sense. Fixes PR38626 Differential Revision: https://reviews.llvm.org/D59986 llvm-svn: 358650
* [LLD][ELF] - Fix the different behavior of the linker script symbols on ↵George Rimar2019-04-181-22/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | different platforms. This generalizes code and also fixes the broken behavior shown in one of our test cases for some targets, like x86-64. The issue occurs when the forward declarations are used in the script. One of the samples is: SECTIONS { foo = ADDR(.text) - ABSOLUTE(ADDR(.text)); }; In that case, we have a broken output when output target does not use thunks. That happens because thunks creating code (called from maybeAddThunks) calls Script->assignAddresses() at least one more time, what fixups the values. As a result final symbols values can be different on AArch64 and x86, for example. In this patch, I generalize and rename maybeAddThunks to finalizeAddressDependentContent and now it is used and called by all targets. Differential revision: https://reviews.llvm.org/D55550 llvm-svn: 358646
* [ELF] Place SectionPiece::{Live,Hash} bit fields togetherFangrui Song2019-04-183-7/+9
| | | | | | | | | | | | | | | | | | | | | | | | Summary: We access Live and OutputOff (which may share the same memory location) concurrently in 2 parallelForEachN loops. Separating them avoids subtle data races like D41884/PR35788. This patch places Live and Hash together. 2 reasons this is appealing: 1) Hash is immutable. Live is almost read-only - only written once in MarkLive.cpp where Hash is not accessed 2) we already discard low bits of Hash to decide ShardID. It doesn't matter much if we make 32-bit Hash to 31-bit. For a huge internal clang -O3 executable (1.6GiB), `Strings` in StringTableBuilder::finalizeStringTable contains at most 310253 elements. The expected number of pair-wise collisions 2^(-31) * C(310253,2) ~= 22.41 is too small to have a negative impact on performance. Actually, my benchmark shows there is actually a minor performance improvement. Differential Revision: https://reviews.llvm.org/D60765 llvm-svn: 358645
* lld: elf: Fix sections with explict addresses in regionsRui Ueyama2019-04-181-3/+4
| | | | | | | | | | | | | | | | | | | | | | | Patch by Gabriel Smith. The address for a section would be evaluated before the region was switched to. Because of this, the position within the region would not be updated. After the region is swapped to the dot would be set to the out of date position within the region, undoing the section address evaluation. To fix this, the region is swapped to before the section's address is evaluated. As part of the fallout of this, expandMemoryRegions needed to be gated in setDot on the condition that the evaluated address is less than the dot. This is for the case where sections are not listed from lowest address to highest address. Finally, a test for the case where sections are listed "out of order" was added. Differential Revision: https://reviews.llvm.org/D60744 llvm-svn: 358638
* [ELF] Use llvm::bsearch. NFCFangrui Song2019-04-172-8/+5
| | | | | | Differential Revision: https://reviews.llvm.org/D60813 llvm-svn: 358565
* ELF: Move build id computation to Writer. NFCI.Peter Collingbourne2019-04-163-66/+77
| | | | | | | | | | | | With partitions, each partition should have the same build id. This means that the build id needs to be only computed once, otherwise we will end up with different build ids in each partition as a result of the file contents changing. This change moves the computation of the build id into Writer so that it only happens once. Differential Revision: https://reviews.llvm.org/D60342 llvm-svn: 358536
* [ELF] Fix typo: .symtab_shndxr -> .symtab_shndxFangrui Song2019-04-122-5/+5
| | | | | | | | The typo was introduced to llvm MC in rL204769 (fixed in rL358247) and then to lld. Also, for relocatable-many-sections.s, the size of .symtab changed at some point and the formula needs update. llvm-svn: 358248
* Discard debuginfo for object files empty after GCRui Ueyama2019-04-105-19/+39
| | | | | | | | | | | | | | | | | | | | | | Patch by Robert O'Callahan. Rust projects tend to link in all object files from all dependent libraries and rely on --gc-sections to strip unused code and data. Unfortunately --gc-sections doesn't currently strip any debuginfo associated with GC'ed sections, so lld links in the full debuginfo from all dependencies even if almost all that code has been discarded. See https://github.com/rust-lang/rust/issues/56068 for some details. Properly stripping debuginfo for discarded sections would be difficult, but a simple approach that helps significantly is to mark debuginfo sections as live only if their associated object file has at least one live code/data section. This patch does that. In a (contrived but not totally artificial) Rust testcase linked above, it reduces the final binary size from 46MB to 5.1MB. Differential Revision: https://reviews.llvm.org/D54747 llvm-svn: 358069
* Rename a variable and add a comment.Rui Ueyama2019-04-102-3/+15
| | | | llvm-svn: 358049
* [RISCV] Fix range check for HI20/LO12/RVC_LUI relocationsChih-Mao Chen2019-04-091-12/+13
| | | | | | | | | | | | | | | | | The code previously specified a 32-bit range for R_RISCV_HI20 and R_RISCV_LO12_[IS], however this is incorrect as the maximum offset on RV64 that can be formed from the immediate of lui and the displacement of an I-type or S-type instruction is -0x80000800 to 0x7ffff7ff. There is also the same issue with a c.lui and LO12 pair, whose actual addressable range should be -0x20800 to 0x1f7ff. The tests will be included in the next patch that converts all RISC-V tests to use llvm-mc instead of yaml2obj, as assembler support has matured enough to write tests in them. Differential Revision: https://reviews.llvm.org/D60414 llvm-svn: 357995
* De-template SymbolTable::addShared.Rui Ueyama2019-04-093-28/+17
| | | | | | | Because of r357925, this member function doesn't have to be a template of ELFT. llvm-svn: 357982
* ELF: Move verneed tracking data structures out of VersionNeedSection.Peter Collingbourne2019-04-086-85/+87
| | | | | | | | | | | | | | | | For partitions I intend to use the same set of version indexes in each partition for simplicity. Since each partition will need its own VersionNeedSection this will require moving the verneed tracking out of VersionNeedSection. The way I've done this is to move most of the tracking into SharedFile. What will eventually become the per-partition tracking still lives in VersionNeedSection. As a bonus the code gets a little simpler and more consistent with how we handle verdef. Differential Revision: https://reviews.llvm.org/D60307 llvm-svn: 357926
* ELF: De-template SharedFile. NFCI.Peter Collingbourne2019-04-0811-181/+165
| | | | | | Differential Revision: https://reviews.llvm.org/D60305 llvm-svn: 357925
* Fix -emit-reloc against local symbols.Rui Ueyama2019-04-081-0/+5
| | | | | | | | | | | | | | | | Previously, we drop symbols starting with .L from the symbol table, so if there is a relocation that refers a .L symbol, it ended up referencing a null -- which happened to be interpreted as an absolute symbol. This patch copies all symbols including local ones if -emit-reloc is given. Fixes https://bugs.llvm.org/show_bug.cgi?id=41385 Differential Revision: https://reviews.llvm.org/D60306 llvm-svn: 357885
* ELF: De-template ELFFileBase. NFCI.Peter Collingbourne2019-04-056-67/+70
| | | | | | Differential Revision: https://reviews.llvm.org/D60304 llvm-svn: 357806
* ELF: Simplify. NFCI.Peter Collingbourne2019-04-051-7/+4
| | | | | | Differential Revision: https://reviews.llvm.org/D60299 llvm-svn: 357739
* Remove redundant parameters. NFC.Rui Ueyama2019-04-051-7/+7
| | | | llvm-svn: 357738
* ELF: Move SymtabSHNDX and getSectionIndex() to ObjFile. NFCI.Peter Collingbourne2019-04-042-11/+10
| | | | | | Differential Revision: https://reviews.llvm.org/D60244 llvm-svn: 357670
OpenPOWER on IntegriCloud