aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Object
AgeCommit message (Collapse)AuthorFilesLines
2024-06-21[llvm-objdump] enable file-headers option of llvm-objdump for XCOFF object ↵zhijian lin1-3/+5
files (#96104) the patch enable file-headers option of llvm-objdump for XCOFF object files
2024-06-06[AMDGPU] Add a new target gfx1152 (#94534)Shilei Tian1-0/+2
2024-05-31AMDGPU: Add gfx12-generic target (#93875)Konstantin Zhuravlyov1-0/+2
2024-05-30[MachO] Stop parsing past end of rebase/bind table (#93897)Zixu Wang1-14/+18
`MachORebaseEntry::moveNext()` and `MachOBindEntry::moveNext()` assume that the rebase/bind table ends with `{REBASE|BIND}_OPCODE_DONE` or an actual rebase/bind. However a valid rebase/bind table might also end with other effectively no-op opcodes, which caused the parser to move past the end and go into the next table, resulting in corrupted entries or infinite loops.
2024-05-28[WebAssembly] Add exnref type (#93586)Heejin Ahn1-2/+6
This adds (back) the exnref type restored in the new EH proposal adopted in Oct 2023 CG meeting: https://github.com/WebAssembly/exception-handling/blob/main/proposals/exception-handling/Exceptions.md:x
2024-05-16[llvm] Drop explicit conversions of string literals to StringRef (NFC)Kazu Hirata1-2/+2
We routinely rely on implicit conversions of string literals to StringRef so that we can use operator==(StringRef, StringRef).
2024-05-15[nfc] Allow forwarding `Error` returns from `Expected` callers (#92208)Mircea Trofin2-5/+5
On a few compilers (clang 11/12 for example [1]), the following does not result in a copy elision, and since `Error`'s copy dtor is elided, results in a compile error: ``` Expect<Something> foobar() { ... if (Error E = aCallReturningError()) return E; ... } ``` Moving `E` would, conversely, result in the pessimizing-move warning on more recent clangs ("moving a local object in a return statement prevents copy elision") We just need to make the `Expected` ctor taking an `Error` take it as a r-value reference. [1] https://lab.llvm.org/buildbot/#/builders/54/builds/10505
2024-05-08[llvm][MachO] Fix integer truncation in rebase/bind parsing (#89337)Zixu Wang1-10/+10
`Count` and `Skip` should use `uint64_t` as they are encoded/decoded using 64-bit ULEB128. In `*_OPCODE_DO_*_ULEB_TIMES_SKIPPING_ULEB`, `Skip` could be encoded as a two's complement for moving `SegmentOffset` backwards. Having a 32-bit `Skip` truncates the encoded value and leads to a malformed `AdvanceAmount` and invalid `SegmentOffset` that extends past valid sections.
2024-05-08[llvm] Use StringRef::operator== instead of StringRef::equals (NFC) (#91441)Kazu Hirata3-5/+5
I'm planning to remove StringRef::equals in favor of StringRef::operator==. - StringRef::operator==/!= outnumber StringRef::equals by a factor of 70 under llvm/ in terms of their usage. - The elimination of StringRef::equals brings StringRef closer to std::string_view, which has operator== but not equals. - S == "foo" is more readable than S.equals("foo"), especially for !Long.Expression.equals("str") vs Long.Expression != "str".
2024-04-23IRSymTab: Record _GLOBAL_OFFSET_TABLE_ for ELF x86Fangrui Song1-0/+14
In ELF, relocatable files generated for x86-32 and some code models of x86-64 (medium, large) may reference the special symbol `_GLOBAL_OFFSET_TABLE_` that is not used in the IR. In an LTO link, if there is no regular relocatable file referencing the special symbol, the linker may not define the symbol and lead to a spurious "undefined symbol" error. Fix #61101: record that `_GLOBAL_OFFSET_TABLE_` is used in the IR symbol table. Note: The `PreservedSymbols` mechanism (https://reviews.llvm.org/D112595) that just sets `FB_used` is not applicable. The `getRuntimeLibcallSymbols` for extracting lazy runtime library symbols is for symbols that are "always" potentially used, but linkers don't have the code model information to make a precise decision. Pull Request: https://github.com/llvm/llvm-project/pull/89463
2024-04-23[RISCV] Split code that tablegen needs out of RISCVISAInfo. (#89684)Craig Topper1-1/+1
This introduces a new file, RISCVISAUtils.cpp and moves the rest of RISCVISAInfo to the TargetParser library. This will allow us to generate part of RISCVISAInfo.cpp using tablegen.
2024-04-18[COFF] Rename the COFFShortExport::AliasTarget field. NFC. (#89039)Martin Storsjö2-6/+6
It turns out that the previous name is vaguely misleading. When operating on a def file like "symbolname == dllname", that is supposed to make an import library entry, that when the symbol "symbolname" links against this, it imports the DLL symbol "dllname" from the referenced DLL. This doesn't need to involve any alias, and it doesn't need to imply that "dllname" is available on its own as a separate symbol in the import library at all. GNU dlltool implements import libraries in the form of "long import library", where each member is a regular object file with section chunks that compose the relevant .idata section pieces. There, this kind of import renaming does not involve any form of aliases, but the right .idata section just gets a different string than the symbol name.
2024-04-09Fix MSVC "result of 32-bit shift implicitly converted to 64 bits" warning. NFC.Simon Pilgrim1-1/+1
2024-04-08 [SystemZ][z/OS] TXT records in the GOFF reader (#87648)Yusra Syeda1-0/+167
This PR adds handling for TXT records in the GOFF reader. --------- Co-authored-by: Yusra Syeda <yusra.syeda@ibm.com>
2024-04-03[Object][COFF][NFC] Introduce getMachineArchType helper. (#87370)Jacek Caban2-37/+18
It's a common pattern that we have a machine type, but we don't care which ARM64* platform we're dealing with. We already have isAnyArm64 for that, but it does not fit cases where we use a switch statement. With this helper, it's easy to simplify such cases by using Triple::ArchType instead of machine type.
2024-04-01[GOFF] Wrap debug output with LLVM_DEBUG (#87252)Kai Nacke1-6/+3
The content of a GOFF record is always dumped if NDEBUG is not defined, which produces rather confusing output. This changes wrap the dumping code in LLVM_DEBUG, so the dump is only done when debug output of this module is requested.
2024-03-31[Object][COFF][NFC] Don't use inline function for ↵Jacek Caban1-0/+21
COFFImportFile::printSymbolName. (#87195) Fixes BUILD_SHARED_LIBS builds after #87191 made helpers non-inline.
2024-03-27Finish revert "[SystemZ][z/OS] TXT records in the GOFF reader (#74526)"Aiden Grossman1-148/+0
This finishes the revert started in aeb8628c218f8224e08dddcdd3199a445d8607a8 which didn't completely back out the original patch.
2024-03-27Revert "[SystemZ][z/OS] TXT records in the GOFF reader (#74526)"Neumann Hon1-19/+0
This reverts commit 009f88fc0e3a036be97ef7b222b90af342bae0b7. Reverting PR due to test failure.
2024-03-27Fix "result of 32-bit shift implicitly converted to 64 bits" MSVC warning. NFCI.Simon Pilgrim1-1/+1
2024-03-27[SystemZ][z/OS] TXT records in the GOFF reader (#74526)Yusra Syeda1-0/+167
This PR adds handling for TXT records in the GOFF reader. --------- Authored-by: Yusra Syeda <yusra.syeda@ibm.com>
2024-03-27[llvm-dlltool][llvm-lib][COFF] Don't override NONAME exports with demangled ↵Jacek Caban1-2/+2
ARM64EC symbols. (#86722)
2024-03-25Add support for PSV EntryFunctionName (#86296)Cooper Partin1-1/+14
This change introduces a version 3 of the PSV data that includes support for the name of the entry function as an offset into StringTable data to a null-terminated utf-8 string. Additional tests were added to ensure that the new value was properly serialized/deserialized from object data. Fixes #80175 --------- Co-authored-by: Cooper Partin <coopp@ntdev.microsoft.com>
2024-03-22[Object][ELF] Ensure offset to locate dyn section does not go past sizeAntonio Frighetto1-1/+5
Validate `p_offset` in `dynamicEntries` before computing the entry offset. Fixes: https://github.com/llvm/llvm-project/issues/85568.
2024-03-22[Object] Ensure header size not to underflow in `OffloadBinary::create`Antonio Frighetto1-1/+4
Prevent potential integer underflows when header size is not valid. Fixes: https://github.com/llvm/llvm-project/issues/86280.
2024-03-21Revert "Add support for PSV EntryFunctionName (#84409)" (#86211)Cooper Partin1-14/+1
This reverts commit cde54df39cab3a1d60a3e1862ab341609bee3cc3. Co-authored-by: Cooper Partin <coopp@ntdev.microsoft.com>
2024-03-21Add support for PSV EntryFunctionName (#84409)Cooper Partin1-1/+14
This change introduces a version 3 of the PSV data that includes support for the name of the entry function as an offset into StringTable data to a null-terminated utf-8 string. Additional tests were added to ensure that the new value was properly serialized/deserialized from object data. Fixes #80175 --------- Co-authored-by: Cooper Partin <coopp@ntdev.microsoft.com>
2024-03-21[llvm-lib] Use ARM64EC machine type for import libraries when ↵Jacek Caban1-2/+5
-machine:arm64x is used. (#85972) This is compatible with MSVC, `-machine:arm64x` is essentially an alias to `-machine:arm64ec`. To make a type library that exposes both native and EC symbols, an additional `-defArm64Native` argument is needed in both cases.
2024-03-20[llvm-ar][Object][COFF] Add support for EC symbols to llvm-ar. (#85230)Jacek Caban1-11/+54
Make writeArchive IsEC argument optional and use EC symbol map when indicated by input object files.
2024-03-19[Hexagon] ELF attributes for Hexagon (#85359)quic-areg2-1/+82
Defines a subset of attributes and emits them to a section called .hexagon.attributes. The current attributes recorded are the attributes needed by llvm-objdump to automatically determine target features and eliminate the need to manually pass features.
2024-03-15[Object][Archive][NFC] Create all symbolic files objects before calculating ↵Jacek Caban1-35/+23
offsets. (#85229) This is refactoring preparing to move UseECMap computation to the archive writer. We currently require writeArchive caller to pass that. This is not practical for llvm-ar, which currently interprets at most one passed object. For a reliable UseECMap, we need to interpret all symbolic objects: we may have, for example, a list of x86_64 files followed by aarch64 file, which indicates that we should use EC map for x86_64 objects. This commit interprets symbolic files in a separated pass, which will be a convenient place to implement UseECMap computation in the follow up. It also makes accessing the next member for AIX big archive offset computation a bit easier.
2024-03-13[llvm-ar] Use COFF archive format for COFF targets. (#82898)Jacek Caban2-17/+26
Detect COFF files by default and allow specifying it with --format argument. This is important for ARM64EC, which uses a separated symbol map for EC symbols. Since K_COFF is mostly compatible with K_GNU, this shouldn't really make a difference for other targets. This originally landed as #82642, but was reverted due to test failures in tests using no symbol table. Since COFF symbol can't express it, fallback to GNU format in that case.
2024-03-12[Arm64EC] Copy import descriptors to the EC Map (#84834)Daniel Paoliello2-6/+15
As noted in <https://github.com/llvm/llvm-project/pull/78537>, MSVC places import descriptors in both the EC and regular map - that PR moved the descriptors to ONLY the regular map, however this causes linking errors when linking as Arm64EC: ``` bcryptprimitives.lib(bcryptprimitives.dll) : error LNK2001: unresolved external symbol __IMPORT_DESCRIPTOR_bcryptprimitives (EC Symbol) ``` This change copies import descriptors from the regular map to the EC map, which fixes this linking error.
2024-03-08[llvm][Support] Add and use errnoAsErrorCode (#84423)Michael Spencer1-1/+1
LLVM is inconsistent about how it converts `errno` to `std::error_code`. This can cause problems because values outside of `std::errc` compare differently if one is system and one is generic on POSIX systems. This is even more of a problem on Windows where use of the system category is just wrong, as that is for Windows errors, which have a completely different mapping than POSIX/generic errors. This patch fixes one instance of this mistake in `JSONTransport.cpp`. This patch adds `errnoAsErrorCode()` which makes it so people do not need to think about this issue in the future. It also cleans up a lot of usage of `errno` in LLVM and Clang.
2024-02-27[DirectX][NFC] Rename ShaderFlag to SHADER_FEATURE_FLAG. (#82700)Xiang Li1-4/+4
This is preparation for add ShaderFlag in DXIL. For #57925
2024-02-27[llvm-ar][Archive] Use getDefaultTargetTriple instead of host triple for the ↵Jacek Caban2-3/+3
fallback archive format. (#82888)
2024-02-24Revert "[llvm-ar] Use COFF archive format for COFF targets." (#82889)Jacek Caban2-22/+14
Reverts llvm/llvm-project#82642 for lld/test/ELF/invalid/Output/data-encoding.test.tmp.a failures on Windows.
2024-02-24[llvm-ar] Use COFF archive format for COFF targets. (#82642)Jacek Caban2-14/+22
Detect COFF files by default and allow specifying it with --format argument. This is important for ARM64EC, which uses a separated symbol map for EC symbols. Since K_COFF is mostly compatible with K_GNU, this shouldn't really make a difference for other targets.
2024-02-22[Symbolizer][WebAssembly] Use wasm-specific getSymbolSize (#82083)Derek Schuff1-0/+7
getSymbolSize was recently added to WasmObjectFile and has correct sizes for most symbol types. This makes llvm-symbolizer correctly symbolize addresses in the middle of the symbol. When reworking the test I also noticed that the DWARF info seems to be wrong for the first instruction in each function. I noted that in the test comments but didn't attempt to fix here.
2024-02-20[XCOFF] Support the subtype flag in DWARF section headers (#81667)stephenpeckham1-0/+6
The section headers for XCOFF files have a subtype flag for Dwarf sections. This PR updates obj2yaml, yaml2obj, and llvm-readobj so that they recognize the subtype.
2024-02-15[Object][Wasm] Use offset instead of index for Global address and store size ↵Derek Schuff1-12/+20
(#81781) Currently the address reported by binutils for a global is its index; but its offset (in the file or section) is more useful for binary size attribution. This PR treats globals similarly to functions, and tracks their offset and size. It also centralizes the logic differentiating linked from object and dylib files (where section addresses are 0).
2024-02-15[llvm-dlltool] Add ARM64EC target support. (#81624)Jacek Caban1-1/+1
Add new target and a new -n option allowing to specify native module definition file, similar to how -defArm64Native works in llvm-lib. This also changes archive format to use K_COFF like non-mingw targets. It's required on ARM64EC, but it should be fine for other targets too.
2024-02-14[AMDGPU] Replace '.' with '-' in generic target names (#81718)Pierre van Houtryve1-2/+2
The dot is too confusing for tools. Output temporaries would have '10.3-generic' so tools could parse it as an extension, device libs & the associated clang driver logic are also confused by the dot. After discussions, we decided it's better to just remove the '.' from the target name than fix each issue one by one.
2024-02-13[Object][COFF][NFC] Make writeImportLibrary NativeExports argument optional. ↵Jacek Caban1-2/+2
(#81600) It's not interesting for majority of downstream users.
2024-02-13[llvm-lib] Add support for -defArm64Native argument. (#81426)Jacek Caban1-52/+60
This can be used to create import libraries that contain both ARM64EC and native exports. The implementation follows observed MSVC lib.exe behaviour. It's ignored on targets other than ARM64EC.
2024-02-12[LinkerWrapper][NFC] Rename 'all' to 'generic' for architecture agnostic IRJoseph Huber1-1/+1
Summary: A previous patch introduced `all` as a special architecture. I have decided I do not like this name and have changed it to `generic`.
2024-02-12[AMDGPU] Introduce GFX9/10.1/10.3/11 Generic Targets (#76955)Pierre van Houtryve1-0/+10
These generic targets include multiple GPUs and will, in the future, provide a way to build once and run on multiple GPU, at the cost of less optimization opportunities. Note that this is just doing the compiler side of things, device libs an runtimes/loader/etc. don't know about these targets yet, so none of them actually work in practice right now. This is just the initial commit to make LLVM aware of them. This contains the documentation changes for both this change and #76954 as well.
2024-02-10[llvm-lib][Object] Add support for EC importlib symbols. (#81059)Jacek Caban1-0/+15
ARM64EC import libraries expose two additional symbols: mangled thunk symbol (like `#func`) and auxiliary import symbol (like`__imp_aux_func`). The main functional change with this patch is that those symbols are properly added to static library ECSYMBOLS.
2024-02-10[llvm-lib][llvm-dlltool][Object] Add support for EXPORTAS name types. (#78772)Jacek Caban2-22/+57
EXPORTAS is a new name type in import libraries. It's used by default on ARM64EC, but it's allowed on other platforms as well.
2024-02-09[llvm-nm][WebAssembly] Print function symbol sizes (#81315)Derek Schuff1-0/+14
nm already prints sizes for data symbols. Do that for function symbols too, and update objdump to also print size information. Implements item 3 from https://github.com/llvm/llvm-project/issues/76107