aboutsummaryrefslogtreecommitdiff
path: root/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp
AgeCommit message (Collapse)AuthorFilesLines
2022-01-05Revert "Revert D109159 "[amdgpu] Enable selection of `s_cselect_b64`.""Nico Weber1-614/+0
This reverts commit 859ebca744e634dcc89a2294ffa41574f947bd62. The change contained many unrelated changes and e.g. restored unit test failes for the old lld port.
2022-01-05Revert D109159 "[amdgpu] Enable selection of `s_cselect_b64`."David Salinas1-0/+614
This reverts commit 640beb38e7710b939b3cfb3f4c54accc694b1d30. That commit caused performance degradtion in Quicksilver test QS:sGPU and a functional test failure in (rocPRIM rocprim.device_segmented_radix_sort). Reverting until we have a better solution to s_cselect_b64 codegen cleanup Change-Id: Ibf8e397df94001f248fba609f072088a46abae08 Reviewed By: kzhuravl Differential Revision: https://reviews.llvm.org/D115960 Change-Id: Id169459ce4dfffa857d5645a0af50b0063ce1105
2021-12-02[lld-macho] Remove old macho darwin lldKeith Smiley1-614/+0
During the llvm round table it was generally agreed that the newer macho lld implementation is feature complete enough to replace the old implementation entirely. This will reduce confusion for new users who aren't aware of the history. Differential Revision: https://reviews.llvm.org/D114842
2020-07-02ld64.lld: Add janky support for tbd filesNico Weber1-0/+21
With this, a simple hello world links against libSystem.tbd and the old ld64.lld linker kind of works again with newer SDKs. The motivation here is to have an arm64 cross linker that's good enough to be able to run simple configure link checks on non-mac systems for generating config.h files. Once -flavor darwinnew can link arm64, we'll switch to that.
2019-08-14[LLD] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere1-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
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth1-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
2017-10-02Move new lld's code to Common subdirectory.Rui Ueyama1-1/+1
New lld's files are spread under lib subdirectory, and it isn't easy to find which files are actually maintained. This patch moves maintained files to Common subdirectory. Differential Revision: https://reviews.llvm.org/D37645 llvm-svn: 314719
2017-07-20lld matching change for llvm change r308690 to add error handling toKevin Enderby1-1/+4
the dyld compact export entries in libObject. llvm-svn: 308691
2017-07-07[MachO] Add missing byte-swaps when reading dyld_infoTom Stellard1-3/+3
Summary: This fixes the following tests on big-endian hosts: lld :: mach-o/dylib-install-names.yaml lld :: mach-o/force_load-dylib.yaml lld :: mach-o/lib-search-paths.yaml lld :: mach-o/upward-dylib-load-command.yaml Reviewers: lhames, kledzik, ruiu Reviewed By: ruiu Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D35022 llvm-svn: 307405
2017-06-07Move Object format code to lib/BinaryFormat.Zachary Turner1-7/+8
This creates a new library called BinaryFormat that has all of the headers from llvm/Support containing structure and layout definitions for various types of binary formats like dwarf, coff, elf, etc as well as the code for identifying a file from its magic. Differential Revision: https://reviews.llvm.org/D33843 llvm-svn: 304864
2016-11-11Prevent at compile time converting from Error::success() to Expected<T>Mehdi Amini1-2/+2
This would trigger an assertion at runtime otherwise. Differential Revision: https://reviews.llvm.org/D26482 llvm-svn: 286562
2016-07-27[lld][MachO] Re-apply r276921 with fix - initialize strings for debug stringLang Hames1-3/+7
copies. llvm-svn: 276935
2016-07-27[lld][MachO] Temporarily revert r276921 - it's causing bot-failures on Linux.Lang Hames1-7/+3
llvm-svn: 276928
2016-07-27[lld][MachO] Add debug info support for MachO.Lang Hames1-3/+7
This patch causes LLD to build stabs debugging symbols for files containing DWARF debug info, and to propagate existing stabs symbols for object files built using '-r' mode. This enables debugging of binaries generated by LLD from MachO objects. llvm-svn: 276921
2016-03-31Convert a few macho reader/writer helpers to new error handling. NFC.Pete Cooper1-9/+9
These methods were responsible for some of the few remaining calls to llvm::errorCodeToError. Converting them makes us have more Error's in the api and fewer error_code's. llvm-svn: 264974
2016-03-30Convert readBinary to llvm::Error. NFCPete Cooper1-6/+7
llvm-svn: 264973
2016-03-23Copy MachO struct to temporary to avoid unaligned load UB.Pete Cooper1-4/+4
We were already copying this data to a temporary for endian swaps. Now we just always copy it, but still only do the endian swaps when needed. llvm-svn: 264172
2016-02-04Generate version min load commands when the platform is unknown.Pete Cooper1-0/+9
In the case where we are emitting to an object file, the platform is possibly unknown, and the source object files contained load commands for version min, we can take the maximum of those min versions and emit in in the output object file. This test also tests r259739. llvm-svn: 259742
2015-04-27Use MemoryBufferRef instead of MemoryBuffer&. NFC.Rafael Espindola1-4/+3
This just reduces the noise from another patch. llvm-svn: 235933
2015-04-24Use MemoryBufferRef instead of MemoryBuffer&. NFC.Rafael Espindola1-2/+2
This just reduces the noise from another patch. llvm-svn: 235776
2015-04-24Return an ErrorOr<std::unique_ptr<File>>. NFC.Rafael Espindola1-10/+12
llvm-svn: 235741
2015-04-24Delete unnecessary generality in loadFile.Rafael Espindola1-10/+9
loadFile could load mulitple files just because yaml has a feature for putting multiple documents in one file. Designing a linker around what yaml can do seems like a bad idea to me. This patch changes it to read a single file. There are further improvements to be done to the api and they will follow shortly. llvm-svn: 235724
2015-04-04Remove a parameter for file extension from canParse.Rui Ueyama1-11/+5
canParse took three parameters -- file magic, filename extension and memory buffer. All but YAMLReader ignored the second parameter. This patch removes the parameter. llvm-svn: 234080
2015-03-26Define an implicit constructor which takes actual alignment value to PowerOf2.Rui Ueyama1-2/+2
The new constructor's type is the same, but this one takes not a log2 value but an alignment value itself, so the meaning is totally differnet. llvm-svn: 233244
2015-03-26Make PowerOf2's constructor private.Rui Ueyama1-2/+2
Ban conversion from integers to PowerOf2 even if explicit to make all places we create PowerOf2 instances visible. llvm-svn: 233243
2015-03-26Remove implicit constructor and operator int from PowerOf2.Rui Ueyama1-2/+2
This patch is to make instantiation and conversion to an integer explicit, so that we can mechanically replace all occurrences of the class with integer in the next step. Now get() returns an alignment value rather than its log2 value. llvm-svn: 233242
2015-02-22[Core,MachO,Test] Remove trailing whitespace.Shankar Easwaran1-1/+1
llvm-svn: 230192
2015-01-15Re-commit r225674: Convert other drivers to use WrapperNode.Rui Ueyama1-5/+4
The original commit had an issue with Mac OS dylib files. It didn't handle fat binary dylib files correctly. This patch includes a fix. A test for that case has already been committed in r225764. llvm-svn: 226123
2015-01-14Revert "Convert other drivers to use WrapperNode" and subsequent commits.Rui Ueyama1-4/+5
r225764 broke a basic functionality on Mac OS. This change reverts r225764, r225766, r225767, r225769, r225814, r225816, r225829, and r225832. llvm-svn: 225859
2015-01-13Convert other drivers to use WrapperNode.Rui Ueyama1-5/+4
llvm-svn: 225764
2014-12-20[macho] Minor install_name fixesJean-Daniel Dupas1-0/+2
Summary: Fix the binary file reader to properly read dyld version info. Update the install_name test case to properly test the binary reader. We can't use '-print_atoms' as the output format is 'native' yaml and it does not contains the dyld current and compatibility versions. Also change the timestamp value of LD_ID_DYLD to match the one generated by ld64. The dynamic linker (dyld) used to expects different values for timestamp in LD_ID_DYLD and LD_LOAD_DYLD for prebound images. While prebinding is deprecated, we should probably keep it safe and match ld64. Reviewers: kledzik Subscribers: llvm-commits Projects: #lld Differential Revision: http://reviews.llvm.org/D6736 llvm-svn: 224681
2014-12-18[macho] -rpath supportJean-Daniel Dupas1-0/+5
Summary: Work on adding -rpath support to the mach-o linker. This patch is based on the ld64 behavior for the command line option validation. It includes a basic test to check that the LC_RPATH load commands are properly generated when that option is used. It also add LC_RPATH support to the binary reader, but I don't know how to test it though. Reviewers: kledzik Subscribers: llvm-commits Projects: #lld Differential Revision: http://reviews.llvm.org/D6724 llvm-svn: 224544
2014-12-12Make File always take the ownership of a MemoryBuffer.Rui Ueyama1-4/+4
The documentation of parseFile() said that "the resulting File object may take ownership of the MemoryBuffer." So, whether or not the ownership of a MemoryBuffer would be taken was not clear. A FileNode (a subclass of InputElement, which is being deprecated) keeps the ownership if a File doesn't take it. This patch makes File always take the ownership of a buffer. Buffers lifespan is not always the same as File instances. Files are able to deallocate buffers after parsing the contents. llvm-svn: 224113
2014-12-12Separate file parsing from File's constructors.Rui Ueyama1-15/+32
This is a second patch for InputGraph cleanup. Sorry about the size of the patch, but what I did in this patch is basically moving code from constructor to a new method, parse(), so the amount of new code is small. This has no change in functionality. We've discussed the issue that we have too many classes to represent a concept of "file". We have File subclasses that represent files read from disk. In addition to that, we have bunch of InputElement subclasses (that are part of InputGraph) that represent command line arguments for input file names. InputElement is a wrapper for File. InputElement has parseFile method. The method instantiates a File. The File's constructor reads a file from disk and parses that. Because parseFile method is called from multiple worker threads, file parsing is processed in parallel. In other words, one reason why we needed the wrapper classes is because a File would start reading a file as soon as it is instantiated. So, the reason why we have too many classes here is at least partly because of the design flaw of File class. Just like threads in a good threading library, we need to separate instantiation from "start" method, so that we can instantiate File objects when we need them (which should be very fast because it involves only one mmap() and no real file IO) and use them directly instead of the wrapper classes. Later, we call parse() on each file in parallel to let them do actual file IO. In this design, we can eliminate a reason to have the wrapper classes. In order to minimize the size of the patch, I didn't go so far as to replace the wrapper classes with File classes. The wrapper classes are still there. In this patch, we call parse() immediately after instantiating a File, so this really has no change in functionality. Eventually the call of parse() should be moved to Driver::link(). That'll be done in another patch. llvm-svn: 224102
2014-11-19[mach-o] propagate dylib version numbersNick Kledzik1-1/+3
Mach-o does not use a simple SO_NEEDED to track dependent dylibs. Instead, the linker copies four things from each dylib to each client: the runtime path (aka "install name"), the build time, current version (dylib build number), and compatibility version The build time is no longer used (it cause every rebuild of a dylib to be different). The compatibility version is usually just 1.0 and never changes, or the dylib becomes incompatible. This patch copies that information into the NormalizedMachO format and propagates it to clients. llvm-svn: 222300
2014-11-14Follow-up to r221913. Fix some -Wcast-qual warning reasons.Simon Atanasyan1-6/+6
llvm-svn: 221974
2014-10-27TMP: fix readN & writeN to not encourage UBTim Northover1-79/+78
llvm-svn: 220730
2014-10-18Sort include files according to convention.Shankar Easwaran1-2/+0
llvm-svn: 220131
2014-10-08[mach-o] Support fat archivesNick Kledzik1-36/+44
mach-o supports "fat" files which are a header/table-of-contents followed by a concatenation of mach-o files (or archives of mach-o files) built for different architectures. Previously, the support for fat files was in the MachOReader, but that only supported fat .o files and dylibs (not archives). The fix is to put the fat handing into MachOFileNode. That way any input file kind (including archives) can be fat. MachOFileNode selects the sub-range of the fat file that matches the arch being linked and creates a MemoryBuffer for just that subrange. llvm-svn: 219268
2014-09-04[mach-o] Let darwin driver infer arch from .o files if -arch not used.Nick Kledzik1-19/+54
Mach-O has a "fat" (or "universal") variant where the same contents built for different architectures are concatenated into one file with a table-of-contents header at the start. But this leaves a dilemma for the linker - which architecture to use. Normally, the linker command line -arch is used to force which slice of any fat files are used. The clang compiler always passes -arch to the linker when invoking it. But some Makefiles invoke the linker directly and don’t specify the -arch option. For those cases, the linker scans all input files in command line order and finds the first non-fat object file. Whatever architecture it is becomes the architecture for the link. llvm-svn: 217189
2014-09-03[mach-o] Add support for using export triesNick Kledzik1-1/+29
On Darwin at runtime, dyld will prefer to use the export trie of a dylib instead of the traditional symbol table (which is large and requires a binary search). This change enables the linker to generate an export trie and to prefer it if found in a dylib being linked against. This also simples the yaml for dylibs because the yaml form of the trie can be reduced to just a sequence of names. llvm-svn: 217066
2014-08-13[mach-o] Support re-exported dylibsNick Kledzik1-13/+32
In general two-level namespace means each program records exactly which dylib each undefined (imported) symbol comes from. But, sometimes the implementor wants to hide the implementation dylib. For instance libSytem.dylib is the base dylib all Darwin programs must link with. A few years ago it was split up into two dozen dylibs by all are hidden behind libSystem.dylib which re-exports each sub-dylib. All clients still think libSystem.dylib is the implementor. To support this, the linker must load "indirect" dylibs and not just the "direct" dylibs specified on the command line. This is done in the createImplicitFiles() method after all command line specified files are loaded. Since an indirect dylib may have already been loaded as a direct dylib (or indirectly via a previous direct dylib), the MachOLinkingContext keeps a list of all loaded dylibs. With this change hello world can now be linked against the real OS or SDK. llvm-svn: 215605
2014-07-24[mach-o] Add support for LC_DATA_IN_CODENick Kledzik1-8/+21
Sometimes compilers emit data into code sections (e.g. constant pools or jump tables). These runs of data can throw off disassemblers. The solution in mach-o is that ranges of data-in-code are encoded into a table pointed to by the LC_DATA_IN_CODE load command. The way the data-in-code information is encoded into lld's Atom model is that that start and end of each data run is marked with a Reference whose offset is the start/end of the data run. For arm, the switch back to code also marks whether it is thumb or arm code. llvm-svn: 213901
2014-07-16[mach-o] refactor KindHandler into ArchHandler and simplify passes.Nick Kledzik1-21/+7
All architecture specific handling is now done in the appropriate ArchHandler subclass. The StubsPass and GOTPass have been simplified. All architecture specific variations in stubs are now encoded in a table which is vended by the current ArchHandler. llvm-svn: 213187
2014-07-01[mach-o] add representation for LC_ID_DYLIB to MachONormalizedFileTim Northover1-0/+9
It still needs to be tied into BinaryReader, but this allows reasonably sensible creation of SharedLibrary atoms on MachO. llvm-svn: 212093
2014-06-30[mach-o] improve errors when mixing architecturesNick Kledzik1-18/+15
llvm-svn: 212072
2014-06-30MachO: support atomization of dylibs.Tim Northover1-1/+2
For .dylib files, we refrain from actually creating any atoms until they're requested via the "exports" method. llvm-svn: 212027
2014-06-27[mach-o] refactor x86_64 relocation handling.Nick Kledzik1-1/+1
This is first step in reworking how mach-o relocations are processed. The existing KindHandler is going to become a delgate/helper object for processing architecture specific references. The KindHandler knows how to convert mach-o relocations into References and back, as well, as fixing up the content the relocation is on. One of the messy things about mach-o relocations is that they sometime come in pairs, but the pairs still convert to one lld::Reference. So, the conversion has to detect pairs (arch specific) and change the stride. llvm-svn: 211921
2014-06-14Using llvm::sys::swapByteOrder() for the common case of byte-swapping a ↵Artyom Skrobov1-5/+7
value in place llvm-svn: 210979
2014-06-14Left two files out of the previous commitArtyom Skrobov1-3/+3
llvm-svn: 210975