summaryrefslogtreecommitdiffstats
path: root/lld/ELF/SymbolTable.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix a few typos in lld/ELF to cycle botsNico Weber2019-10-281-1/+1
|
* [ELF] Wrap things in `namespace lld { namespace elf {`, NFCFangrui Song2019-10-071-4/+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
* [LLD] Simplify the demangleItanium function. NFC.Martin Storsjo2019-09-271-4/+1
| | | | | | | | | Instead of returning an optional, just return the input string if demangling fails, as that's what all callers use anyway. Differential Revision: https://reviews.llvm.org/D68015 llvm-svn: 373077
* [ELF] Initialize 2 fields of Symbol in SymbolTable::insertFangrui Song2019-08-141-0/+4
| | | | | | | | | | | | | | | | | | | A new symbol is added to elf::symtab in 3 steps: 1) SymbolTable::insert creates a placeholder. 2) Symbol::mergeProperties 3) Symbol::replace Fields referenced by steps 2) and 3) should be initialized in SymbolTable::insert. `traced` and `referenced` were missed previously. This did not cause problems because compilers generated code that initialized them (bit fields) to 0. Reviewed By: grimar Differential Revision: https://reviews.llvm.org/D66130 llvm-svn: 368784
* [ELF] Simplify handling of exportDynamic and isPreemptibleFangrui Song2019-08-131-6/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In Writer::includeInDynSym(), exportDynamic is used by a Defined with protected or default visibility, to record whether it is required to be exported into .dynsym. It is set when any of the following conditions hold: 1) There is an interposable symbol from a DSO (Undefined or SharedSymbol with default visibility) 2) If -shared or --export-dynamic is specified, any symbol in an object file/bitcode sets this property, unless suppressed by canBeOmittedFromSymbolTable(). 3) --dynamic-list when producing an executable 4) protected symbol from a DSO preempted by copy relocation/canonical PLT when --ignore-{data,function}-address-equality is specified 5) ifunc is exported when -z ifunc-noplt is specified Bullet points 4) and 5) are irrelevant in this patch. Bullet 3) does not play well with 1) and 2). When -shared is specified, exportDynamic of most symbols is true. This makes it incapable to record --dynamic-list marked symbols. We thus have obscure: if (!config->shared) b->exportDynamic = true; else if (b->includeInDynsym()) b->isPreemptible = true; This patch adds another bit `Symbol::inDynamicList` to record 3). We can thus simplify handleDynamicList() by unifying the DSO and executable cases. It also allows us to simplify isPreemptible - now the field is only used in finalizeSections() and later stages. Reviewed By: peter.smith Differential Revision: https://reviews.llvm.org/D66091 llvm-svn: 368659
* [ELF] Rename odd variable names "New" after r365730. NFCFangrui Song2019-08-131-3/+3
| | | | | | | | | | New -> newSym or newFlags Reviewed By: atanasyan Differential Revision: https://reviews.llvm.org/D66127 llvm-svn: 368651
* [ELF] Consistently prioritize non-* wildcards overs "*" in version scriptsFangrui Song2019-08-051-29/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We prioritize non-* wildcards overs VER_NDX_LOCAL/VER_NDX_GLOBAL "*". This patch generalizes the rule to "*" of other versions and thus fixes PR40176. I don't feel strongly about this GNU linkers' behavior but the generalization simplifies code. Delete `config->defaultSymbolVersion` which was used to special case VER_NDX_LOCAL/VER_NDX_GLOBAL "*". In `SymbolTable::scanVersionScript`, custom versions are handled the same way as VER_NDX_LOCAL/VER_NDX_GLOBAL. So merge `config->versionScript{Locals,Globals}` into `config->versionDefinitions`. Overall this seems to simplify the code. In `SymbolTable::assign{Exact,Wildcard}Versions`, `sym->verdefIndex == config->defaultSymbolVersion` is changed to `verdefIndex == UINT32_C(-1)`. This allows us to give duplicate assignment diagnostics for `{ global: foo; };` `V1 { global: foo; };` In test/linkerscript/version-script.s: vs_index of an undefined symbol changes from 0 to 1. This doesn't matter (arguably 1 is better because the binding is STB_GLOBAL) because vs_index of an undefined symbol is ignored. Reviewed By: ruiu Differential Revision: https://reviews.llvm.org/D65716 llvm-svn: 367869
* [ELF] Fix variable names in comments after VariableName -> variableName changeFangrui Song2019-07-161-2/+2
| | | | | | Also fix some typos. llvm-svn: 366181
* [ELF] Handle non-glob patterns before glob patterns in version scripts & fix ↵Fangrui Song2019-07-111-22/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | a corner case of --dynamic-list This fixes PR38549, which is silently accepted by ld.bfd. This seems correct because it makes sense to let non-glob patterns take precedence over glob patterns. lld issues an error because `assignWildcardVersion(ver, VER_NDX_LOCAL);` is processed before `assignExactVersion(ver, v.id, v.name);`. Move all assignWildcardVersion() calls after assignExactVersion() calls to fix this. Also, move handleDynamicList() to the bottom. computeBinding() called by includeInDynsym() has this cryptic rule: if (versionId == VER_NDX_LOCAL && isDefined() && !isPreemptible) return STB_LOCAL; Before the change: * foo's version is set to VER_NDX_LOCAL due to `local: *` * handleDynamicList() is called - foo.computeBinding() is STB_LOCAL - foo.includeInDynsym() is false - foo.isPreemptible is not set (wrong) * foo's version is set to V1 After the change: * foo's version is set to VER_NDX_LOCAL due to `local: *` * foo's version is set to V1 * handleDynamicList() is called - foo.computeBinding() is STB_GLOBAL - foo.includeInDynsym() is true - foo.isPreemptible is set (correct) Reviewed By: ruiu Differential Revision: https://reviews.llvm.org/D64550 llvm-svn: 365760
* [ELF] Warn rather than error when duplicate version assignments occurFangrui Song2019-07-111-4/+15
| | | | | | | | | | | | | | | | | | | | | | In lvm2, libdevmapper.so is linked with a version script with duplicate version assignments: DM_1_02_138 { global: ... dm_bitset_parse_list; ... }; DM_1_02_129 { global: ... dm_bitset_parse_list; ... }; ld.bfd silently accepts this while gold issues a warning. We currently error, thus inhibit producing the executable. Change the error to warning to allow this case, and improve the message. There are some cases where ld.bfd error `anonymous version tag cannot be combined with other version tags` but we just warn. It is probably OK for now. Reviewed By: grimar, ruiu Differential Revision: https://reviews.llvm.org/D64549 llvm-svn: 365759
* [Coding style change] Rename variables so that they start with a lowercase ↵Rui Ueyama2019-07-101-115/+115
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: Add basic partition data structures and behaviours.Peter Collingbourne2019-05-291-0/+1
| | | | | | | | | | | | | | 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
* Use SymbolTable::insert() to implement --trace.Rui Ueyama2019-05-281-16/+3
| | | | | | Differential Revision: https://reviews.llvm.org/D62381 llvm-svn: 361791
* Move code for symbol resolution from SymbolTable.cpp to Symbols.cpp.Rui Ueyama2019-05-231-319/+3
| | | | | | | | | | | | | | | | 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
* Speed up --start-lib and --end-lib.Rui Ueyama2019-05-231-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | --{start,end}-lib give files grouped by the options the archive file semantics. That is, each object file between them acts as if it were in an archive file whose sole member is the file. Therefore, files between --{start,end}-lib are linked to the final output only if they are needed to resolve some undefined symbols. Previously, the feature was implemented this way: 1. We read a symbol table and insert defined symbols to the symbol table as lazy symbols. 2. If an undefind symbol is resolved to a lazy symbol, that lazy symbol instantiate ObjFile class for that symbol, which re-insert all defined symbols to the symbol table. So, if an ObjFile is instantiated, defined symbols are inserted to the symbol table twice. Since inserting long symbol names is not cheap, there's a room to optimize here. This patch optimzies it. Now, LazyObjFile remembers symbol handles and passed them over to a new ObjFile instance, so that the ObjFile doesn't insert the same strings. Here is a quick benchmark to link clang. "Original" is the original lld with unmodified command line options. For "Case 1" and "Case 2", I extracted all files from archive files and replace .a's in a command line with .o's wrapped with --{start,end}-lib. I used the original lld for Case 1" and use this patch for Case 2. Original: 5.892 Case 1: 6.001 (+1.8%) Case 2: 5.701 (-3.2%) So, interestingly, --{start,end}-lib are now faster than the regular linking scheme with archive files. That's perhaps not too surprising, though, because for regular archive files, we look up the symbol table with the same string twice. Differential Revision: https://reviews.llvm.org/D62188 llvm-svn: 361473
* Move SymbolTable::addCombinedLTOObject() to LinkerDriver.Rui Ueyama2019-05-231-28/+0
| | | | | | | | | | | | Also renames it LinkerDriver::compileBitcodeFiles. The function doesn't logically belong to SymbolTable. We added this function to the symbol table because symbol table used to be a container of input files. This is no longer the case. Differential Revision: https://reviews.llvm.org/D62291 llvm-svn: 361469
* [ELF] Improve error message for relocations to symbols defined in discarded ↵Fangrui Song2019-05-221-2/+6
| | | | | | | | | | | | | | | | | | | | | sections Rather than report "undefined symbol: ", give more informative message about the object file that defines the discarded section. In particular, PR41133, if the section is a discarded COMDAT, print the section group signature and the object file with the prevailing definition. This is useful to track down some ODR issues. We need to * add `uint32_t DiscardedSecIdx` to Undefined for this feature. * make ComdatGroups public and change its type to DenseMap<CachedHashStringRef, const InputFile *> Reviewed By: ruiu Differential Revision: https://reviews.llvm.org/D59649 llvm-svn: 361359
* Make replaceSymbol a member function of Symbol.Rui Ueyama2019-05-201-6/+6
| | | | | | | | | | | | 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-104/+89
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Pemove SymbolTable::addBitcode as it is redundant.Rui Ueyama2019-05-161-17/+0
| | | | | | Differential Revision: https://reviews.llvm.org/D61897 llvm-svn: 360846
* Consistently return `Symbol *` from SymbolTable's add-family functions.Rui Ueyama2019-05-161-8/+14
| | | | llvm-svn: 360845
* De-template parseFile() and SymbolTable's add-family functions.Rui Ueyama2019-05-161-33/+9
| | | | | | Differential Revision: https://reviews.llvm.org/D61896 llvm-svn: 360844
* Introduce CommonSymbol.Rui Ueyama2019-05-161-103/+93
| | | | | | | | | | | | | | | | | 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-209/+179
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Move SymbolTable::addFile to InputFiles.cpp.Rui Ueyama2019-05-141-84/+4
| | | | | | | | | | | | | | | | | 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] Reorder BitcodeFiles.empty() to call thinLTOCreateEmptyIndexFiles() in ↵Fangrui Song2019-05-071-6/+0
| | | | | | | | | | | | | | | | | 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
* [ELF] --plugin-opt=thinlto-index-only: create empty index files even if all ↵Fangrui Song2019-05-021-1/+4
| | | | | | | | | | | | | | | | | | | 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
* De-template SymbolTable::addShared.Rui Ueyama2019-04-091-23/+9
| | | | | | | Because of r357925, this member function doesn't have to be a template of ELFT. llvm-svn: 357982
* ELF: De-template SharedFile. NFCI.Peter Collingbourne2019-04-081-24/+7
| | | | | | Differential Revision: https://reviews.llvm.org/D60305 llvm-svn: 357925
* [ELF] Support --{,no-}allow-shlib-undefinedFangrui Song2019-02-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: In ld.bfd/gold, --no-allow-shlib-undefined is the default when linking an executable. This patch implements a check to error on undefined symbols in a shared object, if all of its DT_NEEDED entries are seen. Our approach resembles the one used in gold, achieves a good balance to be useful but not too smart (ld.bfd traces all DSOs and emulates the behavior of a dynamic linker to catch more cases). The error is issued based on the symbol table, different from undefined reference errors issued for relocations. It is most effective when there are DSOs that were not linked with -z defs (e.g. when static sanitizers runtime is used). gold has a comment that some system libraries on GNU/Linux may have spurious undefined references and thus system libraries should be excluded (https://sourceware.org/bugzilla/show_bug.cgi?id=6811). The story may have changed now but we make --allow-shlib-undefined the default for now. Its interaction with -shared can be discussed in the future. Reviewers: ruiu, grimar, pcc, espindola Reviewed By: ruiu Subscribers: joerg, emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D57385 llvm-svn: 352826
* [ELF] Simplify. NFCFangrui Song2019-01-291-1/+1
| | | | llvm-svn: 352499
* 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
* [ELF] A shared object is needed if any of its occurrences is neededFangrui Song2018-12-271-1/+13
| | | | | | | | | | | | | | | | | | | | | | | Summary: If a DSO appears more than once with and without --as-needed, ld.bfd and gold consider --no-as-needed to takes precedence over --as-needed. lld didn't and this patch makes it do so. This makes it a bit away from the position-dependent behavior (how different occurrences of the same DSO interact) and protects us from some mysterious runtime errors: if some interceptor libraries add their own --no-as-needed dependencies (e.g. librt.so), and the user application specifies -Wl,--as-needed -lrt , the absence of the DT_NEEDED entry would make dlsym(RTLD_NEXT, "clock_gettime") return NULL and would break at runtime. Reviewers: ruiu, espindola Reviewed By: ruiu Subscribers: emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D56089 llvm-svn: 350105
* Remove dead code.Rui Ueyama2018-12-201-4/+0
| | | | | | | | This code is no-op because of r349849. Differential Revision: https://reviews.llvm.org/D55962 llvm-svn: 349859
* Simplify. NFC.Rui Ueyama2018-12-201-12/+7
| | | | llvm-svn: 349850
* [ELF] Move IsNeeded logic from SymbolTable::addShared to MarkLive, and check ↵Fangrui Song2018-12-201-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | IsUsedInRegularObj Summary: In glibc, libc.so is a linker script with an as-needed dependency on ld-linux-x86-64.so.2 GROUP ( /lib/x86_64-linux-gnu/libc.so.6 /usr/lib/x86_64-linux-gnu/libc_nonshared.a AS_NEEDED ( /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 ) ) ld-linux-x86-64.so.2 (as-needed) defines some symbols which resolve undefined references in libc.so.6, it will therefore be added as a DT_NEEDED entry, which isn't necessary. The test case as-needed-not-in-regular.s emulates the libc.so scenario, where ld.bfd and gold don't add DT_NEEDED for a.so The relevant code in gold/resolve.cc: // If we have a non-WEAK reference from a regular object to a // dynamic object, mark the dynamic object as needed. if (to->is_from_dynobj() && to->in_reg() && !to->is_undef_binding_weak()) to->object()->set_is_needed(); in_reg() appears to do something similar to IsUsedInRegularObj. This patch makes lld do the similar thing, but moves the check from addShared to a later stage MarkLive where all symbols are scanned. Reviewers: ruiu, pcc, espindola Reviewed By: ruiu Subscribers: emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D55902 llvm-svn: 349849
* Simplify. NFC.Rui Ueyama2018-12-191-7/+12
| | | | | | Differential Revision: https://reviews.llvm.org/D55903 llvm-svn: 349697
* [ELF] - Make SymbolTable::addDefined return Defined.George Rimar2018-11-221-4/+4
| | | | | | | | | Now it returns Symbol. This should be NFC that avoids doing cast at the caller's sides. Differential revision: https://reviews.llvm.org/D54627 llvm-svn: 347455
* Remove `Type` parameter from SymbolTable::insert(). NFC.Rui Ueyama2018-10-121-12/+7
| | | | | | | | | `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
* Remove SymbolTable::addAbsolute().Rui Ueyama2018-10-111-7/+0
| | | | | | addAbsolute() could be implemented as a non-member function. llvm-svn: 344305
* Rename SymbolTable::addRegular -> SymbolTable::addDefined.Rui Ueyama2018-10-111-2/+2
| | | | | | | We have addAbsolute, addBitcode, addCommon, etc. addRegular looked a bit inconsistent. llvm-svn: 344294
* Remove SymbolTable::addUndefined<ELF32LE>(StringRef).Rui Ueyama2018-10-111-11/+0
| | | | | | Because we can implement the function as a non-member function. llvm-svn: 344290
* Make a member function private and rename it to avoid function overloading.Rui Ueyama2018-10-101-4/+4
| | | | llvm-svn: 344196
* Merge two overloaded functions into one function. NFC.Rui Ueyama2018-10-091-8/+3
| | | | llvm-svn: 344089
* Return early. NFC.Rui Ueyama2018-10-091-15/+14
| | | | llvm-svn: 344088
* Remove redundant `Symtab->`.Rui Ueyama2018-10-091-7/+7
| | | | | | | | | `SymbolTable` is a singleton class and is a global variable for the unique instance, so we can always refer the symtab by `Symtab->`. However, we don't need to use the global varaible from member functions of SymbolTable class. llvm-svn: 344075
* Simplify. NFC.Rui Ueyama2018-10-091-5/+4
| | | | llvm-svn: 344074
* Remove a use of template to make code less abstracted.Rui Ueyama2018-10-091-19/+26
| | | | | | | Sometimes, code that is a bit longer but doesn't use template is easier to understand than code that uses template. llvm-svn: 344072
* Change how we handle -wrap.Rui Ueyama2018-08-221-61/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | We have an issue with -wrap that the option doesn't work well when renamed symbols get PLT entries. I'll explain what is the issue and how this patch solves it. For one -wrap option, we have three symbols: foo, wrap_foo and real_foo. Currently, we use memcpy to overwrite wrapped symbols so that they get the same contents. This works in most cases but doesn't when the relocation processor sets some flags in the symbol. memcpy'ed symbols are just aliases, so they always have to have the same contents, but the relocation processor breaks that assumption. r336609 is an attempt to fix the issue by memcpy'ing again after processing relocations, so that symbols that are out of sync get the same contents again. That works in most cases as well, but it breaks ASan build in a mysterious way. We could probably fix the issue by choosing symbol attributes that need to be copied after they are updated. But it feels too complicated to me. So, in this patch, I fixed it once and for all. With this patch, we no longer memcpy symbols. All references to renamed symbols point to new symbols after wrapSymbols() is done. Differential Revision: https://reviews.llvm.org/D50569 llvm-svn: 340387
* Revert r336609: Fix direct calls to __wrap_sym when it is relocated.Rui Ueyama2018-07-181-11/+0
| | | | | | | This reverts commit r336609 as it doesn't seem to work with AArch64 thunk creation when used with ASan. llvm-svn: 337413
OpenPOWER on IntegriCloud