aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Object
AgeCommit message (Collapse)AuthorFilesLines
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
2021-07-14[ARM] Fix RELA relocations for 32bit ARM.Wolfgang Pieb1-4/+14
RELA relocations for 32 bit ARM ignored the addend. Some tools generate them instead of REL type relocations. This fixes PR50473. Reviewed By: MaskRay, peter.smith Differential Revision: https://reviews.llvm.org/D105214
2021-07-09[NFC][OpaquePtr] Use GlobalValue::getValueType() moreArthur Eubanks1-2/+2
Instead of getType()->getElementType().
2021-07-08PR51018: Remove explicit conversions from SmallString to StringRef to ↵David Blaikie1-1/+1
future-proof against C++23 C++23 will make these conversions ambiguous - so fix them to make the codebase forward-compatible with C++23 (& a follow-up change I've made will make this ambiguous/invalid even in <C++23 so we don't regress this & it generally improves the code anyway)
2021-07-05[llvm-readobj][XCOFF] Add support for printing the String Table.Esme-Yi1-0/+4
Summary: The patch adds the StringTable dumping to llvm-readobj. Currently only XCOFF is supported. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D104613
2021-06-24[AMDGPU] Add gfx1035 targetAakanksha Patil1-0/+2
Differential Revision: https://reviews.llvm.org/D104804
2021-06-23[TextAPI] add symbol name prefixes to central location, NFCCyndy Ishida1-6/+1
These prefixes are used for printing the symbols coming from tbd files and they were redundant across locations
2021-06-21[WebAssembly] Make tag attribute's encoding uint8Heejin Ahn1-2/+2
This changes the encoding of the `attribute` field, which currently only contains the value `0` denoting this tag is for an exception, from `varuint32` to `uint8`. This field is effectively unused at the moment and reserved for future use, and it is not likely to need `varuint32` even in future. See https://github.com/WebAssembly/exception-handling/pull/162. This does not change any encoded binaries because `0` is encoded in the same way both in `varuint32` and `uint8`. Reviewed By: tlively Differential Revision: https://reviews.llvm.org/D104571
2021-06-17[WebAssembly] Rename event to tagHeejin Ahn2-61/+61
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-14[AIX][XCOFF] emit vector info of traceback table.zhijian1-87/+59
Summary: emit vector info of traceback table. Reviewers: Jason Liu,Hubert Tong Differential Revision: https://reviews.llvm.org/D93659
2021-06-13MachOObjectFile.cpp - remove unused <string> include. NFCI.Simon Pilgrim1-1/+0
2021-06-10[XCOFF][llvm-objdump] Dump the debug type in `--section-headers` option.Esme-Yi1-0/+5
Summary: Add XCOFF recognition of debug section types under `--section-headers` option. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D103079
2021-06-10[llvm-objdump][XCOFF] Enable the -l (--line-numbers) option.Esme-Yi2-3/+12
Summary: Add support for dumping line number information for XCOFF object files in llvm-objdump. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D101272
2021-06-08Reland "[AMDGPU] Add gfx1013 target"Brendon Cahoon1-0/+2
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-2/+0
This reverts commit ea10a86984ea73fcec3b12d22404a15f2f59b219. A sanitizer buildbot reports an error.
2021-06-08[AMDGPU] Add gfx1013 targetBrendon Cahoon1-0/+2
Differential Revision: https://reviews.llvm.org/D103663
2021-06-07BPF: fix relocation types in lib/Object/RelocationResolver.cppYonghong Song1-4/+4
Commit 6a2ea84600ba ("BPF: Add more relocation kinds") added new relocations R_BPF_64_ABS64 and R_BPF_64_ABS32 for normal 64-bit and 32-bit data relocations. This is to replace some of functionalities with R_BPF_64_64 and R_BPF_64_32 so that new R_BPF_64_64 and R_BPF_64_32 semantics are for ld_imm64 and call instructions only. The BPF support in lib/Object/RelocationResolver.cpp is used to perform normal data relocations for the case like DWARFObjInMemory with an object file (search function getRelocationResolver() in file DebugInfo/DWARF/DWARFContext.cpp) or llvm-readobj to dump ".stack_sizes" section data. In all these casees, normal 64-bit and 32-bit relocations are performed and such resolution resolution is exactly what implemented in RelocationResolver.cpp. But Commit 6a2ea84600ba missed to change R_BPF_64_64/R_BPF_64_32 to R_BPF_64_ABS64/R_BPF_64_ABS32. This patch fixed the issue and added a test for it with llvm-readobj dumping ".stack_sizes" section. Differential Revision: https://reviews.llvm.org/D103864
2021-06-07[ELF] getRelocatedSection: remove the check for ET_REL object fileAmir Ayupov1-1/+1
getRelocatedSection interface should not check that the object file is relocatable, as executable files may have relocations preserved with `--emit-relocs` linker flag. The relocations are useful in context of post-link binary analysis for function reference identification. For example, BOLT relies on relocations to perform function reordering. Reviewed By: MaskRay, jhenderson Differential Revision: https://reviews.llvm.org/D102296
2021-06-07[XCOFF][AIX] Enable tooling support for 64 bit symbol table parsingjasonliu1-101/+130
Add in the ability of parsing symbol table for 64 bit object. Reviewed By: jhenderson, DiggerLin Differential Revision: https://reviews.llvm.org/D85774
2021-05-27[NFC][libObject] clang-format Archive{.h,.cpp}Jordan Rupprecht1-68/+79
In preparation for D100651
2021-05-26[NFC][object] Change the input parameter of the method isDebugSection.Esme-Yi3-5/+17
Summary: This is a NFC patch to change the input parameter of the method SectionRef::isDebugSection(), by replacing the StringRef SectionName with DataRefImpl Sec. This allows us to determine if a section is debug type in more ways than just by section name. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D102601
2021-05-23[MC] Refactor MCObjectFileInfo initialization and allow targets to create ↵Philipp Krones1-4/+5
MCObjectFileInfo This makes it possible for targets to define their own MCObjectFileInfo. This MCObjectFileInfo is then used to determine things like section alignment. This is a follow up to D101462 and prepares for the RISCV backend defining the text section alignment depending on the enabled extensions. Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D101921
2021-05-20[WebAssembly] Fix PIC/GOT codegen for wasm64Wouter van Oortmerssen1-0/+1
__table_base is know 64-bit, since in LLVM it represents a function pointer offset __table_base32 is a copy in wasm32 for use in elem init expr, since no truncation may be used there. New reloc R_WASM_TABLE_INDEX_REL_SLEB64 added Differential Revision: https://reviews.llvm.org/D101784
2021-05-13[AMDGPU] Add gfx1034 targetAakanksha Patil1-0/+2
Differential Revision: https://reviews.llvm.org/D102306
2021-05-12[lld][WebAssembly] Allow data symbols to extend past end of segmentSam Clegg1-3/+6
This fixes a bug with string merging with string symbols that contain NULLs, as is the case in the `merge-string.s` test. The bug only showed when we run with `--relocatable` and then try read the resulting object back in. In this case we would end up with string symbols that extend past the end of the segment in which they live. The problem comes from the fact that sections which are flagged as string mergable assume that all strings are NULL terminated. The merging algorithm will drop trailing chars that follow a NULL since they are essentially unreachable. However, the "size" attribute (in the symbol table) of such a truncated symbol is not updated resulting a symbol size that can overlap the end of the segment. I verified that this can happen in ELF too given the right conditions and the its harmless enough. In practice Strings that contain embedded null should not be part of a mergable section. Differential Revision: https://reviews.llvm.org/D102281
2021-05-10Reland: "[lld][WebAssembly] Initial support merging string data"Sam Clegg1-2/+2
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-2/+2
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-2/+2
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-05[MC] Untangle MCContext and MCObjectFileInfoPhilipp Krones1-2/+2
This untangles the MCContext and the MCObjectFileInfo. There is a circular dependency between MCContext and MCObjectFileInfo. Currently this dependency also exists during construction: You can't contruct a MOFI without a MCContext without constructing the MCContext with a dummy version of that MOFI first. This removes this dependency during construction. In a perfect world, MCObjectFileInfo wouldn't depend on MCContext at all, but only be stored in the MCContext, like other MC information. This is future work. This also shifts/adds more information to the MCContext making it more available to the different targets. Namely: - TargetTriple - ObjectFileType - SubtargetInfo Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D101462
2021-05-03[lld][WebAssembly] Do not merge comdat data segmentsSam Clegg1-2/+2
When running in relocatable mode any input data segments that are part of a comdat group should not be merged with other segments of the same name. This is because the final linker needs to keep the separate so they can be included/excluded individually. Often this is not a problem since normally only one section with a given name `foo` ends up in the output object file. However, the problem occurs when one input contains `foo` which part of a comdat and another object contains a local symbol `foo` we were attempting to merge them. This behaviour matches (I believe) that of the ELF linker. See `LinkerScript.cpp:addInputSec`. Fixes: https://github.com/emscripten-core/emscripten/issues/9726 Differential Revision: https://reviews.llvm.org/D101703
2021-04-05[TextAPI] move source code files out of subdirectory, NFCCyndy Ishida1-1/+1
TextAPI/ELF has moved out into InterfaceStubs, so theres no longer a need to seperate out TextAPI between formats. Reviewed By: ributzka, int3, #lld-macho Differential Revision: https://reviews.llvm.org/D99811
2021-03-30[WebAssembly] Encode numbers in ULEB128 in event sectionHeejin Ahn1-2/+2
The number of events and the type index should be encoded in ULEB128, but they were incorrctly encoded in LEB128. The smallest number with which its LEB128 and ULEB128 encodings are different is 64. There's no way we can generate 64 events in the C++ toolchain implementation so we can't test that, but the attached test tests when the type index is 64. Reviewed By: dschuff Differential Revision: https://reviews.llvm.org/D99627
2021-03-25[NFC] Reordering parameters in getFile and getFileOrSTDINAbhina Sreeskantharajan1-1/+1
In future patches I will be setting the IsText parameter frequently so I will refactor the args to be in the following order. I have removed the FileSize parameter because it is never used. ``` static ErrorOr<std::unique_ptr<MemoryBuffer>> getFile(const Twine &Filename, bool IsText = false, bool RequiresNullTerminator = true, bool IsVolatile = false); static ErrorOr<std::unique_ptr<MemoryBuffer>> getFileOrSTDIN(const Twine &Filename, bool IsText = false, bool RequiresNullTerminator = true); static ErrorOr<std::unique_ptr<MB>> getFileAux(const Twine &Filename, uint64_t MapSize, uint64_t Offset, bool IsText, bool RequiresNullTerminator, bool IsVolatile); static ErrorOr<std::unique_ptr<WritableMemoryBuffer>> getFile(const Twine &Filename, bool IsVolatile = false); ``` Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D99182
2021-03-24[WebAssembly] Rename WasmLimits::Initial to ::Minimum. NFC.Andy Wingo1-1/+1
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[XCOFF][llvm-dwarfdump] llvm-dwarfdump support for XCOFFChen Zheng1-3/+18
Author: hubert.reinterpretcast, shchenz Reviewed By: jasonliu, echristo Differential Revision: https://reviews.llvm.org/D97186
2021-03-17[Object][MachO] Handle end iterator in getSymbolType()Steven Wu1-0/+2
Fix a bug in MachOObjectFile::getSymbolType() that it is not checking if the iterator is end() before deference the iterator. Instead, return `Other` type, which aligns with the behavior of `llvm-nm`. rdar://75291638 Reviewed By: davide, ab Differential Revision: https://reviews.llvm.org/D98739
2021-03-10[llvm-objcopy][NFC] replace class Buffer/MemBuffer/FileBuffer with streams.Alexey Lapshin1-13/+2
During D88827 it was requested to remove the local implementation of Memory/File Buffers: // TODO: refactor the buffer classes in LLVM to enable us to use them here // directly. This patch uses raw_ostream instead of Buffers. Generally, using streams could allow us to reduce memory usages. No need to load all data into the memory - the data could be streamed through a smaller buffer. Thus, this patch uses raw_ostream as an interface for output data: Error executeObjcopyOnBinary(CopyConfig &Config, object::Binary &In, raw_ostream &Out); Note 1. This patch does not change the implementation of Writers so that data would be directly stored into raw_ostream. This is assumed to be done later. Note 2. It would be better if Writers would be implemented in a such way that data could be streamed without seeking/updating. If that would be inconvenient then raw_ostream could be replaced with raw_pwrite_stream to have a possibility to seek back and update file headers. This is assumed to be done later if necessary. Note 3. Current FileOutputBuffer allows using a memory-mapped file. The raw_fd_ostream (which could be used if data should be stored in the file) does not allow us to use a memory-mapped file. Memory map functionality could be implemented for raw_fd_ostream: It is possible to add resize() method into raw_ostream. class raw_ostream { void resize(uint64_t size); } That method, implemented for raw_fd_ostream, could create a memory-mapped file. The streamed data would be written into that memory file then. Thus we would be able to use memory-mapped files with raw_fd_ostream. This is assumed to be done later if necessary. Differential Revision: https://reviews.llvm.org/D91028
2021-03-08[llvm-readelf] Support dumping the BB address map section with --bb-addr-map.Rahman Lavaee1-0/+52
This patch lets llvm-readelf dump the content of the BB address map section in the following format: ``` Function { At: <address> BB entries [ { Offset: <offset> Size: <size> Metadata: <metadata> }, ... ] } ... ``` Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D95511
2021-03-08[M68k](4/8) MC layer and object file supportMin-Yih Hsu1-0/+7
- 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-08[WebAssembly] Add new relocation for location relative dataYuta Saito2-0/+4
This `R_WASM_MEMORY_ADDR_SELFREL_I32` relocation represents an offset between its relocating address and the symbol address. It's very similar to `R_X86_64_PC32` but restricted to be used for only data segments. ``` S + A - P ``` A: Represents the addend used to compute the value of the relocatable field. P: Represents the place of the storage unit being relocated. S: Represents the value of the symbol whose index resides in the relocation entry. Proposal: https://github.com/WebAssembly/tool-conventions/issues/162 Differential Revision: https://reviews.llvm.org/D96659
2021-03-06[MC] Support .symver *, *, removeFangrui Song2-5/+6
As a resolution to https://sourceware.org/bugzilla/show_bug.cgi?id=25295 , GNU as from binutils 2.35 supports the optional third argument for the .symver directive. 'remove' for a non-default version is useful: `.symver def_v1, def@v1, remove` => def_v1 is not retained in the symbol table. Previously the user has to strip the original symbol or specify a `local:` version node in a version script to localize the symbol. `.symver def, def@@v1, remove` and `.symver def, def@@@v1, remove` are supported as well, though they are identical to `.symver def, def@@@v1`. local/hidden are not useful so this patch does not implement them.
2021-03-05[WebAssembly][yaml2obj][obj2yaml] Elem sections for nonzero tablesAndy Wingo1-12/+53
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