aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/ObjectYAML
AgeCommit message (Collapse)AuthorFilesLines
2021-07-30[yaml2obj] Enable support for parsing 64-bit XCOFF.Esme-Yi1-47/+82
Summary: Add support for yaml2obj to parse 64-bit XCOFF. Reviewed By: shchenz Differential Revision: https://reviews.llvm.org/D100375
2021-07-28[llvm-objcopy][MachO] Ignore all LC_SUB_* commands.Daniel Rodríguez Troitiño2-0/+48
The LC_SUB_FRAMEWORK, LC_SUB_UMBRELLA, LC_SUB_CLIENT, and LC_SUB_LIBRARY are used to indicate related libraries, binaries or framework names. Their only payload is the string with the name of the object. Adding those commands to the list of ignored/skipped load commands will avoid an error that stop the process of copying/stripping and will copy their contents verbatim. Additionally, in order to have a test for this case, `yaml2obj` now allows those four commands to contain a `Content`. Differential Revision: https://reviews.llvm.org/D106412
2021-07-26[yaml2obj][MachO] Rename PayloadString to ContentFangrui Song2-6/+6
The new name is conciser and matches yaml2obj ELF & DWARF. Reviewed By: #lld-macho, thakis Differential Revision: https://reviews.llvm.org/D106759
2021-07-26[yaml2obj] Do not write the string table if there is no string entry.Esme-Yi1-5/+4
Summary: yaml2obj shouldn't create the string table that isn't needed - doing so wastes time and disk space. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D106420
2021-07-07[COFF] [CodeView] Add a few new enum valuesMartin Storsjö1-0/+1
These are undocumented, but are visible in the SDK headers since some versions ago. Differential Revision: https://reviews.llvm.org/D105513
2021-06-24[AMDGPU] Add gfx1035 targetAakanksha Patil1-0/+1
Differential Revision: https://reviews.llvm.org/D104804
2021-06-24[LLD][LLVM] CG Graph profile using relocationsAlexander Yermolovich2-11/+5
Currently when .llvm.call-graph-profile is created by llvm it explicitly encodes the symbol indices. This section is basically a black box for post processing tools. For example, if we run strip -s on the object files the symbol table changes, but indices in that section do not. In non-visible behavior indices point to wrong symbols. The visible behavior indices point outside of Symbol table: "invalid symbol index". This patch changes the format by using R_*_NONE relocations to indicate the from/to symbols. The Frequency (Weight) will still be in the .llvm.call-graph-profile, but symbol information will be in relocation section. In LLD information from both sections is used to reconstruct call graph profile. Relocations themselves will never be applied. With this approach post processing tools that handle relocations correctly work for this section also. Tools can add/remove symbols and as long as they handle relocation sections with this approach information stays correct. Doing a quick experiment with clang-13. The size went up from 107KB to 322KB, aggregate of all the input sections. Size of clang-13 binary is ~118MB. For users of -fprofile-use/-fprofile-sample-use the size of object files will go up slightly, it will not impact final binary size. Reviewed By: jhenderson, MaskRay Differential Revision: https://reviews.llvm.org/D104080
2021-06-21[yaml2obj] Add support for writing the long symbol name.Esme-Yi1-4/+28
Summary: This patch, as a follow-up of D95505, adds support for writing the long symbol name by implementing the StringTable. Only XCOFF32 is suppoted now. Reviewed By: jhenderson, shchenz Differential Revision: https://reviews.llvm.org/D103455
2021-06-17[WebAssembly] Rename event to tagHeejin Ahn2-33/+33
We recently decided to change 'event' to 'tag', and 'event section' to 'tag section', out of the rationale that the section contains a generalized tag that references a type, which may be used for something other than exceptions, and the name 'event' can be confusing in the web context. See - https://github.com/WebAssembly/exception-handling/issues/159#issuecomment-857910130 - https://github.com/WebAssembly/exception-handling/pull/161 Reviewed By: tlively Differential Revision: https://reviews.llvm.org/D104423
2021-06-16[obj2yaml] Address D104035 review commentsJames Henderson1-1/+1
Accidentally missed from commit 5c1639fe064b. Differential Revision: https://reviews.llvm.org/D104035
2021-06-16[yaml2obj][obj2yaml] Support custom ELF section header string table nameJames Henderson2-31/+77
This patch adds support for a new field in the FileHeader, which states the name to use for the section header string table. This also allows combining the string table with another string table in the object, e.g. the symbol name string table. The field is optional. By default, .shstrtab will continue to be used. This partially fixes https://bugs.llvm.org/show_bug.cgi?id=50506. Reviewed by: Higuoxing Differential Revision: https://reviews.llvm.org/D104035
2021-06-16[yaml2obj] Fix bug when referencing items in SectionHeaderTableJames Henderson1-1/+1
There was an off-by-one error caused by an index (which included an index for the null section header) being used to check against the size of a list of sections (which didn't include the null section header). This is a partial fix for https://bugs.llvm.org/show_bug.cgi?id=50506. Reviewed by: MaskRay Differential Revision: https://reviews.llvm.org/D104098
2021-06-10[NFC][XCOFF] Replace structs FileHeader32/SectionHeader32 with constants.Esme-Yi1-2/+2
Summary: Some structs like FileHeader32/SectionHeader32 defined in llvm/include/llvm/BinaryFormat/XCOFF.h seem unnecessary, because we only need their size. So this patch removes them and defines size constants directly. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D103901
2021-06-08Reland "[AMDGPU] Add gfx1013 target"Brendon Cahoon1-0/+1
This reverts commit 211e584fa2a4c032e4d573e7cdbffd622aad0a8f. Fixed a use-after-free error that caused the sanitizers to fail.
2021-06-08Revert "[AMDGPU] Add gfx1013 target"Brendon Cahoon1-1/+0
This reverts commit ea10a86984ea73fcec3b12d22404a15f2f59b219. A sanitizer buildbot reports an error.
2021-06-08[AMDGPU] Add gfx1013 targetBrendon Cahoon1-0/+1
Differential Revision: https://reviews.llvm.org/D103663
2021-06-08[yaml2obj] Fix buildbot-issue-4886Esme-Yi1-1/+2
XCOFFEmitter.cpp:67:16: runtime error: null pointer passed as argument 2, which is declared to never be null
2021-06-07Fixed the build failure of yaml2obj in XCOFFEmitter.cpp:Esme-Yi1-1/+1
error: ambiguous overload for 'operator==' (operand types are 'llvm::yaml::Hex16' and 'llvm::XCOFF::MagicNumber') Is64Bit = Obj.Header.Magic == XCOFF::XCOFF64;
2021-06-07[yaml2obj] Initial the support of yaml2obj for 32-bit XCOFF.Esme-Yi5-13/+387
Summary: The patch implements the mapping of the Yaml information to XCOFF object file to enable the yaml2obj tool for XCOFF. Currently only 32-bit is supported. Reviewed By: jhenderson, shchenz Differential Revision: https://reviews.llvm.org/D95505
2021-06-01[ADT] Move DenseMapInfo for APInt into APInt.h (PR50527)Nikita Popov1-0/+1
As suggested in https://bugs.llvm.org/show_bug.cgi?id=50527, this moves the DenseMapInfo for APInt and APSInt into the respective headers, removing the need to include APInt.h and APSInt.h from DenseMapInfo.h. We could probably do the same from StringRef and ArrayRef as well. Differential Revision: https://reviews.llvm.org/D103422
2021-05-13[AMDGPU] Add gfx1034 targetAakanksha Patil1-0/+1
Differential Revision: https://reviews.llvm.org/D102306
2021-05-12[WebAssembly] Add TLS data segment flag: WASM_SEG_FLAG_TLSSam Clegg1-0/+1
Previously the linker was relying solely on the name of the segment to imply TLS. Differential Revision: https://reviews.llvm.org/D102202
2021-05-10Reland: "[lld][WebAssembly] Initial support merging string data"Sam Clegg1-1/+5
This change was originally landed in: 5000a1b4b9edeb9e994f2a5b36da8d48599bea49 It was reverted in: 061e071d8c9b98526f35cad55a918a4f1615afd4 This change adds support for a new WASM_SEG_FLAG_STRINGS flag in the object format which works in a similar fashion to SHF_STRINGS in the ELF world. Unlike the ELF linker this support is currently limited: - No support for SHF_MERGE (non-string merging) - Always do full tail merging ("lo" can be merged with "hello") - Only support single byte strings (p2align 0) Like the ELF linker merging is only performed at `-O1` and above. This fixes part of https://bugs.llvm.org/show_bug.cgi?id=48828, although crucially it doesn't not currently support debug sections because they are not represented by data segments (they are custom sections) Differential Revision: https://reviews.llvm.org/D97657
2021-05-10Revert "[lld][WebAssembly] Initial support merging string data"Nico Weber1-5/+1
This reverts commit 5000a1b4b9edeb9e994f2a5b36da8d48599bea49. Breaks tests, see https://reviews.llvm.org/D97657#2749151 Easily repros locally with `ninja check-llvm-mc-webassembly`.
2021-05-10[lld][WebAssembly] Initial support merging string dataSam Clegg1-1/+5
This change adds support for a new WASM_SEG_FLAG_STRINGS flag in the object format which works in a similar fashion to SHF_STRINGS in the ELF world. Unlike the ELF linker this support is currently limited: - No support for SHF_MERGE (non-string merging) - Always do full tail merging ("lo" can be merged with "hello") - Only support single byte strings (p2align 0) Like the ELF linker merging is only performed at `-O1` and above. This fixes part of https://bugs.llvm.org/show_bug.cgi?id=48828, although crucially it doesn't not currently support debug sections because they are not represented by data segments (they are custom sections) Differential Revision: https://reviews.llvm.org/D97657
2021-05-02Reland "AMDGPU/llvm-readobj: Add missing tests for note parsing/displaying"Konstantin Zhuravlyov1-0/+3
This reverts commit 54aad6365951247e9f18c718c14422745b3afa4c. Includes fix for note-amd-valid-v3.s test.
2021-05-02[Object] Fix e_machine description for EM_CR16 and add EM_MICROBLAZESergio Perez Gonzalez1-0/+1
Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D101133
2021-04-30Revert "AMDGPU/llvm-readobj: Add missing tests for note parsing/displaying"Konstantin Zhuravlyov1-3/+0
This reverts commit c9c4676a458b1ef99ffb67b43cfd87d6c27a448c. Reason for revert: note-amd-valid-v3.s test fails if AMDGPU is not built.
2021-04-30AMDGPU/llvm-readobj: Add missing tests for note parsing/displayingKonstantin Zhuravlyov1-0/+3
This is a follow up review/change for https://reviews.llvm.org/D95638 Add valid note tests for code object v2 notes: - NT_AMD_HSA_CODE_OBJECT_VERSION (required yaml2obj update) - NT_AMD_HSA_HSAIL (required yaml2obj update) - NT_AMD_HSA_ISA_VERSION (required yaml2obj update) - NT_AMD_HSA_METADATA - NT_AMD_HSA_ISA_NAME - NT_AMD_PAL_METADATA Add valid note tests for code object v3 notes: - NT_AMDGPU_METADATA Add invalid note tests for code object v2 notes: - NT_AMD_HSA_CODE_OBJECT_VERSION (required yaml2obj update) - NT_AMD_HSA_HSAIL (required yaml2obj update) - NT_AMD_HSA_ISA_VERSION (required yaml2obj update) Add invalid note tests for code object v3 notes: - NT_AMDGPU_METADATA Differential Revision: https://reviews.llvm.org/D101304
2021-04-15[yaml2obj/obj2yaml/llvm-readobj] Support printing and parsing AVR-specific ↵LemonBoy1-17/+19
e_flags The `e_flags` contains a mixture of bitfields and regular ones, ensure all of them can be serialized and deserialized. Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D100250
2021-04-09[lld] Fixed CodeView GuidAdapter::format to handle GUID bytes in the right ↵Alex Orlov1-15/+20
order. This fixes https://bugs.llvm.org/show_bug.cgi?id=41712 bug. Reviewed By: aganea Differential Revision: https://reviews.llvm.org/D99978
2021-03-24AMDGPU: Add target id and code object v4 supportKonstantin Zhuravlyov1-5/+30
- Add target id support (https://clang.llvm.org/docs/ClangOffloadBundler.html#target-id) - Add code object v4 support (https://llvm.org/docs/AMDGPUUsage.html#elf-code-object) - Add kernarg_size to kernel descriptor - Change trap handler ABI to no longer move queue pointer into s[0:1] - Cleanup ELF definitions - Add V2, V3, V4 suffixes to make a clear distinction for code object version - Consolidate note names Differential Revision: https://reviews.llvm.org/D95638
2021-03-24[WebAssembly] Rename WasmLimits::Initial to ::Minimum. NFC.Andy Wingo2-2/+2
This patch renames the "Initial" member of WasmLimits to the name used in the spec, "Minimum". In the core WebAssembly specification, the Limits data type has one required "min" member and one optional "max" member, indicating the minimum required size of the corresponding table or memory, and the maximum size, if any. Although the WebAssembly spec does instantiate locally-defined tables and memories with the initial size being equal to the minimum size, it can't impose such a requirement for imports. It doesn't make sense to require an initial size for a memory import, for example. The compiler can only sensibly express the minimum and maximum sizes. See https://github.com/WebAssembly/js-types/blob/master/proposals/js-types/Overview.md#naming-of-size-limits for a related discussion that agrees that the right name of "initial" is "minimum" when querying the type of a table or memory from JavaScript. (Of course it still makes sense for JS to speak in terms of an initial size when it explicitly instantiates memories and tables.) Differential Revision: https://reviews.llvm.org/D99186
2021-03-17[ObjectYAML] Handle Hexagon V68Krzysztof Parzyszek1-0/+2
2021-03-08Read NumBlocks as uint64_t.Rahman Lavaee1-1/+1
This fixes the Buildbot failure happened due to a sloppy merge.
2021-03-08[M68k](4/8) MC layer and object file supportMin-Yih Hsu1-0/+3
- Add the M68k-specific MC layer implementation - Add ELF support for M68k - Add M68k-specifc CC and reloc TODO: Currently AsmParser and disassembler are not implemented yet. Please use this bug to track the status: https://bugs.llvm.org/show_bug.cgi?id=48976 Authors: myhsu, m4yers, glaubitz Differential Revision: https://reviews.llvm.org/D88390
2021-03-05[WebAssembly][yaml2obj][obj2yaml] Elem sections for nonzero tablesAndy Wingo2-1/+24
With reference types, tables can have non-zero table numbers. This commit adds support for element sections against these tables. Differential Revision: https://reviews.llvm.org/D97923
2021-02-22[obj2yaml,yaml2obj] Add NumBlocks to the BBAddrMapEntry yaml field.Rahman Lavaee2-2/+2
As discussed in D95511, this allows us to encode invalid BBAddrMap sections to be used in more rigorous testing. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D96831
2021-02-17[AMDGPU] gfx90a supportStanislav Mekhanoshin1-0/+1
Differential Revision: https://reviews.llvm.org/D96906
2021-02-17[obj2yaml,yaml2obj] Add NumBlocks to the BBAddrMapEntry yaml field.Rahman Lavaee2-4/+7
As discussed in D95511, this allows us to encode invalid BBAddrMap sections to be used in more rigorous testing. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D96831
2021-02-09[llvm-readobj] Add support for decoding FreeBSD ELF notesAlex Richardson1-0/+5
The current support only printed coredump notes, but most binaries also contain notes. This change adds names for four FreeBSD-specific notes and pretty-prints three of them: NT_FREEBSD_ABI_TAG: This note holds a 32-bit (decimal) integer containing the value of the __FreeBSD_version macro, which is defined in crt1.o and will hold a value such as 1300076 for a binary build on a FreeBSD 13 system. NT_FREEBSD_ARCH_TAG: A string containing the value of the build-time MACHINE_ARCH NT_FREEBSD_FEATURE_CTL: A 32-bit flag that indicates to the kernel that the binary wants certain bevahiour. Examples include setting NT_FREEBSD_FCTL_ASLR_DISABLE which tells the kernel to disable ASLR. After this change llvm-readobj also no longer decodes coredump-only FreeBSD notes in non-coredump files. I've also converted the note-freebsd.s test to use yaml2obj instead of llvm-mc. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D74393
2021-02-09[yaml2obj] Handle NT_* string values in for ELF note typesAlex Richardson1-0/+89
This is required for D74393. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D95953
2021-02-02[yaml2obj][wasm] Support numeric relocation typeFangrui Song1-0/+1
Differential Revision: https://reviews.llvm.org/D95661
2021-02-02Diagnose if a SLEB128 is too large to fit in an int64_t.Richard Smith1-1/+2
Previously we'd hit UB due to an invalid left shift operand. Also fix the WASM emitter to properly use SLEB128 encoding instead of ULEB128 encoding for signed fields so that negative numbers don't result in overly-large values that we can't read back any more. In passing, don't diagnose a non-canonical ULEB128 that fits in a uint64_t but has redundant trailing zero bytes. Reviewed By: dblaikie, aardappel Differential Revision: https://reviews.llvm.org/D95510
2021-02-02[yaml2obj/obj2yaml/llvm-readobj] Support SHF_GNU_RETAINFangrui Song1-0/+1
In binutils, the flag is defined for ELFOSABI_GNU and ELFOSABI_FREEBSD. It can be used to mark a section as a GC root. In practice, the flag has generic semantics and can be applied to many EI_OSABI values, so we consider it generic. Differential Revision: https://reviews.llvm.org/D95728
2021-01-28[yaml2obj] - Allow empty SectionHeaderTable definitions.Georgii Rymar2-5/+4
Currently we don't allow the following definition: ``` Sections: - Type: SectionHeaderTable - Name: .foo Type: SHT_PROGBITS ``` We report an error: "SectionHeaderTable can't be empty. Use 'NoHeaders' key to drop the section header table". It was implemented in this way earlier, when `SectionHeaderTable` was a dedicated key outside of the `Sections` list. And we did not allow to select where the table is written. Currently it makes sense to allow it, because a user might want to place the default section header table at an arbitrary position, e.g. before other sections. In this case it is not convenient and error prone to require specifying all sections: ``` Sections: - Type: SectionHeaderTable Sections: - Name: .foo - Name: .strtab - Name: .shstrtab - Name: .foo Type: SHT_PROGBITS ``` This patch allows empty SectionHeaderTable definitions. Differential revision: https://reviews.llvm.org/D95341
2021-01-26[yaml2obj][obj2yaml] - Improve how we set/dump the sh_entsize field.Georgii Rymar1-17/+6
We already set the `sh_entsize` field in a single place for all non-implicit sections. This patch reorders the logic slightly and with it we finally have the only one place where the `sh_entsize` is set. obj2yaml will not dump the `EntSize` key for `SHT_DYNSYM/SHT_SYMTAB` sections anymore, when the value of `sh_entsize` is equal to `sizeof(Elf_Sym)` Note that this also seems revealed an issue in llvm-objcopy: Previously yaml2obj set the `sh_entsize` for the `.symtab` section to 0x18, now we it sets it for `SHT_SYMTAB` sections, i.e. by type. But the `llvm-objcopy/ELF/only-keep-debug.test` has a `.symtab` section of type `SHT_STRTAB`, and now yaml2obj sets the `sh_entsize` to 0 for it. I had to update the corresponding check lines for `ES`, but the behavior of `llvm-objcopy` should be fixed instead I think. I've added a TODO and a comment. Differential revision: https://reviews.llvm.org/D95364
2021-01-26[yaml2obj] - Refine how we set the sh_link field. NFCI.Georgii Rymar1-77/+42
This refactors the logic that sets the `sh_link` field. With this patch we set it in a single place for all sections. Differential revision: https://reviews.llvm.org/D95354
2021-01-25[ObjectYAML] - An attempt to fix BB after commit of D95140.Georgii Rymar1-0/+2
D95140 introduced `static constexpr StringRef TypeStr = "SectionHeaderTable";` member of `SectionHeaderTable` with in-class initialized. BB reports the link error: /usr/bin/ld: lib/libLLVMObjectYAML.a(ELFYAML.cpp.o): in function `llvm::yaml::MappingTraits<std::unique_ptr<llvm::ELFYAML::Chunk, std::default_delete<llvm::ELFYAML::Chunk> > >::mapping(llvm::yaml::IO&, std::unique_ptr<llvm::ELFYAML::Chunk, std::default_delete<llvm::ELFYAML::Chunk> >&)': ELFYAML.cpp:(.text._ZN4llvm4yaml13MappingTraitsISt10unique_ptrINS_7ELFYAML5ChunkESt14default_deleteIS4_EEE7mappingERNS0_2IOERS7_+0x58): undefined reference to `llvm::ELFYAML::SectionHeaderTable::TypeStr' /usr/bin/ld: ELFYAML.cpp:(.text._ZN4llvm4yaml13MappingTraitsISt10unique_ptrINS_7ELFYAML5ChunkESt14default_deleteIS4_EEE7mappingERNS0_2IOERS7_+0x353):undefined reference to `llvm::ELFYAML::SectionHeaderTable::TypeStr' /usr/bin/ld: ELFYAML.cpp:(.text._ZN4llvm4yaml13MappingTraitsISt10unique_ptrINS_7ELFYAML5ChunkESt14default_deleteIS4_EEE7mappingERNS0_2IOERS7_+0x6e5): undefined reference to `llvm::ELFYAML::SectionHeaderTable::TypeStr' This patch adds a definition to cpp file, I guess it should fix the issue.
2021-01-25[yaml2obj, obj2yaml] - Implement section header table as a special Chunk.Georgii Rymar2-82/+149
This was discussed in D93678 thread. Currently we have one special chunk - Fill. This patch re implements the "SectionHeaderTable" key to become a special chunk too. With that we are able to place the section header table at any location, just like we place sections. Differential revision: https://reviews.llvm.org/D95140