summaryrefslogtreecommitdiffstats
path: root/lld/lib
Commit message (Collapse)AuthorAgeFilesLines
...
* ELF: Rename error -> fatal and redefine error as a non-noreturn function.Rui Ueyama2016-01-281-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | In many situations, we don't want to exit at the first error even in the process model. For example, it is better to report all undefined symbols rather than reporting the first one that the linker picked up randomly. In order to handle such errors, we don't need to wrap everything with ErrorOr (thanks for David Blaikie for pointing this out!) Instead, we can set a flag to record the fact that we found an error and keep it going until it reaches a reasonable checkpoint. This idea should be applicable to other places. For example, we can ignore broken relocations and check for errors after visiting all relocs. In this patch, I rename error to fatal, and introduce another version of error which doesn't call exit. That function instead sets HasError to true. Once HasError becomes true, it stays true, so that we know that there was an error if it is true. I think introducing a non-noreturn error reporting function is by itself a good idea, and it looks to me that this also provides a gradual path towards lld-as-a-library (or at least embed-lld-to-your-program) without sacrificing code readability with lots of ErrorOr's. http://reviews.llvm.org/D16641 llvm-svn: 259069
* Use an ilist instead of std::list. NFC.Pete Cooper2016-01-251-78/+115
| | | | | | | | | | | | The TrieNode/TrieEdge data structures here are allocated in a bumpptrallocator. Unfortunately, TrieNode contained a std::list<TrieEdge> and as the allocator doesn't call the TrieNode destructor, we ended up leaking the memory allocated by the std::list itself. Instead we can use an intrusive list as then we save the extra allocations anyway. llvm-svn: 258725
* Initialize member variable.Pete Cooper2016-01-251-1/+1
| | | | | | Found by Rafael using valgrind in https://llvm.org/bugs/show_bug.cgi?id=21466. llvm-svn: 258718
* Add support for export_dynamic cmdline option and behaviour.Pete Cooper2016-01-223-3/+15
| | | | | | | | | | | This option matches the behaviour of ld64, that is it prevents globals from being dead stripped in executables and dylibs. Reviewed by Lang Hames Differential Revision: http://reviews.llvm.org/D16026 llvm-svn: 258554
* Add an ObjCPass to the MachO linker.Pete Cooper2016-01-197-31/+168
| | | | | | | | | This pass currently emits an objc image info section if one is required. This section contains the aggregated version and flags for all of the input files. llvm-svn: 258197
* Set the objc constraint on the context based on the parsed files.Pete Cooper2016-01-191-0/+35
| | | | | | | | | | | | Like arch, os, etc, when we know we are going to use a file, we check that the file has compatible objc constraints to the context, throw appropriate errors where that is not the case, and hopefully set the objc constraints on the context for use later. Added 2 tests to ensure that we don't have incompatibilities between host and simulator code as both will get x86 based architectures. llvm-svn: 258173
* Cache the objc image info constraints in file.Pete Cooper2016-01-193-11/+20
| | | | | | | | | | Image info flags describe the objc constraint which is GC/retain/release/etc. These need to be parsed and stored in the file so that we can do error checking. That will come in a later commit. llvm-svn: 258160
* Only emit files with subsections_via_symbols if all inputs had that set.Pete Cooper2016-01-163-9/+32
| | | | | | | | | | | | When generating a relocatable file, its only valid to set this flag if all of the inputs also had the flag. Otherwise we may atomize incorrectly when we link the relocatable file again. Reviewed by Lang Hames. Differential Revision: http://reviews.llvm.org/D16018 llvm-svn: 257976
* Give error on binaries containing GC objc image infos.Pete Cooper2016-01-161-4/+12
| | | | | | | | The image info struct contains flags for what kind of GC/retain/release is required. Give an error if we parse GC flags as these are unsupported. llvm-svn: 257974
* Add checking of differing swift versions in input files.Pete Cooper2016-01-163-0/+18
| | | | | | | Swift versions are part of the objc image info section, and must match for all files linked which actually have an image info section llvm-svn: 257964
* Check that the objc image info version is exactly 0Pete Cooper2016-01-151-0/+8
| | | | llvm-svn: 257953
* Add the GC commandline options and throw errors if they are usedPete Cooper2016-01-152-0/+22
| | | | llvm-svn: 257907
* Error check the size of the __objc_imageinfo sectionPete Cooper2016-01-141-0/+44
| | | | llvm-svn: 257841
* Check for mismatched arch and OS when linking MachO files.Pete Cooper2016-01-143-0/+36
| | | | | | | | | | | | This patch makes use of the handleLoadedFile hook added in r257814. That method is used to check the arch and the OS of the files we are linking against the arch and OS on the context. The first test to use this ensures that we do not try to combine i386 Mac OS code with i386 simulator code. llvm-svn: 257837
* Add File::kind's for all subclasses of File.Pete Cooper2016-01-1418-27/+54
| | | | | | | | | | | | This is to enable isa<> support for any files which need it. It will be used in an upcoming patch to differentiate MachOFile from other implicitly generated files. Reviewed by Lang Hames. Differential Revision: http://reviews.llvm.org/D16103 llvm-svn: 257830
* Add handleLoadedFile hook to the context.Pete Cooper2016-01-142-22/+64
| | | | | | | | | | | | | | This is called from the resolver on each file we decide we actually want to use. Future commits will make use of this to extract useful information from the files and do error checking against the context. For example, ensure that files are the same arch as each other. Reviewed by Lang Hames. Differential Revision: http://reviews.llvm.org/D16093 llvm-svn: 257814
* Update for LLVM function name change.Rui Ueyama2016-01-147-33/+28
| | | | llvm-svn: 257801
* [old ELF] Remove AMDGPU targetTom Stellard2016-01-1115-429/+0
| | | | | | | | | | | | Summary: This is no longer needed now that the new ELF implementation supports AMDGPU. Reviewers: ruiu, rafael Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D15954 llvm-svn: 257390
* Always generate the fixup content for unwindFDEToFunction as we noPete Cooper2016-01-071-3/+11
| | | | | | longer emit it. llvm-svn: 257100
* Don't emit relocs for the __eh_frame section as they can be implicit.Pete Cooper2016-01-073-8/+34
| | | | | | | | | | | | | | The __eh_frame section contains relocations which can always be implicitly generated. This patch tracks whether sections have only implicitly relocations and skips emitting them to the object file if that is the case. The test case here ensures that this is the case for __eh_frame sections. Reviewed by Lang Hames. http://reviews.llvm.org/D15594 llvm-svn: 257099
* Set CMake ADDITIONAL_HEADER_DIRS on libraries with headers in /include. NFC.Pete Cooper2016-01-074-0/+16
| | | | | | | | | | | In a UI such as XCode, it can group the headers for a library with that library. This is done in the CMakeLists.txt for the library itself by setting the path(s) as ADDITIONAL_HEADER_DIRS. LLVM already does this for all of its libraries, so just adding this to lld to make things easier. Should be NFC. llvm-svn: 257002
* Set the folder for libraries to 'lld libraries'. NFC.Pete Cooper2016-01-0715-15/+15
| | | | | | | | | | | | In a UI such as XCode, LLVM source files are in 'libraries' while clang files are in 'clang libraries'. This change moves the lld source to 'lld libraries' to make code browsing easier. It should be NFC as the build itself is still the same, just the structure in a UI differs. llvm-svn: 257001
* Fix MachO arm64 delta32ToGOT reloc encoding in -r.Pete Cooper2016-01-061-1/+1
| | | | | | | | | | | | | The fixup content we encode here should be the offset from the fixup location back to the last nonlocal label. We were only encoding the address of the fixup, and not taking in to account the base address of the atom we are in. Updated the test case here to have a text section which will come before the data section where the relocation lives. .data being at offset 0 had previously been hiding this bug. llvm-svn: 256974
* Improved debugging printing. NFCPete Cooper2016-01-052-9/+54
| | | | llvm-svn: 256805
* Sort sections in relocatable files.Pete Cooper2016-01-041-102/+62
| | | | | | | | | | | | | | | | | The final section order in relocatable files was just a side effect of the atom sorter. This meant that sections like __data were before __text because __data has RW permissions and __text RX and RW was less than RX in our enum. Final linked images had an actual section/segment sorter. There was no reason for the difference, so simplify a bunch of code and just use the same sorted for everything. Reviewed by Lang Hames. http://reviews.llvm.org/D15868 llvm-svn: 256786
* Fix x86_64 delta*Anon relocs.Pete Cooper2016-01-041-2/+22
| | | | | | | | | | | | | | | | | | The encoded value should be an offset from the fixup location, which means that it should take in to account the fixup offset in its section. We weren't subtracting the base address of the atom, which meant that when we parsed the file again for a round trip, we had 2x the atom address in our target address. I've also improved comments for these to try and describe what is going on. There's no test case right now, as the bug is only exhibited when __data is at a non-zero address in a -r link. A commit will soon sort the sections differently and move __data to after __text. Then these relocations in test/mach-o/parse-data-relocs-x86_64.yaml will test for this bug. llvm-svn: 256779
* Fix negDelta32 relocatable fixups for arm64 in mach-o.Pete Cooper2015-12-161-1/+1
| | | | | | | | | | | negDelta32 is only ever implicitly generated as the FDE->CIE reference. We therefore don't emit a relocation for it in the object file in -r mode. The value we write in to the FDE location therefore needs to point to the final target address of the CIE, and not the inAtomAddress as it was currently doing. llvm-svn: 255835
* Add more debugging output to MachO lld. NFC.Pete Cooper2015-12-163-5/+49
| | | | | | | In debug builds there's now a dump method on Section and improved printing of atoms. llvm-svn: 255826
* Move parsing of LLVM options to parse() method.Pete Cooper2015-12-164-2/+15
| | | | | | | | | We used to parse the LLVM options in Driver::link. However, that is after parse() where we load files. By moving the LLVM option handling earlier, we can add DEBUG() to code such as MachONormalizedFileToAtoms.cpp and have it enabled correctly by '-mllvm --debug'. llvm-svn: 255819
* Added some DEBUG() prints to make it clearer what the mach-o passes are ↵Pete Cooper2015-12-162-2/+27
| | | | | | | | | | | | doing. NFC. We had some DEBUG prints these passes, but add more so that its clear where we are dumping things, and what state we are in when we do so. I'll be adding more and more DEBUG printing to try make it easier to observe whats going on without having to attach a debugger. llvm-svn: 255805
* [lld][MachO] Recognize __thread_bss sections as zero-fill and set all theLang Hames2015-12-117-14/+39
| | | | | | | | | appropriate bits. This fixes the remaining clang regression test failures when linking clang with lld on Darwin. llvm-svn: 255390
* Verify that macho-o delta64 relocs have the same offset.Pete Cooper2015-12-102-21/+50
| | | | | | | | | | The delta64 relocation is represented as the pair ARM64_RELOC_SUBTRACTOR and ARM64_RELOC_UNSIGNED. Those should always have the same offset, so this adds a check and tests to ensure this is the case. Also updated the error printing in this case to shows both relocs when erroring on pair. llvm-svn: 255274
* [lld][MachO] Always reserve space for the empty string in the mach-o symbolLang Hames2015-12-101-1/+1
| | | | | | | | | | | | | table. The first entry in the MachO symbol table is always the empty string: make sure we reserve space for it, or we will overflow the symbol table by one byte. No test case - this manifests as an occasional memory error. In the near future I hope to set up a bot building and runnnig LLD with sanitizers - that should catch future instances of this issue. llvm-svn: 255178
* Don't bypass the GOT for delta32toGOT references.Pete Cooper2015-12-091-0/+6
| | | | | | | | | | | The gcc_except_tab was generating these references to point to the typeinfo in the data section. gcc_except_tab also had the DW_EH_PE_indirect flag set which means that at runtime we are going to dereference this entry as if it is in the GOT. Reviewed by Nick Kledzik in http://reviews.llvm.org/D15360. llvm-svn: 255085
* Rename ld.lld2 to ld.lld since it is the default.Rafael Espindola2015-11-181-1/+1
| | | | llvm-svn: 253437
* Make ELF2 the default.Rafael Espindola2015-11-171-2/+2
| | | | | | With this the only way to get the old elf linker is "-flavor old-elf". llvm-svn: 253318
* Rename gnu2 to gnu.Rafael Espindola2015-11-161-4/+4
| | | | | | This is the second step in making ELF2 the default. llvm-svn: 253270
* Rename the gnu flavour to gnu old.Rafael Espindola2015-11-161-9/+9
| | | | | | This is the first step in making ELF2 the default. llvm-svn: 253188
* Fix Clang-tidy modernize-use-auto warnings, other minor fixes.Eugene Zelenko2015-11-1013-109/+53
| | | | | | Differential revision: http://reviews.llvm.org/D14553 llvm-svn: 252661
* These are the matching changes needed to the lld project for the changes to llvmKevin Enderby2015-11-051-12/+22
| | | | | | | in r252192 that changed the Archive and Child interfaces in libObject. These include Rafael Espindola’s many suggested updates. llvm-svn: 252193
* Fix Clang-tidy modernize-use-override warnings, other minor fixes.Eugene Zelenko2015-11-041-5/+4
| | | | | | Differential revision: http://reviews.llvm.org/D14310 llvm-svn: 252034
* [lld][MachO] Make sure LC_RPATH command size is a multiple of the pointer size.Lang Hames2015-10-291-2/+2
| | | | llvm-svn: 251637
* [lld][MachO] Use a std::string rather than a StringRef for the section name inLang Hames2015-10-291-1/+1
| | | | | | | | | MachODefinedCustomSectionAtom. The section names for these atoms are initialized from temporaries (e.g. segName + "/" + sectName), so we can't use StringRef here. llvm-svn: 251610
* [Driver] Ignore -G option in both new and old ELF linkerSimon Atanasyan2015-10-281-0/+3
| | | | | | | This is optimization option that make sense for MIPS targets. We can safely ignore it now. llvm-svn: 251519
* [Driver] Accept both -m <emulation> and -m<emulation>Simon Atanasyan2015-10-281-1/+1
| | | | | | | | | GNU linkers accept both variants and at least for MIPS target gcc passes joined variant of the '-m' option. Differential Revision: http://reviews.llvm.org/D14133 llvm-svn: 251497
* [lld][Darwin] Add support for the -sectcreate option.Lang Hames2015-10-246-2/+132
| | | | llvm-svn: 251183
* [lld][MachO] Prune unused EH frames.Lang Hames2015-10-231-0/+51
| | | | llvm-svn: 251095
* Update lld to match llvm r250901. OptTable constructor now takes an ↵Craig Topper2015-10-214-4/+4
| | | | | | ArrayRef. NFC llvm-svn: 250904
* [lld][MachO] Fix indentation.Lang Hames2015-10-201-2/+2
| | | | llvm-svn: 250863
* [lld][MachO] Fix typo in comment.Lang Hames2015-10-201-1/+1
| | | | llvm-svn: 250861
OpenPOWER on IntegriCloud