summaryrefslogtreecommitdiffstats
path: root/lld/test/ELF/mips-dynamic.s
Commit message (Collapse)AuthorAgeFilesLines
* [test] Change llvm-readobj -long-option to --long-option or well-known short ↵Fangrui Song2019-05-011-4/+4
| | | | | | | | | | | | options. NFC Also change some options that have different semantics (cause confusion) in llvm-readelf mode: -s => -S -t => --symbols -sd => --section-data llvm-svn: 359651
* [ELF] Remove checking for spurious '@' at the end of dynamic sym namesJames Henderson2019-01-081-3/+3
| | | | | | | | | | | | llvm-readobj currently has a bug (see PR40097) where it prints '@' at the end of unversioned dynamic symbols. This bug will be fixed in a separate later commit, but these tests need fixing first. Reviewed by: ruiu, Higuoxing Differential Revision: https://reviews.llvm.org/D56388 llvm-svn: 350614
* [ELF] Move `# REQUIRES:` line to the topFangrui Song2018-06-261-2/+1
| | | | llvm-svn: 335625
* [ELF][MIPS] Fix stable_sort predicate to satisfy strict-ordering ↵Simon Atanasyan2018-06-151-1/+1
| | | | | | | | requirement. NFC Fix for PR37785. llvm-svn: 334851
* [ELF][MIPS] Multi-GOT implementationSimon Atanasyan2018-06-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Almost all entries inside MIPS GOT are referenced by signed 16-bit index. Zero entry lies approximately in the middle of the GOT. So the total number of GOT entries cannot exceed ~16384 for 32-bit architecture and ~8192 for 64-bit architecture. This limitation makes impossible to link rather large application like for example LLVM+Clang. There are two workaround for this problem. The first one is using the -mxgot compiler's flag. It enables using a 32-bit index to access GOT entries. But each access requires two assembly instructions two load GOT entry index to a register. Another workaround is multi-GOT. This patch implements it. Here is a brief description of multi-GOT for detailed one see the following link https://dmz-portal.mips.com/wiki/MIPS_Multi_GOT. If the sum of local, global and tls entries is less than 64K only single got is enough. Otherwise, multi-got is created. Series of primary and multiple secondary GOTs have the following layout: ``` - Primary GOT Header Local entries Global entries Relocation only entries TLS entries - Secondary GOT Local entries Global entries TLS entries ... ``` All GOT entries required by relocations from a single input file entirely belong to either primary or one of secondary GOTs. To reference GOT entries each GOT has its own _gp value points to the "middle" of the GOT. In the code this value loaded to the register which is used for GOT access. MIPS 32 function's prologue: ``` lui v0,0x0 0: R_MIPS_HI16 _gp_disp addiu v0,v0,0 4: R_MIPS_LO16 _gp_disp ``` MIPS 64 function's prologue: ``` lui at,0x0 14: R_MIPS_GPREL16 main ``` Dynamic linker does not know anything about secondary GOTs and cannot use a regular MIPS mechanism for GOT entries initialization. So we have to use an approach accepted by other architectures and create dynamic relocations R_MIPS_REL32 to initialize global entries (and local in case of PIC code) in secondary GOTs. But ironically MIPS dynamic linker requires GOT entries and correspondingly ordered dynamic symbol table entries to deal with dynamic relocations. To handle this problem relocation-only section in the primary GOT contains entries for all symbols referenced in global parts of secondary GOTs. Although the sum of local and normal global entries of the primary got should be less than 64K, the size of the primary got (including relocation-only entries can be greater than 64K, because parts of the primary got that overflow the 64K limit are used only by the dynamic linker at dynamic link-time and not by 16-bit gp-relative addressing at run-time. The patch affects common LLD code in the following places: - Added new hidden -mips-got-size flag. This flag required to set low maximum size of a single GOT to be able to test the implementation using small test cases. - Added InputFile argument to the getRelocTargetVA function. The same symbol referenced by GOT relocation from different input file might be allocated in different GOT. So result of relocation depends on the file. - Added new ctor to the DynamicReloc class. This constructor records settings of dynamic relocation which used to adjust address of 64kb page lies inside a specific output section. With the patch LLD is able to link all LLVM+Clang+LLD applications and libraries for MIPS 32/64 targets. Differential revision: https://reviews.llvm.org/D31528 llvm-svn: 334390
* [ELF][MIPS] Support linking of PIE for MIPSSimon Atanasyan2018-04-131-12/+34
| | | | | | | | | | | | | | MIPS ABI requires creation of the MIPS_RLD_MAP dynamic tag for non-PIE executables only and MIPS_RLD_MAP_REL tag for both PIE and non-PIE executables. The patch skips definition of the MIPS_RLD_MAP for PIE files and defines MIPS_RLD_MAP_REL. The MIPS_RLD_MAP_REL tag stores the offset to the .rld_map section relative to the address of the tag itself. Differential Revision: https://reviews.llvm.org/D43347 llvm-svn: 329996
* ELF: Place relro sections after non-relro sections in r/w segment.Peter Collingbourne2017-01-101-9/+9
| | | | | | | | | | | | This is in preparation for my next change, which will introduce a relro nobits section. That requires that relro sections appear at the end of the progbits part of the r/w segment so that the relro nobits section can appear contiguously. Because of the amount of churn required in the test suite, I'm making this change separately. llvm-svn: 291523
* Set DT_MIPS_BASE_ADDRESS correctly if -image-base is given.Rui Ueyama2016-07-141-1/+7
| | | | | | Differential Revision: http://reviews.llvm.org/D22323 llvm-svn: 275446
* [ELF][MIPS] Fix predicate used for sorting MIPS dynamic symbol tablesSimon Atanasyan2016-06-201-1/+1
| | | | | | | Now it conforms requirement for std::stable_sort predicates. That resolves build-bot failures on Windows hosts. llvm-svn: 273151
* [ELF][MIPS] Support GOT entries for non-preemptible symbols with different ↵Simon Atanasyan2016-06-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | addends There are two motivations for this patch. The first one is a preparation for support MIPS TLS relocations. It might sound like a joke but for GOT entries related to TLS relocations MIPS ABI uses almost regular approach with creation of dynamic relocations for each GOT enty etc. But we need to separate these 'regular' TLS related entries from MIPS specific local and global parts of GOT. ABI declare simple solution - all TLS related entries allocated at the end of GOT after local/global parts. The second motivation it to support GOT relocations for non-preemptible symbols with addends. If we have more than one GOT relocations against symbol S with different addends we need to create GOT entries for each unique Symbol/Addend pairs. So we store all MIPS GOT entries in separate containers. For non-preemptible symbols we have to maintain two data structures. The first one is MipsLocal vector. Each entry corresponds to the GOT entry from the 'local' part of the GOT contains the symbol's address plus addend. The second one is MipsLocalMap. It is a map from Symbol/Addend pair to the GOT index. Differential Revision: http://reviews.llvm.org/D21297 llvm-svn: 273127
* ELF: Use hidden visibility for all DefinedSynthetic symbols.Peter Collingbourne2016-04-131-5/+4
| | | | | | | | | | | | | This simplifies the code by allowing us to remove the visibility argument to functions that create synthetic symbols. The only functional change is that the visibility of the MIPS "_gp" symbol is now hidden. Because this symbol is defined in every executable or DSO, it would be difficult to observe a visibility change here. Differential Revision: http://reviews.llvm.org/D19033 llvm-svn: 266208
* Devide _gp in the same spot as other mips symbols. NFC.Rafael Espindola2016-04-121-1/+1
| | | | | | The test changes are just because of the symbol order. llvm-svn: 266037
* Cleanup the handling of MustBeInDynSym and IsUsedInRegularObj.Rafael Espindola2016-04-081-2/+2
| | | | | | | | | | | | | | | | | | Now MustBeInDynSym is only true if the symbol really must be in the dynamic symbol table. IsUsedInRegularObj is only true if the symbol is used in a .o or -u. Not a .so or a .bc. A benefit is that this is now done almost entirilly during symbol resolution. The only exception is copy relocations because of aliases. This includes a small fix in that protected symbols in .so don't force executable symbols to be exported. This also opens the way for implementing internalize for -shared. llvm-svn: 265826
* [ELF] - Symbols from object files that override symbols in DSO are added to ↵George Rimar2016-01-251-2/+2
| | | | | | | | | | | .dynsym table. Main executable did not export symbols that exist both in the main executable and in DSOs before this patch. Symbols from object files that override symbols in DSO should be added to .dynsym table. Differential revision: http://reviews.llvm.org/D16405 llvm-svn: 258672
* [ELF][MIPS] Update test case to reflect recent changes in llvm-readobjSimon Atanasyan2016-01-201-0/+2
| | | | llvm-svn: 258340
* Reapply fixed r253967.George Rimar2015-11-241-8/+8
| | | | llvm-svn: 253971
* Revert r253967 which broke buildbot.George Rimar2015-11-241-8/+8
| | | | llvm-svn: 253970
* [ELF] Implements -z relro: create an ELF "PT_GNU_RELRO" segment header in ↵George Rimar2015-11-241-8/+8
| | | | | | | | | | | | | | | | | the object. Partial (-z relro) and full (-z relro, -z now) relro cases are implemented. Partial relro: The ELF sections are reordered so that the ELF internal data sections (.got, .dtors, etc.) precede the program's data sections (.data and .bss). .got is readonly, .got.plt is still writeable. Full relro: Supports all the features of partial RELRO, .got.plt is also readonly. Differential revision: http://reviews.llvm.org/D14218 llvm-svn: 253967
* Rename ld.lld2 to ld.lld since it is the default.Rafael Espindola2015-11-181-3/+3
| | | | llvm-svn: 253437
* Rename test/elf2 to test/ELF.Rafael Espindola2015-11-171-0/+91
llvm-svn: 253313
OpenPOWER on IntegriCloud