summaryrefslogtreecommitdiffstats
path: root/lld/ELF/LinkerScript.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [ELF] Delete redundant isLive() check. NFCFangrui Song2019-12-151-2/+0
|
* [ELF] Support input section description .rel[a].dyn in /DISCARD/Fangrui Song2019-11-251-1/+1
| | | | | | Reviewed By: ruiu Differential Revision: https://reviews.llvm.org/D70695
* [ELF] Wrap things in `namespace lld { namespace elf {`, NFCFangrui Song2019-10-071-3/+6
| | | | | | | | | | | This makes it clear `ELF/**/*.cpp` files define things in the `lld::elf` namespace and simplifies `elf::foo` to `foo`. Reviewed By: atanasyan, grimar, ruiu Differential Revision: https://reviews.llvm.org/D68323 llvm-svn: 373885
* ELF: Don't merge SHF_LINK_ORDER sections for different output sections in ↵Peter Collingbourne2019-09-301-18/+42
| | | | | | | | | | | | | | | | | | | | | relocatable links. Merging SHF_LINK_ORDER sections can affect semantics if the sh_link fields point to different sections. Specifically, for SHF_LINK_ORDER sections, the sh_link field acts as a reverse dependency from the linked section, causing the SHF_LINK_ORDER section to be included if the linked section is included. Merging sections with different sh_link fields will cause the entire contents of the SHF_LINK_ORDER section to be associated with a single (arbitrarily chosen) output section, whereas the correct semantics are for the individual pieces of the SHF_LINK_ORDER section to be associated with their linked output sections. As a result we can end up incorrectly dropping SHF_LINK_ORDER section contents or including the wrong section contents, depending on which linked sections were chosen. Differential Revision: https://reviews.llvm.org/D68094 llvm-svn: 373255
* [ELF] Set SectionBase::partition in processSectionCommandsFangrui Song2019-09-261-0/+5
| | | | | | | | | | | | | | | | | Fixes PR43461 (regression caused by D67504) The partition field of a SECTIONS-specified section is not set after D67504. The 0 value affects findSection() which checks if the partition field is 1. So `Out::initArray = findSection(".init_array")` is null, and DT_INIT_ARRAYSZ is not set. Reviewed By: peter.smith Differential Revision: https://reviews.llvm.org/D68087 llvm-svn: 372996
* [ELF] Delete SectionBase::assignedFangrui Song2019-09-241-5/+5
| | | | | | | | | | | | | D67504 removed uses of `assigned` from OutputSection::addSection, which makes `assigned` purely used in processSectionCommands() and its callees. By replacing its references with `parent`, we can remove `assigned`. Reviewed By: grimar Differential Revision: https://reviews.llvm.org/D67531 llvm-svn: 372735
* [ELF] Make MergeInputSection merging aware of output sectionsFangrui Song2019-09-241-54/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes PR38748 mergeSections() calls getOutputSectionName() to get output section names. Two MergeInputSections may be merged even if they are made different by SECTIONS commands. This patch moves mergeSections() after processSectionCommands() and addOrphanSections() to fix the issue. The new pass is renamed to OutputSection::finalizeInputSections(). processSectionCommands() and addorphanSections() are changed to add sections to InputSectionDescription::sectionBases. finalizeInputSections() merges MergeInputSections and migrates `sectionBases` to `sections`. For the -r case, we drop an optimization that tries keeping sh_entsize non-zero. This is for the simplicity of addOrphanSections(). The updated merge-entsize2.s reflects the change. Reviewed By: grimar Differential Revision: https://reviews.llvm.org/D67504 llvm-svn: 372734
* [ELF] Map the ELF header at imageBaseFangrui Song2019-09-161-26/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If there is no readonly section, we map: * The ELF header at imageBase+maxPageSize * Program headers at imageBase+maxPageSize+sizeof(Ehdr) * The first section .text at imageBase+maxPageSize+sizeof(Ehdr)+sizeof(program headers) Due to the interaction between Writer<ELFT>::fixSectionAlignments and LinkerScript::allocateHeaders, `alignDown(p_vaddr(R PT_LOAD)) = alignDown(p_vaddr(RX PT_LOAD))`. The RX PT_LOAD will override the R PT_LOAD at runtime, which is not ideal: ``` // PHDR at 0x401034, should be 0x400034 PHDR 0x000034 0x00401034 0x00401034 0x000a0 0x000a0 R 0x4 // R PT_LOAD contains just Ehdr and program headers. // At 0x401000, should be 0x400000 LOAD 0x000000 0x00401000 0x00401000 0x000d4 0x000d4 R 0x1000 LOAD 0x0000d4 0x004010d4 0x004010d4 0x00001 0x00001 R E 0x1000 ``` * createPhdrs allocates the headers to the R PT_LOAD. * fixSectionAlignments assigns `imageBase+maxPageSize+sizeof(Ehdr)+sizeof(program headers)` (formula: `alignTo(dot, maxPageSize) + dot % config->maxPageSize`) to addrExpr of .text * allocateHeaders computes the minimum address among SHF_ALLOC sections, i.e. addr(.text) * allocateHeaders sets address of ELF header to `addr(.text)-sizeof(Ehdr)-sizeof(program headers) = imageBase+maxPageSize` The main observation is that when the SECTIONS command is not used, we don't have to call allocateHeaders. This requires an assumption that the presence of PT_PHDR and addresses of headers can be decided regardless of address information. This may seem natural because dot is not manipulated by a linker script. The other thing is that we have to drop the special rule for -T<section> in `getInitialDot`. If -Ttext is smaller than the image base, the headers will not be allocated with the old behavior (allocateHeaders is called) but always allocated with the new behavior. The behavior change is not a problem. Whether and where headers are allocated can vary among linkers, or ld.bfd across different versions (--enable-separate-code or not). It is thus advised to use a linker script with the PHDRS command to have a consistent behavior across linkers. If PT_PHDR is needed, an explicit --image-base can be a simpler alternative. Differential Revision: https://reviews.llvm.org/D67325 llvm-svn: 371957
* [ELF] Delete a redundant assignment to SectionBase::assigned. NFCFangrui Song2019-09-131-1/+0
| | | | | | | LinkerScript::discard marks a section dead. It is unnecessary to set the `assigned` bit. llvm-svn: 371804
* Revert "Revert r370635, it caused PR43241."Fangrui Song2019-09-061-45/+37
| | | | | | This reverts commit 50d2dca22b3b05d0ee4883b0cbf93d7d15f241fc. llvm-svn: 371215
* Revert r370635, it caused PR43241.Nico Weber2019-09-061-37/+45
| | | | llvm-svn: 371202
* [ELF] Do not ICF two sections with different output sections (by SECTIONS ↵Fangrui Song2019-09-021-45/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | commands) Fixes PR39418. Complements D47241 (the non-linker-script case). processSectionCommands() assigns input sections to output sections. ICF is called before it, so .text.foo and .text.bar may be folded even if their output sections are made different by SECTIONS commands. ``` markLive<ELFT>() doIcf<ELFT>() // During ICF, we don't know the output sections writeResult() combineEhSections<ELFT>() script->processSectionCommands() // InputSection -> OutputSection assignment ``` This patch splits processSectionCommands() into processSectionCommands() and processSymbolAssignments(), and moves processSectionCommands() before ICF: ``` markLive<ELFT>() combineEhSections<ELFT>() script->processSectionCommands() doIcf<ELFT>() // should remove folded input sections writeResult() script->processSymbolAssignments() ``` An alternative approach is to unfold a section `sec` in processSectionCommands() when we find `sec` and `sec->repl` belong to different output sections. I feel this patch is superior because this can fold more sections and the decouple of SectionCommand/SymbolAssignment gives flexibility: * An ExprValue can't be evaluated before its section is assigned to an output section -> we can delete getOutputSectionVA and simplify another place where we had to check if the output section is null. Moreover, a case in linkerscript/early-assign-symbol.s can be handled now. * processSectionCommands/processSymbolAssignments can be freely moved around. Reviewed By: ruiu Differential Revision: https://reviews.llvm.org/D66717 llvm-svn: 370635
* [ELF] Make LinkerScript::assignAddresses iterativeFangrui Song2019-08-261-1/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | PR42990. For `SECTIONS { b = a; . = 0xff00 + (a >> 8); a = .; }`, we currently set st_value(a)=0xff00 while st_value(b)=0xffff. The following call tree demonstrates the problem: ``` link<ELF64LE>(Args); Script->declareSymbols(); // insert a and b as absolute Defined Writer<ELFT>().run(); Script->processSectionCommands(); addSymbol(cmd); // a and b are re-inserted. LinkerScript::getSymbolValue // is lazily called by subsequent evaluation finalizeSections(); forEachRelSec(scanRelocations<ELFT>); processRelocAux // another problem PR42506, not affected by this patch finalizeAddressDependentContent(); // loop executed once script->assignAddresses(); // a = 0, b = 0xff00 script->assignAddresses(); // a = 0xff00, _end = 0xffff ``` We need another assignAddresses() to finalize the value of `a`. This patch 1) modifies assignAddress() to track the original section/value of each symbol and return a symbol whose section/value has changed. 2) moves the post-finalizeSections assignAddress() inside the loop of finalizeAddressDependentContent() and makes it iterative. Symbol assignment may not converge so we make a few attempts before bailing out. Note, assignAddresses() must be called at least twice. The penultimate call finalized section addresses while the last finalized symbol values. It is somewhat obscure and there was no comment. linkerscript/addr-zero.test tests this. Reviewed By: ruiu Differential Revision: https://reviews.llvm.org/D66279 llvm-svn: 369889
* [ELF] Delete a redundant dyn_cast<InputSection>. NFCFangrui Song2019-08-251-6/+5
| | | | llvm-svn: 369868
* Fix lld on GCC 5.1 after the C++14 moveJF Bastien2019-08-151-26/+24
| | | | | | | | | | | | | | | | | | | | | | | Summary: libstdc++ in GCC 5.1 has some bugs. The move to C++14 in D66195 triggered one such bug caused by the new constexpr support in C++14, and the implementation doing SFINAE wrong with the comparator to std::stable_sort. Here's a small repro: https://godbolt.org/z/2QC3-n The fix is to inline the lambdas directly into the llvm::stable_sort call instead of erasing them through a std::function. The code is more readable as well. Reviewers: thakis, ruiu, espindola Subscribers: emaste, arichardson, MaskRay, jkorous, dexonsmith, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D66306 llvm-svn: 369023
* [LLD] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere2019-08-141-2/+2
| | | | | | | | | | 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
* [ELF] Rename odd variable names "New" after r365730. NFCFangrui Song2019-08-131-8/+8
| | | | | | | | | | New -> newSym or newFlags Reviewed By: atanasyan Differential Revision: https://reviews.llvm.org/D66127 llvm-svn: 368651
* [ELF] Expand regions for gaps due to explicit addressFangrui Song2019-08-091-0/+8
| | | | | | | | | | 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
* [ELF] Fix variable names in comments after VariableName -> variableName changeFangrui Song2019-07-161-3/+3
| | | | | | Also fix some typos. llvm-svn: 366181
* [Coding style change] Rename variables so that they start with a lowercase ↵Rui Ueyama2019-07-101-489/+489
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* ELF: Create synthetic sections for loadable partitions.Peter Collingbourne2019-06-071-5/+7
| | | | | | | | | | | | | | | We create several types of synthetic sections for loadable partitions, including: - The dynamic symbol table. This allows code outside of the loadable partitions to find entry points with dlsym. - Creating a dynamic symbol table also requires the creation of several other synthetic sections for the partition, such as the dynamic table and hash table sections. - The partition's ELF header is represented as a synthetic section in the combined output file, and will be used by llvm-objcopy to extract partitions. Differential Revision: https://reviews.llvm.org/D62350 llvm-svn: 362819
* ELF: Introduce a separate bit for tracking whether an output section has ↵Peter Collingbourne2019-06-031-4/+3
| | | | | | | | | | | | | | | | | | ever had an input section added to it. NFCI. We currently (ab)use the Live bit on output sections to track whether the section has ever had an input section added to it, and then later use it during orphan placement. This will conflict with one of my upcoming partition-related changes that will assign all output sections to a partition (thus marking them as live) so that they can be added to the correct segment by the code that creates program headers. Instead of using the Live bit for this purpose, create a new flag and start using it to track the property explicitly. Differential Revision: https://reviews.llvm.org/D62348 llvm-svn: 362444
* [LLD][ELF] - Remove dead code. NFC.George Rimar2019-06-031-1/+0
| | | | | | I believe this line was dead after r362356. llvm-svn: 362367
* [ELF] Don't create an output section named `/DISCARD/` if it is assigned to ↵Fangrui Song2019-06-031-0/+3
| | | | | | | | | | | | | | | | the special phdr `NONE` Fixes the remaining issue of PR41673 after D61186: with `/DISCARD/ { ... } :NONE`, we may create an output section named `/DISCARD/`. Note, if an input section is named `/DISCARD/`, ld.bfd discards it but lld keeps it. It is probably not worth copying this behavior as it is unrealistic. Reviewed By: ruiu Differential Revision: https://reviews.llvm.org/D62768 llvm-svn: 362356
* ELF: Add basic partition data structures and behaviours.Peter Collingbourne2019-05-291-11/+15
| | | | | | | | | | | | | | This change causes us to read partition specifications from partition specification sections and split output sections into partitions according to their reachability from partition entry points. This is only the first step towards a full implementation of partitions. Later changes will add additional synthetic sections to each partition so that they can be loaded independently. Differential Revision: https://reviews.llvm.org/D60353 llvm-svn: 361925
* Move code for symbol resolution from SymbolTable.cpp to Symbols.cpp.Rui Ueyama2019-05-231-2/+2
| | | | | | | | | | | | | | | | My recent commits separated symbol resolution from the symbol table, so the functions to resolve symbols are now in a somewhat wrong file. This patch moves it to Symbols.cpp. The functions are now member functions of the symbol. This is code move change. I modified function names so that they are appropriate as member functions, though. No functionality change intended. Differential Revision: https://reviews.llvm.org/D62290 llvm-svn: 361474
* [ELF] Don't advance position in a memory region when assigning to the DotFangrui Song2019-05-211-2/+0
| | | | | | | | | | | | | For memory5.test, ld.bfd appears to ignore `. += 0x2000;`, so the test was testing a wrong behavior. After deleting the code added in rLLD336335, we match ld.bfd and thus fix PR41357. PR37836 (memory4.test) seems to have been fixed by another change. Reviewed By: ruiu Differential Revision: https://reviews.llvm.org/D62177 llvm-svn: 361228
* Make replaceSymbol a member function of Symbol.Rui Ueyama2019-05-201-2/+2
| | | | | | | | | | | | This is a mechanical rewrite of replaceSymbol(A, B) to A->replace(B). I also added a comment to Symbol::replace(). Technically this change is not necessary, but this change makes code a bit more concise. Differential Revision: https://reviews.llvm.org/D62117 llvm-svn: 361123
* Move symbol resolution code out of SymbolTable class.Rui Ueyama2019-05-171-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is the last patch of the series of patches to make it possible to resolve symbols without asking SymbolTable to do so. The main point of this patch is the introduction of `elf::resolveSymbol(Symbol *Old, Symbol *New)`. That function resolves or merges given symbols by examining symbol types and call replaceSymbol (which memcpy's New to Old) if necessary. With the new function, we have now separated symbol resolution from symbol lookup. If you already have a Symbol pointer, you can directly resolve the symbol without asking SymbolTable to do that. Now that the nice abstraction become available, I can start working on performance improvement of the linker. As a starter, I'm thinking of making --{start,end}-lib faster. --{start,end}-lib is currently unnecessarily slow because it looks up the symbol table twice for each symbol. - The first hash table lookup/insertion occurs when we instantiate a LazyObject file to insert LazyObject symbols. - The second hash table lookup/insertion occurs when we create an ObjFile from LazyObject file. That overwrites LazyObject symbols with Defined symbols. I think it is not too hard to see how we can now eliminate the second hash table lookup. We can keep LazyObject symbols in Step 1, and then call elf::resolveSymbol() to do Step 2. Differential Revision: https://reviews.llvm.org/D61898 llvm-svn: 360975
* Introduce CommonSymbol.Rui Ueyama2019-05-161-4/+4
| | | | | | | | | | | | | | | | | Previously, we handled common symbols as a kind of Defined symbol, but what we were doing for common symbols is pretty different from regular defined symbols. Common symbol and defined symbol are probably as different as shared symbol and defined symbols are different. This patch introduces CommonSymbol to represent common symbols. After symbols are resolved, they are converted to Defined symbols residing in a .bss section. Differential Revision: https://reviews.llvm.org/D61895 llvm-svn: 360841
* Simplify SymbolTable::add{Defined,Undefined,...} functions.Rui Ueyama2019-05-161-13/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | SymbolTable's add-family functions have lots of parameters because when they have to create a new symbol, they forward given arguments to Symbol's constructors. Therefore, the functions take at least as many arguments as their corresponding constructors. This patch simplifies the add-family functions. Now, the functions take a symbol instead of arguments to construct a symbol. If there's no existing symbol, a given symbol is memcpy'ed to the symbol table. Otherwise, the functions attempt to merge the existing and a given new symbol. I also eliminated `CanOmitFromDynSym` parameter, so that the functions take really one argument. Symbol classes are trivially constructible, so looks like constructing them to pass to add-family functions is as cheap as passing a lot of arguments to the functions. A quick benchmark showed that this patch seems performance-neutral. This is a preparation for http://lists.llvm.org/pipermail/llvm-dev/2019-April/131902.html Differential Revision: https://reviews.llvm.org/D61855 llvm-svn: 360838
* [ELF] Full support for -n (--nmagic) and -N (--omagic) via common pagePeter Smith2019-05-131-1/+3
| | | | | | | | | | | | | | | | | | | | | | 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
* [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] - Do not remove empty sections referenced in LOADADDR/ADDR commands.George Rimar2019-04-261-3/+9
| | | | | | | | | | | | | | | 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] 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
* Use llvm::stable_sortFangrui Song2019-04-231-1/+1
| | | | | | | | | 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] Respect NonAlloc when copying flags from the previous sectionsFangrui Song2019-04-181-1/+2
| | | | | | | | | | | | | | | | 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 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: Simplify. NFCI.Peter Collingbourne2019-03-121-3/+1
| | | | | | | | | We don't need to take a slice of SectionCommands in addOrphanSections() because it is not modified until the end of the function. Differential Revision: https://reviews.llvm.org/D59239 llvm-svn: 355954
* 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][ELF] - Support discarding the .dynamic section.George Rimar2018-12-101-2/+1
| | | | | | | | | | | This is a part of https://bugs.llvm.org/show_bug.cgi?id=39810. Seems it turns out that supporting /DISCARD/ for the .dynamic section with the linker script is something we can do easily. The patch does this. Differential revision: https://reviews.llvm.org/D55211 llvm-svn: 348749
* [ELF] - Allow discarding .dynsym from the linker script.George Rimar2018-12-101-2/+2
| | | | | | | | | 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-1/+1
| | | | | | | | | 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] Allow discarding of .rela.pltMartell Malone2018-12-041-2/+1
| | | | | | | | | | | | | | | | When linking the linux kernel on ppc64le ld.lld -EL -m elf64lppc -Bstatic --orphan-handling=warn --build-id -o .tmp_vmlinux1 -T ./arch/powerpc/kernel/vmlinux.lds --whole-archive built-in.a --no-whole-archive --start-group lib/lib.a --end-group ld.lld: error: discarding .rela.plt section is not allowed The linker script discards with the following matches *(.glink .iplt .plt .rela* .comment) Differential Revision: https://reviews.llvm.org/D54871 llvm-svn: 348258
* Remove `Type` parameter from SymbolTable::insert(). NFC.Rui Ueyama2018-10-121-2/+2
| | | | | | | | | `Type` parameter was used only to check for TLS attribute mismatch, but we can do that when we actually replace symbols, so we don't need to type as an argument. This change should simplify the interface of the symbol table a bit. llvm-svn: 344394
* Reset input section pointers to null on each linker invocation.Rui Ueyama2018-09-251-7/+7
| | | | | | | | | | Previously, if you invoke lld's `main` more than once in the same process, the second invocation could fail or produce a wrong result due to a stale pointer values of the previous run. Differential Revision: https://reviews.llvm.org/D52506 llvm-svn: 343009
* ELF: Don't examine values of linker script symbols during ICF.Peter Collingbourne2018-08-291-0/+1
| | | | | | | | | These symbols are declared early with the same value, so they otherwise appear identical to ICF. Differential Revision: https://reviews.llvm.org/D51376 llvm-svn: 340998
* [ELF] - Remove dead code from LinkerScript::assignOffsets(). NFC-ihope.George Rimar2018-08-061-14/+2
| | | | | | | | | | | | | | | | | | Some parts of the code changed are a bit old. I found traces in 2016. Initiall commits has test cases and perhaps reasonable comments. For example, we had segfaults earlier and had the code to fix them. Now, in 2018, I think it is excessive to have these parts, because we do not have segfaults and our code was changed a lot (softly saying). I reviewed the current sources and I think that at this point of the execution flow, we should never face with the conditions checked and so I removing them in this patch. This helps to cleanup the code. llvm-svn: 339003
* [LLD][ELF] - Simplify. NFC.George Rimar2018-08-021-6/+1
| | | | | | | | isHeaderSection can be useful I believe, but probably not right now and not for this case. llvm-svn: 338699
OpenPOWER on IntegriCloud