summaryrefslogtreecommitdiffstats
path: root/lld/test/ELF/relocation.s
Commit message (Collapse)AuthorAgeFilesLines
* [llvm-objdump] Further rearrange llvm-objdump sections for compatabilityJordan Rupprecht2019-10-031-33/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: rL371826 rearranged some output from llvm-objdump for GNU objdump compatability, but there still seem to be some more. I think this rearrangement is a little closer. Overview of the ordering which matches GNU objdump: * Archive headers * File headers * Section headers * Symbol table * Dwarf debugging * Relocations (if `--disassemble` is not used) * Section contents * Disassembly Reviewers: jhenderson, justice_adams, grimar, ychen, espindola Reviewed By: jhenderson Subscribers: aprantl, emaste, arichardson, jrtc27, atanasyan, seiya, llvm-commits, MaskRay Tags: #llvm Differential Revision: https://reviews.llvm.org/D68066 llvm-svn: 373671
* [ELF][X86] Allow PT_LOAD to have overlapping p_offset ranges on EM_X86_64Fangrui Song2019-09-161-19/+19
| | | | | | | | Port the D64906 technique to EM_X86_64. Differential Revision: https://reviews.llvm.org/D67482 llvm-svn: 371958
* [llvm-objdump] Print newlines before and after "Disassembly of section ...:"Fangrui Song2019-05-011-0/+5
| | | | | | | | | | | This improves readability and the behavior is consistent with GNU objdump. The new test test/tools/llvm-objdump/X86/disassemble-section-name.s checks we print newlines before and after "Disassembly of section ...:" Differential Revision: https://reviews.llvm.org/D61127 llvm-svn: 359668
* [test] Change llvm-readobj -long-option to --long-option or well-known short ↵Fangrui Song2019-05-011-1/+1
| | | | | | | | | | | | 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] Change GOT*_FROM_END (relative to end(.got)) to GOTPLT* (start(.got.plt))Fangrui Song2019-03-251-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [ELF] Split RW PT_LOAD on the PT_GNU_RELRO boundaryFangrui Song2019-03-151-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Based on Peter Collingbourne's suggestion in D56828. Before D56828: PT_LOAD(.data PT_GNU_RELRO(.data.rel.ro .bss.rel.ro) .bss) Old: PT_LOAD(PT_GNU_RELRO(.data.rel.ro .bss.rel.ro) .data .bss) New: PT_LOAD(PT_GNU_RELRO(.data.rel.ro .bss.rel.ro)) PT_LOAD(.data. .bss) The new layout reflects the runtime memory mappings. By having two PT_LOAD segments, we can utilize the NOBITS part of the first PT_LOAD and save bytes for .bss.rel.ro. .bss.rel.ro is currently small and only used by copy relocations of symbols in read-only segments, but it can be used for other purposes in the future, e.g. if a relro section's statically relocated data is all zeros, we can move it to .bss.rel.ro. Reviewers: espindola, ruiu, pcc Reviewed By: ruiu Subscribers: nemanjai, jvesely, nhaehnle, javed.absar, kbarton, emaste, arichardson, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D58892 llvm-svn: 356226
* [ELF] Simplify RelRo, TLS, NOBITS section ranks and make RW PT_LOAD start ↵Fangrui Song2019-03-141-12/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | with RelRo Old: PT_LOAD(.data | PT_GNU_RELRO(.data.rel.ro .bss.rel.ro) | .bss) New: PT_LOAD(PT_GNU_RELRO(.data.rel.ro .bss.rel.ro) | .data .bss) The placement of | indicates page alignment caused by PT_GNU_RELRO. The new layout has simpler rules and saves space for many cases. Old size: roundup(.data) + roundup(.data.rel.ro) New size: roundup(.data.rel.ro + .bss.rel.ro) + .data Other advantages: * At runtime the 3 memory mappings decrease to 2. * start(PT_TLS) = start(PT_GNU_RELRO) = start(RW PT_LOAD). This simplifies binary manipulation tools. GNU strip before 2.31 discards PT_GNU_RELRO if its address is not equal to the start of its associated PT_LOAD. This has been fixed by https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f2731e0c374e5323ce4cdae2bcc7b7fe22da1a6f But with this change, we will be compatible with GNU strip before 2.31 * Before, .got.plt (non-relro by default) was placed before .got (relro by default), which made it impossible to have _GLOBAL_OFFSET_TABLE_ (start of .got.plt on x86-64) equal to the end of .got (R_GOT*_FROM_END) (https://bugs.llvm.org/show_bug.cgi?id=36555). With the new ordering, we can improve on this regard if we'd like to. Reviewers: ruiu, espindola, pcc Subscribers: emaste, arichardson, llvm-commits, joerg, jdoerfert Differential Revision: https://reviews.llvm.org/D56828 llvm-svn: 356117
* [ELF] Move `// REQUIRES:` line to the topFangrui Song2018-06-261-1/+1
| | | | llvm-svn: 335676
* [ELF] Make non-writable non-executable PROGBITS sections closer to .textFangrui Song2018-06-261-3/+3
| | | | | | | | | | | | This generalizes the old heuristic placing SHT_DYNSYM SHT_DYNSTR first in the readonly SHF_ALLOC segment. Reviewers: espindola Subscribers: emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D48406 llvm-svn: 335674
* [lld] Mitigate relocation overflow [part 1 of 2].Han Shen2018-05-151-5/+4
| | | | | | | | | | | This CL places .dynsym and .dynstr at the beginning of SHF_ALLOC sections. We do this to mitigate the possibility that huge .dynsym and .dynstr sections placed between ro-data and text sections cause relocation overflow. Differential Revision: https://reviews.llvm.org/D45788 llvm-svn: 332374
* [ELF] - Revert of: r332038, r332054, r332060, r332061, r332062, r332063George Rimar2018-05-111-2/+2
| | | | | | | | | | | This reverts "Mitigate relocation overflow [part 1 of 2]." and the following commits which were trying to fix the bots. At the moment of r332082, bots are still failing and we need to find the reason of test case breakages first of all. http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/17042/steps/test/logs/stdio http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/29845/steps/test/logs/stdio llvm-svn: 332085
* [ELF] Fix testFangrui Song2018-05-101-1/+1
| | | | llvm-svn: 332063
* [ELF] Fix tests after rL332038Fangrui Song2018-05-101-1/+1
| | | | llvm-svn: 332062
* Fix test cases failure caused by revision 332038.Han Shen2018-05-101-2/+2
| | | | | | | The previous CL changes the order of output sections, which causes address changes in test cases. Review: https://reviews.llvm.org/D46730 llvm-svn: 332054
* Mitigate relocation overflow [part 1 of 2].Han Shen2018-05-101-2/+2
| | | | | | | | | | | | This CL is to mitigate R_X86_64_PC32 relocation overflow problems for huge binaries that has near 4G allocated sections. By examining those binaries, there're 2 issues contributes to the problem: 1). huge ".dynsym" and ".dynstr" stands in the way between .rodata and .text 2). _init_array_start/end are placed at 0 if no ".init_array" presents, this causes .text relocation against them become more prone to overflow. This CL addresses 1st problem (the 2nd will be addressed in another CL.) by assigning a smaller sortrank to .dynsym and .dynstr thus they no longer stand in between. llvm-svn: 332038
* [ELF] - Do --hash-style=both by default.George Rimar2017-10-061-1/+1
| | | | | | | | | | | | | | Its PR34712, GNU linkers recently changed default values to "both" of "sysv". Patch do the same for all targets except MIPS, where .gnu.hash section is not yet supported. Code suggested by Rui Ueyama. Differential revision: https://reviews.llvm.org/D38407 llvm-svn: 315051
* ELF: Place relro sections after non-relro sections in r/w segment.Peter Collingbourne2017-01-101-11/+11
| | | | | | | | | | | | 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
* Add support for R_X86_64_GOT64.Rafael Espindola2016-12-091-0/+8
| | | | llvm-svn: 289277
* lld: Default image base address to 0x200000 on x86-64Ed Maste2016-11-231-16/+16
| | | | | | | | | Align to the large page size (known as a superpage or huge page). FreeBSD automatically promotes large, superpage-aligned allocations. Differential Revision: https://reviews.llvm.org/D27042 llvm-svn: 287782
* Fix handling of R_X86_64_GOT32.Rafael Espindola2016-04-181-0/+8
| | | | | | It computes the offset to the end of .got. llvm-svn: 266610
* Create implicit plt entries for R_X86_64_32S.Rafael Espindola2016-02-241-2/+11
| | | | llvm-svn: 261749
* Add debugger rendezvous DT_DEBUG .dynamic entryEd Maste2016-01-061-3/+3
| | | | | | | | | The runtime linker may store a pointer to a data structure used by debuggers. Differential Revision: http://reviews.llvm.org/D15775 llvm-svn: 256942
* Place RW sections that go after relro to another memory page.Rafael Espindola2015-12-231-2/+2
| | | | | | | | | | | | Before this patch sections that go after relro sequence were placed at the same memory page with relro ones. It caused segmentation fault on freebsd. Fixes PR25790. Patch by George Rimar with some tweaks by myself. llvm-svn: 256334
* Revert "ELF: Make .note.GNU-stack more compatible with traditional linkers."Rui Ueyama2015-11-241-4/+4
| | | | | | | This reverts commit r253797 because it was based on a misunderstanding that lld wouldn't work on NetBSD without this change. llvm-svn: 254003
* Reapply fixed r253967.George Rimar2015-11-241-2/+2
| | | | llvm-svn: 253971
* Revert r253967 which broke buildbot.George Rimar2015-11-241-2/+2
| | | | llvm-svn: 253970
* [ELF] Implements -z relro: create an ELF "PT_GNU_RELRO" segment header in ↵George Rimar2015-11-241-2/+2
| | | | | | | | | | | | | | | | | 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
* ELF: Make .note.GNU-stack more compatible with traditional linkers.Rui Ueyama2015-11-211-2/+2
| | | | | | | | | | | | | With this patch, lld creates PT_GNU_STACK segments only when all input files have .note.GNU-stack sections. This is in line with other linkers with a minor difference (we don't care about .note.GNU-stack rwx bits as you can always remove .note.GNU-stack sections instead of setting x bit.) At least, NetBSD loader does not understand PT_GNU_STACK segments and reject any executables that have the section. This patch makes lld compatible with such operating systems. llvm-svn: 253797
* Rename ld.lld2 to ld.lld since it is the default.Rafael Espindola2015-11-181-2/+2
| | | | llvm-svn: 253437
* Rename test/elf2 to test/ELF.Rafael Espindola2015-11-171-0/+117
llvm-svn: 253313
OpenPOWER on IntegriCloud