aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Object
AgeCommit message (Collapse)AuthorFilesLines
2022-01-12Revert "[llvm-readobj][XCOFF] dump auxiliary symbols."Nico Weber1-5/+1
This reverts commit aad49c8eb9849be57c562f8e2b7fbbe816183343. Breaks tests on Windows, see comments on https://reviews.llvm.org/D113825
2022-01-12[llvm-readobj][XCOFF] dump auxiliary symbols.Esme-Yi1-1/+5
Summary: The patch adds support for dumping auxiliary symbols in llvm-readobj for XCOFF. Reviewed By: jhenderson, Higuoxing Differential Revision: https://reviews.llvm.org/D113825
2021-12-15[dwarf][NFC] Move expandBundle() to MachO.hEllis Hoag1-0/+46
The function `expandBundle()` is defined both in `llvm-dwarfdump.cpp` and `llvm-gsymutil.cpp` in the exact same way. Reduce code duplication by moving this function to the `MachOObjectFile` class. Reviewed By: jhenderson, clayborg Differential Revision: https://reviews.llvm.org/D115418
2021-12-13[VE] Support R_VE_RELATIVEKazushi (Jam) Marukawa1-0/+2
Change getELFRelativeRelocationType() to return R_VE_RELATIVE as a preparation of lld for VE. Reviewed By: simoll Differential Revision: https://reviews.llvm.org/D115592
2021-12-09[llvm] Add null-termination capability to SmallVectorMemoryBufferJan Svoboda1-1/+1
Most of `MemoryBuffer` interfaces expose a `RequiresNullTerminator` parameter that's being used to: * determine how to open a file (`mmap` vs `open`), * assert newly initialized buffer indeed has an implicit null terminator. This patch adds the paramater to the `SmallVectorMemoryBuffer` constructors, meaning: * null terminator can now be added to `SmallVector`s that didn't have one before, * `SmallVectors` that had a null terminator before keep it even after the move. In line with existing code, the new parameter is defaulted to `true`. This patch makes sure all calls to the `SmallVectorMemoryBuffer` constructor set it to `false` to preserve the current semantics. Reviewed By: dexonsmith Differential Revision: https://reviews.llvm.org/D115331
2021-12-09[llvm][lldb] Remove unused SmallVectorMemoryBuffer.h includesJan Svoboda1-1/+0
2021-11-29[llvm] Use range-based for loops (NFC)Kazu Hirata1-2/+2
2021-11-08Extend obj2yaml to optionally preserve raw __LINKEDIT/__DATA segments.Adrian Prantl1-0/+40
I am planning to upstream MachOObjectFile code to support Darwin chained fixups. In order to test the new parser features we need a way to produce correct (and incorrect) chained fixups. Right now the only tool that can produce them is the Darwin linker. To avoid having to check in binary files, this patch allows obj2yaml to print a hexdump of the raw LINKEDIT and DATA segment, which both allows to bootstrap the parser and enables us to easily create malformed inputs to test error handling in the parser. This patch adds two new options to obj2yaml: -raw-data-segment -raw-linkedit-segment Differential Revision: https://reviews.llvm.org/D113234
2021-11-05[NFC] Inclusive language: Remove instances of master in URLsQuinn Pham1-1/+1
[NFC] This patch fixes URLs containing "master". Old URLs were either broken or redirecting to the new URL. Reviewed By: #libc, ldionne, mehdi_amini Differential Revision: https://reviews.llvm.org/D113186
2021-11-04Make the BBAddrMap struct binary-format-agnostic.Rahman Lavaee1-3/+3
The only binary-format-related field in the BBAddrMap structure is the function address (`Addr`), which will use uint64_t in 64B format and uint32_t in 32B format. This patch changes it to use uint64_t in both formats. This allows non-templated use of the struct, at the expense of a marginal additional size overhead for the 32-bit format. The size of the BB address map section does not change. Differential Revision: https://reviews.llvm.org/D112679
2021-10-28[IRSymTab] Mark __stack_chk_guard usedYuanfang Chen1-3/+8
`__stack_chk_guard` is a global variable that has no uses before the LLVM code generation phase (how it is defined is platform-dependent). LTO needs to preserve this symbol for that reason. Currently, legacy LTO API preserves it by hardcoding the logic in Internalizer, but this symbol is not preserved by regular LTO API in thinlink phase. This patch marks `__stack_chk_guard` used during IR symbol table writing since this is how builtin functions are preserved by thinlink by using `RuntimeLibcalls.def`. Reviewed By: MaskRay, tejohnson Differential Revision: https://reviews.llvm.org/D112595
2021-10-26[AIX][XCOFF] parsing xcoff object file auxiliary headerzhijian1-2/+19
Summary: The patch supports parsing the xcoff object file auxiliary header with llvm-readobj with option "auxiliary-headers" the format of auxiliary header as https://www.ibm.com/support/knowledgecenter/en/ssw_aix_72/filesreference/XCOFF.html#XCOFF__fyovh386shar Reviewers: James Henderson, Jason Liu, Hubert Tong, Esme yi, Sean Fertile. Differential Revision: https://reviews.llvm.org/D82549
2021-10-22Support: Use Expected<T>::moveInto() in a few placesDuncan P. N. Exon Smith1-7/+8
These are some usage examples for `Expected<T>::moveInto()`. Differential Revision: https://reviews.llvm.org/D112280
2021-10-20[IR] Refactor GlobalIFunc to inherit from GlobalObject, Remove ↵Itay Bookstein1-2/+3
GlobalIndirectSymbol As discussed in: * https://reviews.llvm.org/D94166 * https://lists.llvm.org/pipermail/llvm-dev/2020-September/145031.html The GlobalIndirectSymbol class lost most of its meaning in https://reviews.llvm.org/D109792, which disambiguated getBaseObject (now getAliaseeObject) between GlobalIFunc and everything else. In addition, as long as GlobalIFunc is not a GlobalObject and getAliaseeObject returns GlobalObjects, a GlobalAlias whose aliasee is a GlobalIFunc cannot currently be modeled properly. Creating aliases for GlobalIFuncs does happen in the wild (e.g. glibc). In addition, calling getAliaseeObject on a GlobalIFunc will currently return nullptr, which is undesirable because it should return the object itself for non-aliases. This patch refactors the GlobalIFunc class to inherit directly from GlobalObject, and removes GlobalIndirectSymbol (while inlining the relevant parts into GlobalAlias and GlobalIFunc). This allows for calling getAliaseeObject() on a GlobalIFunc to return the GlobalIFunc itself, making getAliaseeObject() more consistent and enabling alias-to-ifunc to be properly modeled in the IR. I exercised some judgement in the API clients of GlobalIndirectSymbol: some were 'monomorphized' for GlobalAlias and GlobalIFunc, and some remained shared (with the type adapted to become GlobalValue). Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D108872
2021-10-16[Object] Simplify RELR decodingFangrui Song1-28/+14
2021-10-15[WebAssembly] Add import info to `dylink` section of shared librariesSam Clegg1-0/+8
See https://github.com/WebAssembly/tool-conventions/pull/175 Differential Revision: https://reviews.llvm.org/D111345
2021-10-12[WebAssembly] Make EH work with dynamic linkingHeejin Ahn1-2/+4
This makes Wasm EH work with dynamic linking. So far we were only able to handle destructors, which do not use any tags or LSDA info. 1. This uses `TargetExternalSymbol` for `GCC_except_tableN` symbols, which points to the address of per-function LSDA info. It is more convenient to use than `MCSymbol` because it can take additional target flags. 2. When lowering `wasm_lsda` intrinsic, if PIC is enabled, make the symbol relative to `__memory_base` and generate the `add` node. If PIC is disabled, continue to use the absolute address. 3. Make tag symbols (`__cpp_exception` and `__c_longjmp`) undefined in the backend, because it is hard to make it work with dynamic linking's loading order. Instead, we make all tag symbols undefined in the LLVM backend and import it from JS. 4. Add support for undefined tags to the linker. Companion patches: - https://github.com/WebAssembly/binaryen/pull/4223 - https://github.com/emscripten-core/emscripten/pull/15266 Reviewed By: sbc100 Differential Revision: https://reviews.llvm.org/D111388
2021-10-11[Object] Deduplicate the three createError functionsRaphael Isemann2-9/+0
The Object library currently has three identical functions that translate a Twine into a parser error. Until recently these functions have coexisted peacefully, but since D110320 Clang with enabled modules is now diagnosing that we have several definitions of `createError` in Object. This patch just merges them all and puts them into Object's `Error.h` where the error code for `parse_failed` is also defined which seems cleaner and unbreaks the bots. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D111541
2021-10-11[XCOFF] Improve error message context.Esme-Yi1-27/+67
Summary: This patch improves the error message context of the XCOFF interfaces by providing more details. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D110320
2021-10-08Move TargetRegistry.(h|cpp) from Support to MCReid Kleckner3-3/+3
This moves the registry higher in the LLVM library dependency stack. Every client of the target registry needs to link against MC anyway to actually use the target, so we might as well move this out of Support. This allows us to ensure that Support doesn't have includes from MC/*. Differential Revision: https://reviews.llvm.org/D111454
2021-10-06[IR][NFC] Rename getBaseObject to getAliaseeObjectItay Bookstein2-8/+8
To better reflect the meaning of the now-disambiguated {GlobalValue, GlobalAlias}::getBaseObject after breaking off GlobalIFunc::getResolverFunction (D109792), the function is renamed to getAliaseeObject.
2021-10-06[llvm] Replace report_fatal_error(std::string) uses with ↵Simon Pilgrim1-1/+1
report_fatal_error(Twine) As described on D111049, we're trying to remove the <string> dependency from error handling and replace uses of report_fatal_error(const std::string&) with the Twine() variant which can be forward declared.
2021-10-05[WebAssembly] Remove WasmTagTypeHeejin Ahn1-10/+21
This removes `WasmTagType`. `WasmTagType` contained an attribute and a signature index: ``` struct WasmTagType { uint8_t Attribute; uint32_t SigIndex; }; ``` Currently the attribute field is not used and reserved for future use, and always 0. And that this class contains `SigIndex` as its property is a little weird in the place, because the tag type's signature index is not an inherent property of a tag but rather a reference to another section that changes after linking. This makes tag handling in the linker also weird that tag-related methods are taking both `WasmTagType` and `WasmSignature` even though `WasmTagType` contains a signature index. This is because the signature index changes in linking so it doesn't have any info at this point. This instead moves `SigIndex` to `struct WasmTag` itself, as we did for `struct WasmFunction` in D111104. In this CL, in lib/MC and lib/Object, this now treats tag types in the same way as function types. Also in YAML, this removes `struct Tag`, because now it only contains the tag index. Also tags set `SigIndex` in `WasmImport` union, as functions do. I think this makes things simpler and makes tag handling more in line with function handling. These two shares similar properties in that both of them have signatures, but they are kind of nominal so having the same signature doesn't mean they are the same element. Also a drive-by fix: the reserved 'attirubute' part's encoding changed from uleb32 to uint8 a while ago. This was fixed in lib/MC and lib/Object but not in YAML. This doesn't change object files because the field's value is always 0 and its encoding is the same for the both encoding. This is effectively NFC; I didn't mark it as such just because it changed YAML test results. Reviewed By: sbc100, tlively Differential Revision: https://reviews.llvm.org/D111086
2021-10-05[llvm] Update report_fatal_error calls from raw_string_ostream to use ↵Simon Pilgrim1-6/+3
Twine(OS.str()) As described on D111049, we're trying to remove the <string> dependency from error handling and replace uses of report_fatal_error(const std::string&) with the Twine() variant which can be forward declared. We can use the raw_string_ostream::str() method to perform the implicit flush() and return a reference to the std::string container that we can then wrap inside Twine().
2021-10-05Silence an implicit conversion warning on the bit shift result in MSVC; NFCAaron Ballman1-1/+1
2021-10-04[Object][WebAssemlby] Report function types (signatures). NFCSam Clegg1-8/+9
This simplifies the code in a number of ways and avoids having to track functions and their types separately. Differential Revision: https://reviews.llvm.org/D111104
2021-10-01Revert "Extract LC_CODE_SIGNATURE related implementation out of LLD"Daniel Rodríguez Troitiño2-143/+0
This reverts commit cc8229603b67763e77a46894f88f7d3ddd04de34. As discussed in the review of https://reviews.llvm.org/D109972, this was not right approach, so we are reverting to start with a different approach. Differential Revision: https://reviews.llvm.org/D110974
2021-10-01[AIX]implement the --syms and using "symbol index and qualname" for --sym ↵zhijian1-4/+117
--symbol--description for llvm-objdump for xcoff Summary: for xcoff : implement the getSymbolFlag and getSymbolType() for option --syms. llvm-objdump --sym , if the symbol is label, print the containing section for the symbol too. when using llvm-objdump --sym --symbol--description, print the symbol index and qualname for symbol. for example: --symbol-description 00000000000000c0 l .text (csect: (idx: 2) .foov[PR]) (idx: 3) .foov and without --symbol-description 00000000000000c0 l .text (csect: .foov) .foov Reviewers: James Henderson,Esme Yi Differential Revision: https://reviews.llvm.org/D109452
2021-09-29[llvm-objdump/llvm-readobj/obj2yaml/yaml2obj] Support STO_RISCV_VARIANT_CC ↵Fangrui Song1-0/+10
and DT_RISCV_VARIANT_CC STO_RISCV_VARIANT_CC marks that a symbol uses a non-standard calling convention or the vector calling convention. See https://github.com/riscv/riscv-elf-psabi-doc/pull/190 Differential Revision: https://reviews.llvm.org/D107949
2021-09-29[WebAssemlby][Object] Fix dead code in WasmObjectFile.cppSam Clegg1-2/+1
I introduced this by mistake in https://reviews.llvm.org/D109595. Differential Revision: https://reviews.llvm.org/D110717
2021-09-28[llvm-readobj] Support dumping of MSP430 ELF attributesJozef Lawrynowicz1-0/+3
The MSP430 ABI supports build attributes for specifying the ISA, code model, data model and enum size in ELF object files. Differential Revision: https://reviews.llvm.org/D107969
2021-09-23Resolve {GlobalValue,GloalIndirectSymol}::getBaseObject confusionFangrui Song2-4/+8
While both GlobalAlias and GlobalIFunc are GlobalIndirectSymbol, their `getIndirectSymbol()` usage is quite different (GlobalIFunc's resolver is an entity different from GlobalIFunc itself). As discussed on https://lists.llvm.org/pipermail/llvm-dev/2020-September/144904.html ("[IR] Modelling of GlobalIFunc"), the name `getBaseObject` is confusing when used with GlobalIFunc. To resolve the confusion: * Move GloalIndirectSymol::getBaseObject to GlobalAlias:: (GlobalIFunc should use `getResolver` instead) * Change GlobalValue::getBaseObject not to inspect GlobalIFunc. Note: the function has 7 references. * Add GlobalIFunc::getResolverFunction to peel off potential ConstantExpr indirection (`strlen` in `test/LTO/Resolution/X86/ifunc.ll`) Note: GlobalIFunc::getResolver (like GlobalAlias::getAliasee which does not peel off ConstantExpr indirection) is kept to be used by ValueEnumerator. Reviewed By: ibookstein Differential Revision: https://reviews.llvm.org/D109792
2021-09-20MachOObjectFile - checkOverlappingElement - use const-ref to avoid ↵Simon Pilgrim1-3/+3
unnecessary copies. NFCI. Reported by MSVC static analyzer.
2021-09-16Extract LC_CODE_SIGNATURE related implementation out of LLDNuri Amari2-0/+143
Move the functionality in lld that handles writing of the LC_CODE_SIGNATURE load command and associated data section to a central reusable location. This change is in preparation for another change that modifies llvm-objcopy to reproduce the LC_CODE_SIGNATURE load command and corresponding data section to maintain the validity of signed macho object files passed through llvm-objcopy. Reviewed By: #lld-macho, int3, oontvoo Differential Revision: https://reviews.llvm.org/D109803
2021-09-14[WebAssembly] Allow import and export of TLS symbols between DSOsSam Clegg1-0/+7
We previously had a limitation that TLS variables could not be exported (and therefore could also not be imported). This change removed that limitation. Differential Revision: https://reviews.llvm.org/D108877
2021-09-14[yaml2obj][XCOFF] add the SectionIndex field for symbol.Esme-Yi1-1/+3
Summary: Add the SectionIndex field for symbol. 1: a symbol can reference a section by SectionName or SectionIndex. 2: a symbol can reference a section by both SectionName and SectionIndex. 3: if both Section and SectionIndex are specified, but the two values refer to different sections, an error will be reported. 4: an invalid SectionIndex is allowed. 5: if a symbol references a non-existent section by SectionName, an error will be reported. Reviewed By: jhenderson, Higuoxing Differential Revision: https://reviews.llvm.org/D109566
2021-09-13[XCOFF] Fix the program abortion issue in XCOFFObjectFile::getSectionContents.Esme-Yi1-2/+3
Summary: Use std::move(E) to avoid `Program aborted due to an unhandled Error` Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D109567
2021-09-12[WebAssembly] Convert to new "dylink.0" section formatSam Clegg1-1/+52
This format is based on sub-sections (like the "linking" and "name" sections) and is therefore easier to extend going forward. spec change: https://github.com/WebAssembly/tool-conventions/pull/170 binaryen change: https://github.com/WebAssembly/binaryen/pull/4141 wabt change: https://github.com/WebAssembly/wabt/pull/1707 emscripten change: https://github.com/emscripten-core/emscripten/pull/15019 Differential Revision: https://reviews.llvm.org/D109595
2021-09-10[WebAssembly][libObject] Avoid re-use of Section object during parsingSam Clegg1-1/+1
The re-use of this struct across iterations of the loop was causing fields (specifically Name) to be incorrectly shared between multiple sections. Differential Revision: https://reviews.llvm.org/D108984
2021-08-26[llvm-readobj][XCOFF] Add support for `--needed-libs` option.Esme-Yi1-0/+73
Summary: This patch is trying to add support for llvm-readobj --needed-libs option under XCOFF. For XCOFF, the needed libraries can be found from the Import File ID Name Table of the Loader Section. Currently, I am using binary inputs in the test since yaml2obj does not yet support for writing the Loader Section and the import file table. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D106643
2021-08-19[AIX][XCOFF] 64-bit relocation reading supportMaryam Benimmar1-60/+137
Support XCOFFDumper relocation reading support This patch is part of D103696 partition Reviewed By: daltenty, Helflym Differential Revision: https://reviews.llvm.org/D104646
2021-08-17[Object] Move llvm-nm's symbol version utility to ↵Fangrui Song1-0/+69
ELFObjectFile::readDynsymVersions The utility can be reused by llvm-objdump -T. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D108096
2021-08-12[Object] Add missing PPC_DYNAMIC_TAG macrosFangrui Song1-0/+10
2021-08-05[llvm-ar] Fix for handling thin archive with SYM64 and a test case for itRamesh Peri1-1/+1
WHen thin archives are created which have symbol table of type SYM64 then all the tools will not work since they cannot read the files properly. One can reproduce the problem as follows: 1. Take a hello world program and create an archive out of it. The SYM64_THRESHOLD=0 will force the generation of SYM64 symbol table. clang -c hello.cpp SYM64_THRESHOLD=0 llvm-ar crsT mylib.a hello.o 2. Now try to use any of the tools on this mylib.a and it will fail. llvm-nm -M mylib.a THis fix will eliminate these failures. A regression test is created in llvm/test/Object/archive-symtab.test Reviewed By: MaskRay, Ramesh Differential Revision: https://reviews.llvm.org/D107322
2021-08-03[llvm-readobj][XCOFF] Fix the error dumping for the firstEsme-Yi1-1/+4
item of StringTable. Summary: For the string table in XCOFF, the first 4 bytes contains the length of the string table, so we should print the string entries from fifth bytes. This patch also adds tests for llvm-readobj dumping the string table. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D105522
2021-07-28[ARM] Fix llvm-objdump disassembly of armv7m object files.Eli Friedman1-2/+9
Apparently, the features were getting mixed up, so we'd try to disassemble in ARM mode. Fix sub-architecture detection to compute the correct triple if we're detecting it automatically, so the user doesn't need to pass --triple=thumb etc. It's possible we should be somehow tying the "+thumb-mode" target feature more directly to Tag_CPU_arch_profile? But this seems to work reasonably well, anyway. While I'm here, fix up the other llvm-objdump tests that were explicitly specifying an ARM triple; that shouldn't be necessary. Differential Revision: https://reviews.llvm.org/D106912
2021-07-25[Object] make SourceMgr available to MCContext during inline asm symbolsYuanfang Chen1-4/+5
collection Fixes PR51210.
2021-07-20[LTO] Add SelectionKind to IRSymtab and use it in ld.lld/LLVMgoldFangrui Song1-0/+1
In PGO, a C++ external linkage function `foo` has a private counter `__profc_foo` and a private `__profd_foo` in a `comdat nodeduplicate`. A `__attribute__((weak))` function `foo` has a weak hidden counter `__profc_foo` and a private `__profd_foo` in a `comdat nodeduplicate`. In `ld.lld a.o b.o`, say a.o defines an external linkage `foo` and b.o defines a weak `foo`. Currently we treat `comdat nodeduplicate` as `comdat any`, ld.lld will incorrectly consider `b.o:__profc_foo` non-prevailing. In the worst case when `b.o:__profd_foo` is retained and `b.o:__profc_foo` isn't, there will be dangling reference causing an `undefined hidden symbol` error. Add SelectionKind to `Comdat` in IRSymtab and let linkers ignore nodeduplicate comdat. Differential Revision: https://reviews.llvm.org/D106228
2021-07-20[SystemZ][z/OS] Add GOFF support to file magic identificationAnirudh Prasad3-0/+4
- This patch adds in the GOFF format to the file magic identification logic in LLVM - Currently, for the object file support, GOFF is marked as having as an error - However, this is only temporary until https://reviews.llvm.org/D98437 is merged in Reviewed By: abhina.sreeskantharajan Differential Revision: https://reviews.llvm.org/D105993
2021-07-19[WebAssembly] Support R_WASM_MEMORY_ADDR_TLS_SLEB64 for wasm64Wouter van Oortmerssen1-0/+1
Also fixed TLS tests swapping addr & value in store op Differential Revision: https://reviews.llvm.org/D106096