summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Object
Commit message (Collapse)AuthorAgeFilesLines
...
* [WebAssembly] clang-tidy (NFC)Heejin Ahn2019-02-041-18/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch fixes clang-tidy warnings on wasm-only files. The list of checks used is: `-*,clang-diagnostic-*,llvm-*,misc-*,-misc-unused-parameters,readability-identifier-naming,modernize-*` (LLVM's default .clang-tidy list is the same except it does not have `modernize-*`. But I've seen in multiple CLs in LLVM the modernize style was recommended and code was fixed based on the style, so I added it as well.) The common fixes are: - Variable names start with an uppercase letter - Function names start with a lowercase letter - Use `auto` when you use casts so the type is evident - Use inline initialization for class member variables - Use `= default` for empty constructors / destructors - Use `using` in place of `typedef` Reviewers: sbc100, tlively, aardappel Subscribers: dschuff, sunfish, jgravelle-google, yurydelendik, kripken, MatzeB, mgorny, rupprecht, llvm-commits Differential Revision: https://reviews.llvm.org/D57500 llvm-svn: 353075
* [WebAssembly] Rename relocations from R_WEBASSEMBLY_ to R_WASM_Sam Clegg2019-02-041-16/+16
| | | | | | | | | | | | | | | | See https://github.com/WebAssembly/tool-conventions/pull/95. This is less typing and IMHO more readable, and it also fits with our naming around the binary format which tends to use the short name. e.g. include/llvm/BinaryFormat/Wasm.h tools/llvm-objdump/WasmDump.cpp etc.. Differential Revision: https://reviews.llvm.org/D57611 llvm-svn: 353062
* [AsmPrinter] Remove hidden flag -print-schedule.Andrea Di Biagio2019-02-042-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch removes hidden codegen flag -print-schedule effectively reverting the logic originally committed as r300311 (https://llvm.org/viewvc/llvm-project?view=revision&revision=300311). Flag -print-schedule was originally introduced by r300311 to address PR32216 (https://bugs.llvm.org/show_bug.cgi?id=32216). That bug was about adding "Better testing of schedule model instruction latencies/throughputs". These days, we can use llvm-mca to test scheduling models. So there is no longer a need for flag -print-schedule in LLVM. The main use case for PR32216 is now addressed by llvm-mca. Flag -print-schedule is mainly used for debugging purposes, and it is only actually used by x86 specific tests. We already have extensive (latency and throughput) tests under "test/tools/llvm-mca" for X86 processor models. That means, most (if not all) existing -print-schedule tests for X86 are redundant. When flag -print-schedule was first added to LLVM, several files had to be modified; a few APIs gained new arguments (see for example method MCAsmStreamer::EmitInstruction), and MCSubtargetInfo/TargetSubtargetInfo gained a couple of getSchedInfoStr() methods. Method getSchedInfoStr() had to originally work for both MCInst and MachineInstr. The original implmentation of getSchedInfoStr() introduced a subtle layering violation (reported as PR37160 and then fixed/worked-around by r330615). In retrospect, that new API could have been designed more optimally. We can always query MCSchedModel to get the latency and throughput. More importantly, the "sched-info" string should not have been generated by the subtarget. Note, r317782 fixed an issue where "print-schedule" didn't work very well in the presence of inline assembly. That commit is also reverted by this change. Differential Revision: https://reviews.llvm.org/D57244 llvm-svn: 353043
* [WebAssembly] Add missing SymbolRef update from rL352551Sam Clegg2019-01-301-2/+2
| | | | | | | | This change broke some MC tests which are now fixed. Differential Revision: https://reviews.llvm.org/D57424 llvm-svn: 352573
* [WebAssembly] Ensure BasicSymbolRef.getRawDataRefImpl().p is non-nullSam Clegg2019-01-291-4/+6
| | | | | | | | | | | | Store a non-zero value to ref.d.a and use ref.d.b to store the symbol index. This means that ref.p is never null, which was confusing llvm-nm. Fixes PR40497 Differential Revision: https://reviews.llvm.org/D57373 llvm-svn: 352551
* [COFF] Add new relocation types.Martin Storsjo2019-01-271-0/+3
| | | | | | Differential Revision: https://reviews.llvm.org/D57291 llvm-svn: 352324
* allow COFF .def directive in module assembly when using ThinLTOBob Haarman2019-01-241-0/+9
| | | | | | | | | | | | | | | | | | | | Summary: Using COFF's .def directive in module assembly used to crash ThinLTO with "this directive only supported on COFF targets" when getting symbol information in ModuleSymbolTable. This change allows ModuleSymbolTable to process such code and adds a test to verify that the .def directive has the desired effect on the native object file, with and without ThinLTO. Fixes https://bugs.llvm.org/show_bug.cgi?id=36789 Reviewers: rnk, pcc, vlad.tsyrklevich Subscribers: mehdi_amini, eraman, hiraditya, dexonsmith, llvm-commits Differential Revision: https://reviews.llvm.org/D57073 llvm-svn: 352112
* Limit dyld image suffixes guessed by guessLibraryShortName()Michael Trent2019-01-241-3/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: guessLibraryShortName() separates a full Mach-O dylib install name path into a short name and a dyld image suffix. The short name is the name of the dylib without its path or extension. The dyld image suffix is a string used by dyld to load variants of dylibs if available at runtime; for example, "when binding this process, load 'debug' variants of all required dylibs." dyld knows exactly what the image suffix is, but by convention diagnostic tools such as llvm-nm attempt to guess suffix names by looking at the install name path. These dyld image suffixes are separated from the short name by a '_' character. Because the '_' character is commonly used to separate words in filenames guessLibraryShortName() cannot reliably separate a dylib's short name from an arbitrary image suffix; imagine if both the short name and the suffix contains an '_' character! To better deal with this ambiguity, guessLibraryShortName() will recognize only "_debug" and "_profile" as valid Suffix values. Calling code needs to be tolerant of guessLibraryShortName() guessing incorrectly. The previous implementation of guessLibraryShortName() did not allow '_' characters to appear in short names. When present, the short name would be truncated, e.g., "libcompiler_rt" => "libcompiler". This change allows "libcompiler_rt" and "libcompiler_rt_debug" to both be recognized as "libcompiler_rt". rdar://47412244 Reviewers: kledzik, lhames, pete Reviewed By: pete Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D56978 llvm-svn: 352104
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-1924-96/+72
| | | | | | | | | | | | | | | | | 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
* [WebAssembly] Fixed objdump not parsing function headers.Wouter van Oortmerssen2019-01-171-1/+12
| | | | | | | | | | | | | | | | | | | | | | | Summary: objdump was interpreting the function header containing the locals declaration as instructions. To parse these without injecting target specific code in objdump, MCDisassembler::onSymbolStart was added to be implemented by the WebAssembly implemention. WasmObjectFile now returns a code offset for the "address" of a symbol, rather than the index. This is also more in-line with what other targets do. Also ensured that the AsmParser correctly puts each function in its own segment to enable this test case. Reviewers: sbc100, dschuff Subscribers: jgravelle-google, aheejin, sunfish, rupprecht, llvm-commits Differential Revision: https://reviews.llvm.org/D56684 llvm-svn: 351460
* [WebAssembly] Parse llvm.ident into producers sectionThomas Lively2019-01-171-0/+45
| | | | llvm-svn: 351413
* Revert "[WebAssembly] Parse llvm.ident into producers section"Thomas Lively2019-01-171-45/+0
| | | | | | This reverts commit eccdbba3a02a33e13b5262e92200a33e2ead873d. llvm-svn: 351410
* [WebAssembly] Parse llvm.ident into producers sectionThomas Lively2019-01-161-0/+45
| | | | | | | | | | | | | | Summary: Everything before the word "version" is the tool, and everything after the word "version" is the version. Reviewers: aheejin, dschuff Subscribers: sbc100, jgravelle-google, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D56742 llvm-svn: 351399
* [Object] Return a symbol_iterator, rather than a basic_symbol_iterator, fromLang Hames2019-01-141-1/+1
| | | | | | | | | | | | | | MachOObjectFile::getSymbolByIndex. ObjectFile derivatives should prefer symbol_iterator/SymbolRef over basic_symbol_iterator/BasicSymbolRef where possible, as the former retain their link to the ObjectFile (rather than a SymbolicFile) and provide more functionality. No test for this: Existing code is working, and we don't have (m)any libObject unit tests. I'll think about how we can test more systematically going forward. llvm-svn: 351128
* Don't require a null terminator when loading objectsDavid Major2019-01-091-1/+2
| | | | | | | | | | When a null terminator is required and the file size is a multiple of the system page size, MemoryBuffer will prefer pread() over mmap(), which can result in excessive memory usage. Patch by Mike Hommey! Differential Revision: https://reviews.llvm.org/D56475 llvm-svn: 350774
* [WebAssembly] Massive instruction renamingThomas Lively2019-01-081-3/+3
| | | | | | | | | | | | | | | Summary: An automated renaming of all the instructions listed at https://github.com/WebAssembly/spec/issues/884#issuecomment-426433329 as well as some similarly-named identifiers. Reviewers: aheejin, dschuff, aardappel Subscribers: sbc100, jgravelle-google, eraman, sunfish, jfb, llvm-commits Differential Revision: https://reviews.llvm.org/D56338 llvm-svn: 350609
* [llvm-readobj] [COFF] Print the symbol index for relocationsMartin Storsjo2019-01-031-0/+10
| | | | | | | | | | There can be multiple local symbols with the same name (for e.g. comdat sections), and thus the symbol name itself isn't enough to disambiguate symbols. Differential Revision: https://reviews.llvm.org/D56140 llvm-svn: 350288
* Add vtable anchor to classes.Richard Trieu2018-12-291-0/+1
| | | | llvm-svn: 350142
* [llvm-ar] Simplify string table get-or-insert pattern with .insert, NFCReid Kleckner2018-12-191-6/+4
| | | | llvm-svn: 349681
* [Object] Deduplicate long archive member namesPeter Wu2018-12-191-4/+22
| | | | | | | | | | | | | Summary: Import libraries as created by llvm-dlltool always use the same archive member name for every object file (namely, the DLL library name). Ensure that long names are not repeatedly stored in the string table. Reviewed By: ruiu Differential Revision: https://reviews.llvm.org/D55860 llvm-svn: 349637
* [llvm-objcopy] Initial COFF supportMartin Storsjo2018-12-191-0/+12
| | | | | | | | | This is an initial implementation of no-op passthrough copying of COFF with objcopy. Differential Revision: https://reviews.llvm.org/D54939 llvm-svn: 349605
* [WebAssembly] Check if the section order is correctHeejin Ahn2018-12-151-3/+67
| | | | | | | | | | | | | | | | | | | | Summary: This patch checks if the section order is correct when reading a wasm object file in `WasmObjectFile` and converting YAML to wasm object in yaml2wasm. (It is not possible to check when reading YAML because it is handled exclusively by the YAML reader.) This checks the ordering of all known sections (core sections + known custom sections). This also adds section ID DataCount section that will be scheduled to be added in near future. Reviewers: sbc100 Subscribers: dschuff, mgorny, jgravelle-google, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D54924 llvm-svn: 349221
* [Object] Rename getRelrRelocationType to getRelativeRelocationTypeFangrui Song2018-12-141-2/+2
| | | | | | | | | | | | | | | | | Summary: The two utility functions were added in D47919 to support SHT_RELR. However, these are just relative relocations types and are't necessarily be named Relr. Reviewers: phosek, dberris Reviewed By: dberris Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D55691 llvm-svn: 349133
* [macho] save the SDK version stored in module metadata into the version min andAlex Lorenz2018-12-141-0/+1
| | | | | | | | | | | | | | | | | | | | | build version load commands in the object file This commit introduces a new metadata node called "SDK Version". It will be set by the frontend to mark the platform SDK (macOS/iOS/etc) version which was used during that particular compilation. This node is used when machine code is emitted, by either saving the SDK version into the appropriate macho load command (version min/build version), or by emitting the assembly for these load commands with the SDK version specified as well. The assembly for both load commands is extended by allowing it to contain the sdk_version X, Y [, Z] trailing directive to represent the SDK version respectively. rdar://45774000 Differential Revision: https://reviews.llvm.org/D55612 llvm-svn: 349119
* [llvm-size][libobject] Add explicit "inTextSegment" methods similar to ↵Jordan Rupprecht2018-12-131-0/+8
| | | | | | | | | | | | | | | | | | | | | "isText" section methods to calculate size correctly. Summary: llvm-size uses "isText()" etc. which seem to indicate whether the section contains code-like things, not whether or not it will actually go in the text segment when in a fully linked executable. The unit test added (elf-sizes.test) shows some types of sections that cause discrepencies versus the GNU size tool. llvm-size is not correctly reporting sizes of things mapping to text/data segments, at least for ELF files. This fixes pr38723. Reviewers: echristo, Bigcheese, MaskRay Reviewed By: MaskRay Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D54369 llvm-svn: 349074
* [WebAssembly] Update dylink section parsingSam Clegg2018-12-121-0/+6
| | | | | | | | | | This updates the format of the dylink section in accordance with recent "spec" change: https://github.com/WebAssembly/tool-conventions/pull/77 Differential Revision: https://reviews.llvm.org/D55609 llvm-svn: 348989
* [COFF] Map truncated .eh_frame section nameMartin Storsjo2018-12-081-0/+6
| | | | | | | | | | | | | | | PE/COFF sections can have section names truncated to 8 chars, in order to have the name available at runtime. (The string table, where long untruncated names are stored, isn't loaded at runtime.) This allows various llvm tools to dump the .eh_frame section from such executables. Patch by Peiyuan Song! Differential Revision: https://reviews.llvm.org/D55407 llvm-svn: 348708
* [WebAssembly] Make WasmSymbol's signature usable for events (NFC)Heejin Ahn2018-12-081-5/+7
| | | | | | | | | | | | | | Summary: WasmSignature used to use its `WasmSignature` member variable only for function types, but now it also can be used for events as well. Reviewers: sbc100 Subscribers: dschuff, jgravelle-google, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D55247 llvm-svn: 348702
* Use llvm::copy. NFCFangrui Song2018-11-172-5/+4
| | | | llvm-svn: 347126
* [MSP430] Add MC layerAnton Korobeynikov2018-11-151-0/+7
| | | | | | | | | | | | | | Reapply r346374 with the fixes for modules build. Original summary: This change implements assembler parser, code emitter, ELF object writer and disassembler for the MSP430 ISA. Also, more instruction forms are added to the target description. Patch by Michael Skvortsov! llvm-svn: 346948
* [WebAssembly] Add support for dylink section in object formatSam Clegg2018-11-141-1/+16
| | | | | | | | See https://github.com/WebAssembly/tool-conventions/blob/master/DynamicLinking.md. Differential Revision: https://reviews.llvm.org/D54490 llvm-svn: 346880
* [WebAssembly] Add support for the event sectionHeejin Ahn2018-11-141-3/+92
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This adds support for the 'event section' specified in the exception handling proposal. (This was named 'exception section' first, but later renamed to 'event section' to take possibilities of other kinds of events into consideration. But currently we only store exception info in this section.) The event section is added between the global section and the export section. This is for ease of validation per request of the V8 team. This patch: - Creates the event symbol type, which is a weak symbol - Makes 'throw' instruction take the event symbol '__cpp_exception' - Adds relocation support for events - Adds WasmObjectWriter / WasmObjectFile (Reader) support - Adds obj2yaml / yaml2obj support - Adds '.eventtype' printing support Reviewers: dschuff, sbc100, aardappel Subscribers: jgravelle-google, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D54096 llvm-svn: 346825
* [Support] Make error banner optional in logAllUnhandledErrorsJonas Devlieghere2018-11-111-3/+3
| | | | | | | | In a lot of places an empty string was passed as the ErrorBanner to logAllUnhandledErrors. This patch makes that argument optional to simplify the call sites. llvm-svn: 346604
* Revert "[MSP430] Add MC layer"Davide Italiano2018-11-081-7/+0
| | | | | | | | | | | This commit broke the module buildbots. Error: lib/Target/MSP430/MSP430GenAsmMatcher.inc:1027:1: error: redundant namespace 'llvm' [-Wmodules-import-nested-redundant] ^ llvm-svn: 346410
* [MSP430] Add MC layerAnton Korobeynikov2018-11-081-0/+7
| | | | | | | | | | | | | | | | | Summary: This change implements assembler parser, code emitter, ELF object writer and disassembler for the MSP430 ISA. Also, more instruction forms are added to the target description. Reviewers: asl Reviewed By: asl Subscribers: pftbest, krisb, mgorny, llvm-commits Differential Revision: https://reviews.llvm.org/D53661 llvm-svn: 346374
* [WebAssembly] Add shared memory support to limits fieldDerek Schuff2018-11-061-1/+1
| | | | | | | | | | Support the IS_SHARED bit in the memory limits flag word. The compiler does not create object files with memory definitions, but the field is used by the linker. Differential Revision: https://reviews.llvm.org/D54131 llvm-svn: 346246
* llvm-ar: Darwin archive format fixes.James Y Knight2018-10-101-26/+35
| | | | | | | | | | | | | * Support writing the DARWIN64 symbol table format. * In darwin archives, emit a symbol table whenever requested, even when there are no members, as the apple linker will abort if given an archive without a symbol table. Added tests for same, and also simplified and moved the GNU 64-bit symbol table test into archive-symtab.test. llvm-svn: 344183
* Give same-named members unique timestamps on Darwin in llvm-ar.James Y Knight2018-10-041-7/+70
| | | | | | | | | | | | | This change ensures that the (membername,timestamp) tuple uniquely identifies an entry in an archive for format=darwin, in deterministic mode (which is the default). That, then, enables lldb and dsymutil to locate the appropriate object within the archive. Differential Revision: https://reviews.llvm.org/D47659 llvm-svn: 343805
* [WebAssembly] Refactor WasmSignature and use it for MCSymbolWasmDerek Schuff2018-10-031-5/+4
| | | | | | | | | | | | MCContext does not destroy MCSymbols on shutdown. So, rather than putting SmallVectors (which may heap-allocate) inside MCSymbolWasm, use unowned pointer to a WasmSignature instead. The signatures are now owned by the AsmPrinter. Also uses WasmSignature instead of param and result vectors in TargetStreamer, and leaves some TODOs for further simplification. Differential Revision: https://reviews.llvm.org/D52580 llvm-svn: 343733
* [object] Improve the performance of getSymbols used by ArchiveWriterAlexander Shaposhnikov2018-09-111-11/+23
| | | | | | | | | | | | In this diff we adjust the code of getSymbols to avoid creating LLVMContext when it's not necessary. Without this patch when the function getSymbols was called on a MachO object with a __bitcode section it was parsing the embedded bitcode and then ignoring the result. Test plan: make check-all Differential revision: https://reviews.llvm.org/D51759 llvm-svn: 341998
* Handle zero-length debug directory entries.Nico Weber2018-09-051-4/+6
| | | | | | Part of https://reviews.llvm.org/D51652 (tests will be in the lld repo) llvm-svn: 341485
* [WebAssembly] clang-format (NFC)Heejin Ahn2018-09-051-38/+35
| | | | | | | | | | | | Summary: This patch runs clang-format on all wasm-only files. Reviewers: aardappel, dschuff, sunfish, tlively Subscribers: MatzeB, sbc100, jgravelle-google, llvm-commits Differential Revision: https://reviews.llvm.org/D51447 llvm-svn: 341439
* [MachO] Fix inconsistency between error messages when validating LC_DYSYMTABFrancis Visoiu Mistrih2018-09-041-2/+2
| | | | llvm-svn: 341379
* [MachO] Fix LC_DYSYMTAB validation for external symbolsFrancis Visoiu Mistrih2018-09-041-1/+1
| | | | | | | We were validating the same index (ilocalsym) twice, while iextdefsym was never validated. llvm-svn: 341378
* [Wasm] Add missing EOF checks for floatsJonas Devlieghere2018-08-311-0/+4
| | | | | | | Adds the same checks we already do for ints to floats. Fixes: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=8698 llvm-svn: 341216
* [COFF] Expose an easier helper function for getting names for relocation typesMartin Storsjo2018-08-271-16/+18
| | | | | | | | | The existing method is protected, and requires using DataRefImpl and SmallVector. Differential Revision: https://reviews.llvm.org/D50995 llvm-svn: 340725
* Use unique_ptr to hold MCInstrInfoVitaly Buka2018-08-241-1/+2
| | | | llvm-svn: 340654
* Use unique_ptr.Joel Galenson2018-08-241-1/+2
| | | | llvm-svn: 340642
* Find PLT entries for x86, x86_64, and AArch64.Joel Galenson2018-08-241-0/+65
| | | | | | | | | | This adds a new method to ELFObjectFileBase that returns the symbols and addresses of PLT entries. This design was suggested by pcc and eugenis in https://reviews.llvm.org/D49383. Differential Revision: https://reviews.llvm.org/D50203 llvm-svn: 340610
* [WebAssembly] Ensure relocation entries are ordered by offsetSam Clegg2018-08-221-0/+5
| | | | | | | | | | | | | wasm-lld expects relocation entries to be sorted by offset. In most cases llvm produces them in order, but the CODE section (which combines many MCSections) is an exception because we order the functions in Symbol order, not in section order. What is more, its not clear weather `recordRelocation` is guaranteed to be called in offset order so this sort of most likely needed in the general case too. Differential Revision: https://reviews.llvm.org/D51065 llvm-svn: 340423
OpenPOWER on IntegriCloud