summaryrefslogtreecommitdiffstats
path: root/lld/ELF/SyntheticSections.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Revert "[ELF] -z combreloc: sort dynamic relocations by (symbol_index,r_offset)"Dmitri Gribenko2019-05-201-7/+9
| | | | | | | | This reverts commit r361125. This linker change breaks shared libraries in some subtle way on x86_64. (Specifically, gold segfaults when loading the LLVMgold.so plugin linked with lldb with this patch.) llvm-svn: 361150
* [ELF] -z combreloc: sort dynamic relocations by (symbol_index,r_offset)Fangrui Song2019-05-201-9/+7
| | | | | | | | | | | | | | | | | | | | | | Fixes PR41692. We currently sort dynamic relocations by (!is_relative,symbol_index). Change it to (symbol_index,r_offset). We still place relative relocations first because R_*_RELATIVE are the only dynamic relocations with 0 symbol index (except on MIPS, which doesn't use DT_REL[A]COUNT anyway). This makes `readelf -r` debugging easier (relocations to the same symbol are ordered by r_offset). Refactor the test combreloc.s (renamed from combrelocs.s) to check R_X86_64_RELATIVE, and delete --expand-relocs. Reviewed By: ruiu Differential Revision: https://reviews.llvm.org/D61477 llvm-svn: 361125
* [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
* Use llvm::stable_sortFangrui Song2019-04-231-8/+7
| | | | | | | | | 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
* [ELF] Place SectionPiece::{Live,Hash} bit fields togetherFangrui Song2019-04-181-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | 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
* ELF: Move build id computation to Writer. NFCI.Peter Collingbourne2019-04-161-62/+3
| | | | | | | | | | | | 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-121-2/+2
| | | | | | | | 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
* ELF: Move verneed tracking data structures out of VersionNeedSection.Peter Collingbourne2019-04-081-54/+57
| | | | | | | | | | | | | | | | 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-081-11/+11
| | | | | | Differential Revision: https://reviews.llvm.org/D60305 llvm-svn: 357925
* ELF: Perform per-section .ARM.exidx processing during ↵Peter Collingbourne2019-04-011-45/+38
| | | | | | | | | | | | combineEhFrameSections(). NFCI. And rename the function to combineEhSections(). This makes the processing of .ARM.exidx even more similar to .eh_frame and means that we can avoid an additional loop over InputSections. Differential Revision: https://reviews.llvm.org/D60026 llvm-svn: 357417
* [ELF] Rename SyntheticSection::empty to more appropriate isNeeded() with ↵Fangrui Song2019-04-011-18/+18
| | | | | | | | | | | | | | | | | | | | | | | opposite meaning Summary: Some synthetic sections can be empty while still being needed, thus they can't be removed by removeUnusedSyntheticSections(). Rename this member function to more appropriate isNeeded() with the opposite meaning. No functional change intended. Reviewers: ruiu, espindola Reviewed By: ruiu Subscribers: jhenderson, grimar, emaste, arichardson, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D59982 llvm-svn: 357377
* Replace `typedef A B` with `using B = A`. NFC.Rui Ueyama2019-04-011-3/+3
| | | | | | | | I did this using Perl. Differential Revision: https://reviews.llvm.org/D60003 llvm-svn: 357372
* [ELF][ARM] Recommit Redesign of .ARM.exidx handling to use a SyntheticSectionPeter Smith2019-03-281-22/+183
| | | | | | | | | | | | | | | | | | | | | | Recommit r356666 with fixes for buildbot failure, as well as handling for --emit-relocs, which we decide not to emit any relocation sections as the table is already position independent and an offline tool can deduce the relocations. Instead of creating extra Synthetic .ARM.exidx sections to account for gaps in the table, create a single .ARM.exidx SyntheticSection that can derive the contents of the gaps from a sorted list of the executable InputSections. This has the benefit of moving the ARM specific code for SyntheticSections in SHF_LINK_ORDER processing and the table merging code into the ARM specific SyntheticSection. This also makes it easier to create EXIDX_CANTUNWIND table entries for executable InputSections that don't have an associated .ARM.exidx section. Fixes pr40277 Differential Revision: https://reviews.llvm.org/D59216 llvm-svn: 357160
* [ELF] Change GOT*_FROM_END (relative to end(.got)) to GOTPLT* (start(.got.plt))Fangrui Song2019-03-251-9/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This should address remaining issues discussed in PR36555. Currently R_GOT*_FROM_END are exclusively used by x86 and x86_64 to express relocations types relative to the GOT base. We have _GLOBAL_OFFSET_TABLE_ (GOT base) = start(.got.plt) but end(.got) != start(.got.plt) This can have problems when _GLOBAL_OFFSET_TABLE_ is used as a symbol, e.g. glibc dl_machine_dynamic assumes _GLOBAL_OFFSET_TABLE_ is start(.got.plt), which is not true. extern const ElfW(Addr) _GLOBAL_OFFSET_TABLE_[] attribute_hidden; return _GLOBAL_OFFSET_TABLE_[0]; // R_X86_64_GOTPC32 In this patch, we * Change all GOT*_FROM_END to GOTPLT* to fix the problem. * Add HasGotPltOffRel to denote whether .got.plt should be kept even if the section is empty. * Simplify GotSection::empty and GotPltSection::empty by setting HasGotOffRel and HasGotPltOffRel according to GlobalOffsetTable early. The change of R_386_GOTPC makes X86::writePltHeader simpler as we don't have to compute the offset start(.got.plt) - Ebx (it is constant 0). We still diverge from ld.bfd (at least in most cases) and gold in that .got.plt and .got are not adjacent, but the advantage doing that is unclear. Reviewers: ruiu, sivachandra, espindola Subscribers: emaste, mehdi_amini, arichardson, dexonsmith, jdoerfert, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D59594 llvm-svn: 356968
* Simplify PltSection.Rui Ueyama2019-03-221-19/+10
| | | | | | | | | Previously, `Entries` contains pairs of symbols and their indices. The indices are always 0, x, 2x, 3x, ..., where x is the size of relocation entry. We didn't have to store that values because we can compute them when we consume them. llvm-svn: 356812
* [ELF][ARM] Revert Redesign of .ARM.exidx handling to use a SyntheticSectionPeter Smith2019-03-211-172/+22
| | | | | | | | | There is a reproducible buildbot failure (segfault) on the 2 stage clang-cmake-armv8-lld bot. Reverting while I investigate. Differential Revision: https://reviews.llvm.org/D59216 llvm-svn: 356684
* [ELF][ARM] Redesign of .ARM.exidx handling to use a SyntheticSectionPeter Smith2019-03-211-22/+172
| | | | | | | | | | | | | | | | | Instead of creating extra Synthetic .ARM.exidx sections to account for gaps in the table, create a single .ARM.exidx SyntheticSection that can derive the contents of the gaps from a sorted list of the executable InputSections. This has the benefit of moving the ARM specific code for SyntheticSections in SHF_LINK_ORDER processing and the table merging code into the ARM specific SyntheticSection. This also makes it easier to create EXIDX_CANTUNWIND table entries for executable InputSections that don't have an associated .ARM.exidx section. Fixes pr40277 Differential Revision: https://reviews.llvm.org/D59216 llvm-svn: 356666
* [ELF] Allow sh_entsize to be unrelated to sh_addralign and not a power of 2Fangrui Song2019-03-181-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This implements Rui Ueyama's idea in PR39044. I've checked that ld.bfd and gold do not have the power-of-2 requirement and do not require sh_entsize to be a multiple of sh_align. Now on the updated test merge-entsize.s, all the 3 linkers happily create .rodata that is not 3-byte aligned. This has a use case in Linux arch/x86/crypto/sha512-avx2-asm.S It uses sh_entsize of 640, which is not a power of 2. See https://github.com/ClangBuiltLinux/linux/issues/417 Reviewers: ruiu, espindola Reviewed By: ruiu Subscribers: nickdesaulniers, E5ten, emaste, arichardson, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D59478 llvm-svn: 356428
* ELF: Don't add .dynamic strings to .dynstr early.Peter Collingbourne2019-03-121-19/+17
| | | | | | | | | | This does not appear to be necessary because StringTableSection does not need to be finalized, which also means that we can remove the call to finalizeSynthetic on .dynstr. Differential Revision: https://reviews.llvm.org/D59240 llvm-svn: 355977
* ELF: De-template OutputSection::finalize() and MipsGotSection::build(). NFCI.Peter Collingbourne2019-03-061-6/+1
| | | | | | Differential Revision: https://reviews.llvm.org/D58810 llvm-svn: 355479
* ELF: Extract a non-ELFT base class for VersionNeedSection.Peter Collingbourne2019-03-061-18/+11
| | | | | | | | | | | We're going to need a separate VersionNeedSection for each partition, and the partition data structure won't be templated. With this the VersionTableSection class no longer needs ELFT, so detemplate it. Differential Revision: https://reviews.llvm.org/D58808 llvm-svn: 355478
* ELF: Write .eh_frame_hdr explicitly after writing .eh_frame.Peter Collingbourne2019-02-281-2/+14
| | | | | | | | | | | This lets us remove the special case from Writer::writeSections(), and also fixes a bug where .eh_frame_hdr isn't necessarily written in the correct order if a linker script moves .eh_frame and .eh_frame_hdr into the same output section. Differential Revision: https://reviews.llvm.org/D58795 llvm-svn: 355153
* ELF: Remove dead code. NFCI.Peter Collingbourne2019-02-211-3/+2
| | | | | | | | | RelocationBaseSection is not used in -r links, so Config->Relocatable will always be false. Differential Revision: https://reviews.llvm.org/D58489 llvm-svn: 354607
* [MIPS] Handle cross-mode (regular <-> microMIPS) jumpsSimon Atanasyan2019-02-191-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The patch solves two tasks: 1. MIPS ABI allows to mix regular and microMIPS code and perform cross-mode jumps. Linker needs to detect such cases and replace jump/branch instructions by their cross-mode equivalents. 2. Other tools like dunamic linkers need to recognize cases when dynamic table entries, e_entry field of an ELF header etc point to microMIPS symbol. Linker should provide such information. The first task is implemented in the `MIPS<ELFT>::relocateOne()` method. New routine `fixupCrossModeJump` detects ISA mode change, checks and replaces an instruction. The main problem is how to recognize that relocation target is microMIPS symbol. For absolute and section symbols compiler or assembler set the less-significant bit of the symbol's value or sum of the symbol's value and addend. And this bit signals to linker about microMIPS code. For global symbols compiler cannot do the same trick because other tools like, for example, disassembler wants to know an actual position of the symbol. So compiler sets STO_MIPS_MICROMIPS flag in the `st_other` field. In `MIPS<ELFT>::relocateOne()` method we have a symbol's value only and cannot access any symbol's attributes. To pass type of the symbol (regular/microMIPS) to that routine as well as other places where we write a symbol value as-is (.dynamic section, `Elf_Ehdr::e_entry` field etc) we set when necessary a less-significant bit in the `getSymVA` function. Differential revision: https://reviews.llvm.org/D40147 llvm-svn: 354311
* [PPC64] Preserve LocalEntry when linkingRui Ueyama2019-02-151-0/+5
| | | | | | | | | | | | | On PowerPC64, it is necessary to keep the LocalEntry bits in st_other, especially when -r is used. Otherwise, when the resulting object is used in a posterior linking, LocalEntry info will be unavailable and functions may be called through the wrong entrypoint. Patch by Leandro Lupori. Differential Revision: https://reviews.llvm.org/D56782 llvm-svn: 354184
* ELF: Allow GOT relocs pointing to non-preemptable ifunc to resolve to an ↵Peter Collingbourne2019-02-131-4/+1
| | | | | | | | | | | | | | | | IRELATIVE where possible. Non-GOT non-PLT relocations to non-preemptible ifuncs result in the creation of a canonical PLT, which now takes the identity of the IFUNC in the symbol table. This (a) ensures address consistency inside and outside the module, and (b) fixes a bug where some of these relocations end up pointing to the resolver. Fixes (at least) PR40474 and PR40501. Differential Revision: https://reviews.llvm.org/D57371 llvm-svn: 353981
* Remove a small header that is used only by one file. NFC.Rui Ueyama2019-02-061-1/+11
| | | | llvm-svn: 353331
* Recommit r353293 "[LLD][ELF] - Set DF_STATIC_TLS flag for i386 target."George Rimar2019-02-061-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With the following changes: 1) Compilation fix: std::atomic<bool> HasStaticTlsModel = false; -> std::atomic<bool> HasStaticTlsModel{false}; 2) Adjusted the comment in code. Initial commit message: DF_STATIC_TLS flag indicates that the shared object or executable contains code using a static thread-local storage scheme. Patch checks if IE/LE relocations were used to check if the code uses a static model. If so it sets the DF_STATIC_TLS flag. Differential revision: https://reviews.llvm.org/D57749 ---- Modified : /lld/trunk/ELF/Arch/X86.cpp Modified : /lld/trunk/ELF/Config.h Modified : /lld/trunk/ELF/SyntheticSections.cpp Added : /lld/trunk/test/ELF/Inputs/i386-static-tls-model1.s Added : /lld/trunk/test/ELF/Inputs/i386-static-tls-model2.s Added : /lld/trunk/test/ELF/Inputs/i386-static-tls-model3.s Added : /lld/trunk/test/ELF/Inputs/i386-static-tls-model4.s Added : /lld/trunk/test/ELF/i386-static-tls-model.s Modified : /lld/trunk/test/ELF/i386-tls-ie-shared.s Modified : /lld/trunk/test/ELF/tls-dynamic-i686.s Modified : /lld/trunk/test/ELF/tls-opt-iele-i686-nopic.s llvm-svn: 353299
* Revert r353293 "[LLD][ELF] - Set DF_STATIC_TLS flag for i386 target."George Rimar2019-02-061-2/+0
| | | | | | | | | | | | It broke BB: http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/43450 http://lab.llvm.org:8011/builders/lld-x86_64-freebsd/builds/27891 Error is: tools/lld/ELF/Config.h:84:41: error: copying member subobject of type 'std::atomic<bool>' invokes deleted constructor std::atomic<bool> HasStaticTlsModel = false; llvm-svn: 353297
* [LLD][ELF] - Set DF_STATIC_TLS flag for i386 target.George Rimar2019-02-061-0/+2
| | | | | | | | | | | | DF_STATIC_TLS flag indicates that the shared object or executable contains code using a static thread-local storage scheme. Patch checks if IE/LE relocations were used to check if the code uses a static model. If so it sets the DF_STATIC_TLS flag. Differential revision: https://reviews.llvm.org/D57749 llvm-svn: 353293
* ELF: Set sh_info on RelaIplt to point to the IgotPlt output section.Peter Collingbourne2019-01-281-1/+3
| | | | | | | | | | | Previously we were setting it to the GotPlt output section, which is incorrect on ARM where this section is in .got. In static binaries this can lead to sh_info being set to -1 (because there is no .got.plt) which results in various tools rejecting the output file. Differential Revision: https://reviews.llvm.org/D57274 llvm-svn: 352413
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* [lld] Use range-based llvm::sortMandeep Singh Grang2019-01-181-1/+1
| | | | llvm-svn: 351612
* Use error() instead of fatal() to report an invalid address range.Rui Ueyama2018-12-261-15/+7
| | | | | | In this patch we also use toString() to stringize a section. llvm-svn: 350070
* gdb-index: Handle errors when parsing rangesDavid Blaikie2018-12-221-6/+18
| | | | | | | | | | When parsing CU ranges for gdb-index, handle the error (now propagated up though the API lld is calling here - previously the error was printed within the libDebugInfo API, not allowing lld to format or handle the message at all) - including information about the object and archive name, as well as failing the link. llvm-svn: 349979
* [ELF] .gnu.hash bloom filter: use Shift2 = 26 instead of 6Fangrui Song2018-12-211-0/+2
| | | | | | | | | | | | | | | | | | | | | Summary: For the 2-bit bloom filter, we currently pick the bits Hash%64 and Hash>>6%64 (Shift2=6), but bits [6:...] are also used to select a word, causing a loss of precision. In this patch, we choose Shift2=26, with is suggested by Ambrose Feinstein. Note, Shift2 is computed as maskbitslog2 in bfd/elflink.c and gold/dynobj.cc It is varying with the number of dynamic symbols but we don't necessarily copy its rule. Reviewers: ruiu, espindola Reviewed By: ruiu Subscribers: emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D55971 llvm-svn: 349966
* [ELF] - Allow discarding .dynsym from the linker script.George Rimar2018-12-101-3/+8
| | | | | | | | | This is a part of https://bugs.llvm.org/show_bug.cgi?id=39810. The patch allows discarding the .dynsym section using linker script. Differential revision: https://reviews.llvm.org/D55218 llvm-svn: 348748
* [LLD][ELF] - Support discarding .dynstr section.George Rimar2018-12-101-4/+9
| | | | | | | | | This is a part of https://bugs.llvm.org/show_bug.cgi?id=39810. The patch allows discarding the .dynstr section using linker script. Differential revision: https://reviews.llvm.org/D55215 llvm-svn: 348746
* [ELF] --gdb-index: use lower_bound to compute relative CU index in the ↵Fangrui Song2018-11-291-5/+6
| | | | | | | | | | | | | | | | | | | | | | object file Summary: This reinstates what I originally intended to do in D54361. It removes the assumption that .debug_gnu_pubnames has increasing CuOffset. Now we do better than gold here: when .debug_gnu_pubnames contains multiple sets, gold would think every set has the same CU index as the first set (incorrect). Reviewed By: ruiu Reviewers: ruiu, dblaikie, espindola Subscribers: emaste, arichardson, arphaman, llvm-commits Differential Revision: https://reviews.llvm.org/D54483 llvm-svn: 347820
* [ELF] Use more specific method to calculate DT_PLTRELSZPeter Smith2018-11-281-1/+13
| | | | | | | | | | | | | | | | | | | | The DT_PLTRELSZ dynamic tag is calculated using the size of the OutputSection containing the In.RelaPlt InputSection. This will work for the default no linker script case and the majority of linker scripts. Unfortunately it doesn't work for some 'almost' sensible linker scripts. It is permitted by ELF to have a single OutputSection containing both In.RelaDyn, In.RelaPlt and In.RelaIPlt. It is also permissible for the range of memory [DT_RELA, DT_RELA + DT_RELASZ) and the range [DT_JMPREL, DT_JMPREL + DT_JMPRELSZ) to overlap as long as the the latter range is at the end. To support this type of linker script use the specific InputSection sizes. Fixes pr39678 Differential Revision: https://reviews.llvm.org/D54759 llvm-svn: 347736
* [ELF] - Implement -z nodefaultlibGeorge Rimar2018-11-271-0/+2
| | | | | | | | | | | | | | | | | | | | This is https://bugs.llvm.org//show_bug.cgi?id=38978 Spec says that: "Objects may be built with the -z nodefaultlib option to suppress any search of the default locations at runtime. Use of this option implies that all the dependencies of an object can be located using its runpaths. Without this option, which is the most common case, no matter how you augment the runtime linker's library search path, its last element is always /usr/lib for 32-bit objects and /usr/lib/64 for 64-bit objects." The patch implements this option. Differential revision: https://reviews.llvm.org/D54577 llvm-svn: 347647
* [LLD][ELF] - Remove the excessive safety return. NFC.George Rimar2018-11-261-3/+0
| | | | | | | | | | | | We explicitly call finalizeContents() only once for DynamicSection. The code testing we do not do it twice is just excessive. It could be an assert, but we don't do that for other sections, so does not seem we should do it here too. llvm-svn: 347543
* [ELF] Write IPLT header in -static -z retpolineplt modeFangrui Song2018-11-211-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | Summary: This fixes PR39711: -static -z retpolineplt does not produce retpoline PLT header. -z now is not relevant. Statically linked executable does not have PLT, but may have IPLT with no header. When -z retpolineplt is specified, however, the repoline PLT header should still be emitted. I've checked that this fixes the FreeBSD reproduce in PR39711 and a Linux program statically linked against glibc. The programm print "Hi" rather than SIGILL/SIGSEGV. getPltEntryOffset may look dirty after this patch, but it can be cleaned up later. Another possible improvement is that when there are non-preemptible IFUNC symbols (rare case, e.g. -Bsymbolic), both In.Plt and In.Iplt can be non-empty and we'll emit the retpoline PLT header twice. Reviewers: espindola, emaste, chandlerc, ruiu Reviewed By: emaste Subscribers: emaste, arichardson, krytarowski, llvm-commits Differential Revision: https://reviews.llvm.org/D54782 llvm-svn: 347404
* [PPC64] Long branch thunks.Sean Fertile2018-11-141-0/+47
| | | | | | | | | | | | | | | | | | On PowerPC64, when a function call offset is too large to encode in a call instruction the address is stored in a table in the data segment. A thunk is used to load the branch target address from the table relative to the TOC-pointer and indirectly branch to the callee. When linking position-dependent code the addresses are stored directly in the table, for position-independent code the table is allocated and filled in at load time by the dynamic linker. For position-independent code the branch targets could have gone in the .got.plt but using the .branch_lt section for both position dependent and position independent binaries keeps it consitent and helps keep this PPC64 specific logic seperated from the target-independent code handling the .got.plt. Differential Revision: https://reviews.llvm.org/D53408 llvm-svn: 346877
* [ELF] Rename NameTypeEntry to NameAttrEntry and its field "Type" to ↵Fangrui Song2018-11-131-10/+10
| | | | | | | | | | | | | | | | | | | CuIndexAndAttrs Summary: NameTypeEntry::Type is a bit-packed value of CU index+attributes (https://sourceware.org/gdb//onlinedocs/gdb/Index-Section-Format.html), which is named cu_index_and_attrs in a local variable in gdb/dwarf2read.c:dw2_symtab_iter_next The new name CuIndexAndAttrs is more meaningful. Reviewers: ruiu, dblaikie, espindola Reviewed By: dblaikie Subscribers: emaste, aprantl, arichardson, JDevlieghere, arphaman, llvm-commits Differential Revision: https://reviews.llvm.org/D54481 llvm-svn: 346794
* [ELF] .gdb_index: fix CuOff when a .debug_info section contains more than 1 ↵Fangrui Song2018-11-131-9/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | DW_TAG_compile_unit Summary: Idx passed to readPubNamesAndTypes was an index into Chunks, not an index into the CU list. This would be incorrect if some .debug_info section contained more than 1 DW_TAG_compile_unit. In real world, glibc Scrt1.o is a partial link of start.os abi-note.o init.o and contains 2 CUs in debug builds. Without this patch, any application linking such Scrt1.o would have invalid .gdb_index The issue could be demonstrated by: (gdb) py print(gdb.lookup_global_symbol('main')) None Reviewers: espindola, ruiu Reviewed By: ruiu Subscribers: Higuoxing, grimar, dblaikie, emaste, aprantl, arichardson, JDevlieghere, arphaman, llvm-commits Differential Revision: https://reviews.llvm.org/D54361 llvm-svn: 346747
* [ELF] Change GnuPub{Names,Types}Section from StringRef to LLDDWARFSectionFangrui Song2018-11-111-5/+7
| | | | | | | | | | | | | | | Summary: The debug_info_offset value may be relocated. This is lld side change of D54375. Reviewers: ruiu, dblaikie, grimar, espindola Subscribers: emaste, arichardson, JDevlieghere, llvm-commits Differential Revision: https://reviews.llvm.org/D54376 llvm-svn: 346616
* [ELF] Change sh_link of .rel{,a}.plt to make GNU strip happyFangrui Song2018-11-011-9/+5
| | | | | | | | | | | | | | | | | | | | | | | | Summary: D52830 sets sh_link to .symtab in static link, which breaks executable stripped by GNU strip. It may also be odd that .rela.plt (SHF_ALLOC) points to .symtab (non-SHF_ALLOC). Change the logic on pcc's suggestion. Before: % clang -fuse-ld=lld -static -xc =(printf 'int main(){}') # or gcc % strip a.out; ./a.out unexpected reloc type in static binary[1] 61634 segmentation fault ./a.out Reviewers: ruiu, grimar, emaste, espindola Reviewed By: ruiu Subscribers: pcc, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D53993 llvm-svn: 345899
* [ELF] Fallback to sh_link=0 if neither .dynsym nor .symtab existsFangrui Song2018-10-301-5/+9
| | | | | | | | | | | | | | Summary: .rela.plt may only contain R_*_{,I}RELATIVE relocations and not need a symbol table link. bfd/gold fallbacks to sh_link=0 in this case. Without this patch, ld.lld --strip-all caused lld to dereference a null pointer. Reviewers: ruiu, grimar, espindola Reviewed By: ruiu Subscribers: emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D53881 llvm-svn: 345648
* Remove a global variable that we can live without.Rui Ueyama2018-10-231-1/+1
| | | | | | | | | | Out::DebugInfo was used only by GdbIndex class to determine if we need to create a .gdb_index section, but we can do the same check without it. Added a test that this patch doesn't change the existing behavior. llvm-svn: 345058
OpenPOWER on IntegriCloud