aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
AgeCommit message (Collapse)AuthorFilesLines
2025-06-26[llvm] Use a new constructor of ArrayRef (NFC) (#146008)Kazu Hirata1-3/+2
ArrayRef now has a new constructor that takes a parameter whose type has data() and size(). This patch migrates: ArrayRef<T>(X.data(), X.size() to: ArrayRef<T>(X)
2025-03-11[llvm-rtdyld] Avoid repeated hash lookups (NFC) (#130711)Kazu Hirata1-3/+5
2024-05-20Use StringRef::find_first_of(char), etc (NFC) (#92841)Kazu Hirata1-2/+2
2024-01-20[llvm-jitlink] Allow optional stub-kind filter in stub_addr() expressions ↵Stefan Gränitz1-3/+8
(#78369) We use `jitlink-check` lines in LIT tests as the primary tool for testing JITLink backends. Parsing and evaluation of the expressions is implemented in `RuntimeDyldChecker`. The `stub_addr(obj, name)` expression allows to obtain the linker-generated stub for the external symbol `name` in object file `obj`. This patch adds support for a filter parameter to select one out of many stubs. This is necessary for the AArch32 JITLink backend, which must be able to emit two different kinds of stubs depending on the instruction set state (Arm/Thumb) of the relocation site. Since the new parameter is optional, we don't have to update existing tests. Filters are regular expressions without brackets that match exactly one existing stub. Given object file `armv7.o` with two stubs for external function `ext` of kinds `armv7_abs_le` and `thumbv7_abs_le`, we get the following filter results e.g.: ``` stub_addr(armv7.o, ext, thumb) thumbv7_abs_le stub_addr(armv7.o, ext, thumbv7) thumbv7_abs_le stub_addr(armv7.o, ext, armv7_abs_le) armv7_abs_le stub_addr(armv7.o, ext, v7_.*_le) Error: "ext" has 2 candidate stubs in file "armv7.o". Please refine stub-kind filter "v7_.*_le" for disambiguation (encountered kinds are "thumbv7_abs_le", "armv7_abs_le"). stub_addr(armv7.o, ext, v8) Error: "ext" has 2 stubs in file "armv7.o", but none of them matches the stub-kind filter "v8" (all encountered kinds are "thumbv7_abs_le", "armv7_abs_le"). ```
2023-10-12Use llvm::endianness::{big,little,native} (NFC)Kazu Hirata1-1/+3
Note that llvm::support::endianness has been renamed to llvm::endianness while becoming an enum class as opposed to an enum. This patch replaces support::{big,little,native} with llvm::endianness::{big,little,native}.
2023-09-09[jitlink][rtdyld][checker] Re-apply 4b17c81d5a5 with fixes.Eymen Ünay1-1/+3
This re-applies 4b17c81d5a5, "[jitlink/rtdydl][checker] Add TargetFlag dependent disassembler switching support", which was reverted in 4871a9ca546 due to bot failures. The patch has been updated to add missing plumbing for Subtarget Features and a CPU string, which should fix the failing tests. https://reviews.llvm.org/D158280
2023-09-08Revert "[jitlink/rtdydl][checker] Add TargetFlag dependent disassembler ↵Tom Weaver1-4/+1
switching support" This reverts commit 4b17c81d5a5d3e0f514026c2b7f9b623d901cc04. Caused buildbot failures: https://lab.llvm.org/buildbot/#/builders/230/builds/18341 https://lab.llvm.org/buildbot/#/builders/109/builds/73169 https://lab.llvm.org/buildbot/#/builders/67/builds/12597
2023-09-08[jitlink/rtdydl][checker] Add TargetFlag dependent disassembler switching ↵Eymen Ünay1-1/+4
support Some targets such as AArch32 make use of TargetFlags to indicate ISA mode. Depending on the TargetFlag, MCDisassembler and similar target specific objects should be reinitialized with the correct Target Triple. Backends with similar needs can easily extend this implementation for their usecase. The drivers llvm-rtdyld and llvm-jitlink have their SymbolInfo's extended to take TargetFlag into account. RuntimeDyldChecker can now create necessary TargetInfo to reinitialize MCDisassembler and MCInstPrinter. The required triple is obtained from the new getTripleFromTargetFlag function by checking the TargetFlag. In addition, breaking changes for RuntimeDyld COFF Thumb tests are fixed by making the backend emit a TargetFlag. Reviewed By: lhames, sgraenitz Differential Revision: https://reviews.llvm.org/D158280
2022-06-05Remove unneeded cl::ZeroOrMore for cl::opt/cl::list optionsFangrui Song1-1/+1
2022-06-05Remove unneeded cl::ZeroOrMore for cl::opt/cl::list optionsFangrui Song1-5/+4
2022-06-04Remove unneeded cl::ZeroOrMore for cl::list optionsFangrui Song1-1/+1
2022-02-17[RuntimeDyld] Fix building on OpenBSDBrad Smith1-3/+3
With https://reviews.llvm.org/D105466 the tree does not build on OpenBSD/amd64. Moritz suggested only building this code on Linux. Reviewed By: MoritzS Differential Revision: https://reviews.llvm.org/D119991
2021-10-09Fixed some errors detected by PVS StudioDávid Bolvanský1-1/+1
2021-10-08Move TargetRegistry.(h|cpp) from Support to MCReid Kleckner1-1/+1
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[llvm] Replace report_fatal_error(std::string) uses with ↵Simon Pilgrim1-8/+11
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-09-07[RuntimeDyld] Guard UsedTLSStorage to x86 ELF onlyJinsong Ji1-0/+2
UsedTLSStorage is only used in allocateTLSSection, guarded in x87 ELF only. So clang will emit error with -Werror on. .../llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp:288:12: error: private field 'UsedTLSStorage' is not used [-Werror,-Wunused-private-field] unsigned UsedTLSStorage = 0; ^
2021-09-06[RuntimeDyld] Implemented relocation of TLS symbols in ELFMoritz Sichert1-0/+44
Differential Revision: https://reviews.llvm.org/D105466
2021-08-02[DWARF] Don't process .debug_info relocations for DWO ContextAlexander Yermolovich1-2/+3
When we build with split dwarf in single mode the .o files that contain both "normal" debug sections and dwo sections, along with relocaiton sections for "normal" debug sections. When we create DWARF context in DWARFObjInMemory we process relocations and store them in the map for .debug_info, etc section. For DWO Context we also do it for non dwo dwarf sections. Which I believe is not necessary. This leads to a lot of memory being wasted. We observed 70GB extra memory being used. I went with context sensitive approach, flag is passed in. I am not sure if it's always safe not to process relocations for regular debug sections if Obj contains .dwo sections. If it is alternatvie might be just to scan, in constructor, sections and if there are .dwo sections not to process regular debug ones. Reviewed By: dblaikie Differential Revision: https://reviews.llvm.org/D106624
2021-07-22[llvm][tools] Hide remaining unrelated llvm- tool optionsTimm Bäder1-55/+57
Differential Revision: https://reviews.llvm.org/D106430
2021-05-23[MC] Refactor MCObjectFileInfo initialization and allow targets to create ↵Philipp Krones1-2/+1
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-05[MC] Untangle MCContext and MCObjectFileInfoPhilipp Krones1-1/+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-04-21[Support] Don't include VirtualFileSystem.h in CommandLine.hNico Weber1-0/+1
CommandLine.h is indirectly included in ~50% of TUs when building clang, and VirtualFileSystem.h is large. (Already remarked by jhenderson on D70769.) No behavior change. Differential Revision: https://reviews.llvm.org/D100957
2021-03-30[JITLink] Switch from StringRef to ArrayRef<char>, add some generic x86-64 utilsLang Hames1-3/+6
Adds utilities for creating anonymous pointers and jump stubs to x86_64.h. These are used by the GOT and Stubs builder, but may also be used by pass writers who want to create pointer stubs for indirection. This patch also switches the underlying type for LinkGraph content from StringRef to ArrayRef<char>. This avoids any confusion when working with buffers that contain null bytes in the middle like, for example, a newly added null pointer content array. ;)
2020-11-21[llvm][clang][mlir] Add checks for the return values from Target::createXXX ↵Ella Ma1-0/+2
to prevent protential null deref All these potential null pointer dereferences are reported by my static analyzer for null smart pointer dereferences, which has a different implementation from `alpha.cplusplus.SmartPtr`. The checked pointers in this patch are initialized by Target::createXXX functions. When the creator function pointer is not correctly set, a null pointer will be returned, or the creator function may originally return a null pointer. Some of them may not make sense as they may be checked before entering the function, but I fixed them all in this patch. I submit this fix because 1) similar checks are found in some other places in the LLVM codebase for the same return value of the function; and, 2) some of the pointers are dereferenced before they are checked, which may definitely trigger a null pointer dereference if the return value is nullptr. Reviewed By: tejohnson, MaskRay, jpienaar Differential Revision: https://reviews.llvm.org/D91410
2020-01-28Make llvm::StringRef to std::string conversions explicit.Benjamin Kramer1-3/+3
This is how it should've been and brings it more in line with std::string_view. There should be no functional change here. This is mostly mechanical from a custom clang-tidy check, with a lot of manual fixups. It uncovers a lot of minor inefficiencies. This doesn't actually modify StringRef yet, I'll do that in a follow-up.
2019-10-23[Mips] Use appropriate private label prefix based on Mips ABIMirko Brkusanin1-1/+4
MipsMCAsmInfo was using '$' prefix for Mips32 and '.L' for Mips64 regardless of -target-abi option. By passing MCTargetOptions to MCAsmInfo we can find out Mips ABI and pick appropriate prefix. Tags: #llvm, #clang, #lldb Differential Revision: https://reviews.llvm.org/D66795
2019-09-16Added return statement to fix compile and build warning:Sjoerd Meijer1-0/+1
llvm-rtdyld.cpp:966:7: warning: variable ‘Result’ set but not used llvm-svn: 371972
2019-09-04[llvm-rtdyld][llvm-jitlink] Rename struct member to remove ambiguity.Lang Hames1-5/+4
This ambiguity (struct member name matching struct name) was causing errors on a few of the MSVC bots. Hopefully this should fix it. llvm-svn: 370969
2019-09-04[llvm-rtdyld] Add timers to match llvm-jitlink.Lang Hames1-31/+69
When using llvm-rtdyld to execute code, -show-times will now show the time taken to load the object files, apply relocations, and execute the rtdyld-linked code. llvm-svn: 370968
2019-08-15[llvm] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere1-1/+1
Now that we've moved to C++14, we no longer need the llvm::make_unique implementation from STLExtras.h. This patch is a mechanical replacement of (hopefully) all the llvm::make_unique instances across the monorepo. llvm-svn: 369013
2019-08-14Recommit r368812 "[llvm/Object] - Convert SectionRef::getName() to return ↵George Rimar1-2/+0
Expected<>" Changes: no changes. A fix for the clang code will be landed right on top. Original commit message: SectionRef::getName() returns std::error_code now. Returning Expected<> instead has multiple benefits. For example, it forces user to check the error returned. Also Expected<> may keep a valuable string error message, what is more useful than having a error code. (Object\invalid.test was updated to show the new messages printed.) This patch makes a change for all users to switch to Expected<> version. Note: in a few places the error returned was ignored before my changes. In such places I left them ignored. My intention was to convert the interface used, and not to improve and/or the existent users in this patch. (Though I think this is good idea for a follow-ups to revisit such places and either remove consumeError calls or comment each of them to clarify why it is OK to have them). Differential revision: https://reviews.llvm.org/D66089 llvm-svn: 368826
2019-08-14Revert r368812 "[llvm/Object] - Convert SectionRef::getName() to return ↵George Rimar1-0/+2
Expected<>" It broke clang BB: http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/16455 llvm-svn: 368813
2019-08-14[llvm/Object] - Convert SectionRef::getName() to return Expected<>George Rimar1-2/+0
SectionRef::getName() returns std::error_code now. Returning Expected<> instead has multiple benefits. For example, it forces user to check the error returned. Also Expected<> may keep a valuable string error message, what is more useful than having a error code. (Object\invalid.test was updated to show the new messages printed.) This patch makes a change for all users to switch to Expected<> version. Note: in a few places the error returned was ignored before my changes. In such places I left them ignored. My intention was to convert the interface used, and not to improve and/or the existent users in this patch. (Though I think this is good idea for a follow-ups to revisit such places and either remove consumeError calls or comment each of them to clarify why it is OK to have them). Differential revision: https://reviews.llvm.org/D66089 llvm-svn: 368812
2019-05-20[Support] Renamed member 'Size' to 'AllocatedSize' in MemoryBlock and ↵Lang Hames1-3/+4
OwningMemoryBlock. Rename member 'Size' to 'AllocatedSize' in order to provide a hint that the allocated size may be different than the requested size. Comments are added to clarify this point. Updated the InMemoryBuffer in FileOutputBuffer.cpp to track the requested buffer size. Patch by Machiel van Hooren. Thanks Machiel! https://reviews.llvm.org/D61599 llvm-svn: 361195
2019-05-12[JITLink] Add a test for zero-filled content.Lang Hames1-10/+10
Also updates RuntimeDyldChecker and llvm-rtdyld to support zero-fill tests by returning a content address of zero (but no error) for zero-fill atoms, and treating loads from zero as returning zero. llvm-svn: 360547
2019-04-25[llvm-rtdyld] Add support for passing command line arguments to rtdyld-run code.Lang Hames1-5/+19
The --args option can now be used to pass arguments to code linked with llvm-rtdyld. E.g. $ llvm-rtdyld file1.o file2.o --args a b c is equivalent to: $ ld -o program file1.o file2.o $ ./program a b c This is the rtdyld counterpart to the jitlink change in r359115, and makes benchmarking and comparison between the tools easier. llvm-svn: 359168
2019-04-24[CommandLine] Provide parser<unsigned long> instantiation to allow ↵Fangrui Song1-29/+22
cl::opt<uint64_t> on LP64 platforms Summary: And migrate opt<unsigned long long> to opt<uint64_t> Fixes PR19665 Differential Revision: https://reviews.llvm.org/D60933 llvm-svn: 359068
2019-04-12Simplify decoupling between RuntimeDyld/RuntimeDyldChecker, add 'got_addr' util.Lang Hames1-86/+93
This patch reduces the number of functions in the interface between RuntimeDyld and RuntimeDyldChecker by combining "GetXAddress" and "GetXContent" functions into "GetXInfo" functions that return a struct describing both the address and content. The GetStubOffset function is also replaced with a pair of utilities, GetStubInfo and GetGOTInfo, that fit the new scheme. For RuntimeDyld both of these functions will return the same result, but for the new JITLink linker (https://reviews.llvm.org/D58704) these will provide the addresses of PLT stubs and GOT entries respectively. For JITLink's use, a 'got_addr' utility has been added to the rtdyld-check language, and the syntax of 'got_addr' and 'stub_addr' has been changed: both functions now take two arguments, a 'stub container name' and a target symbol name. For llvm-rtdyld/RuntimeDyld the stub container name is the object file name and section name, separated by a slash. E.g.: rtdyld-check: *{8}(stub_addr(foo.o/__text, y)) = y For the upcoming llvm-jitlink utility, which creates stubs on a per-file basis rather than a per-section basis, the container name is just the file name. E.g.: jitlink-check: *{8}(got_addr(foo.o, y)) = y llvm-svn: 358295
2019-04-09[llvm-rtdyld] Fix missing include on MSVC builds.Simon Pilgrim1-0/+1
llvm-svn: 357990
2019-04-08[RuntimeDyld] Decouple RuntimeDyldChecker from RuntimeDyld.Lang Hames1-48/+212
This will allow RuntimeDyldChecker (and rtdyld-check tests) to test a new JIT linker: JITLink (https://reviews.llvm.org/D58704). llvm-svn: 357947
2019-02-27[DebugInfo] add SectionedAddress to DebugInfo interfaces.Alexey Lapshin1-2/+8
That patch is the fix for https://bugs.llvm.org/show_bug.cgi?id=40703 "wrong line number info for obj file compiled with -ffunction-sections" bug. The problem happened with only .o files. If object file contains several .text sections then line number information showed incorrectly. The reason for this is that DwarfLineTable could not detect section which corresponds to specified address(because address is the local to the section). And as the result it could not select proper sequence in the line table. The fix is to pass SectionIndex with the address. So that it would be possible to differentiate addresses from various sections. With this fix llvm-objdump shows correct line numbers for disassembled code. Differential review: https://reviews.llvm.org/D58194 llvm-svn: 354972
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth1-4/+3
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
2018-11-11[Support] Make error banner optional in logAllUnhandledErrorsJonas Devlieghere1-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
2018-10-23[RuntimeDyld][COFF] Skip non-loaded sections when calculating ImageBase.Lang Hames1-5/+14
Non-loaded sections (whose unused load-address defaults to zero) should not be taken into account when calculating ImageBase, or ImageBase will be incorrectly set to 0. Patch by Andrew Scheidecker. Thanks Andrew! https://reviews.llvm.org/D51343 + // The Sections list may contain sections that weren't loaded for + // whatever reason: they may be debug sections, and ProcessAllSections + // is false, or they may be sections that contain 0 bytes. If the + // section isn't loaded, the load address will be 0, and it should not + // be included in the ImageBase calculation. llvm-svn: 344995
2018-04-13Define InitLLVM to do common initialization all at once.Rui Ueyama1-7/+2
We have a few functions that virtually all command wants to run on process startup/shutdown. This patch adds InitLLVM class to do that all at once, so that we don't need to copy-n-paste boilerplate code to each llvm command's main() function. Differential Revision: https://reviews.llvm.org/D45602 llvm-svn: 330046
2018-03-31[llvm-rtdyld] Fix the InputFileList cl::opt description: it accepts multipleLang Hames1-1/+1
input files. llvm-svn: 328920
2017-12-13Remove redundant includes from tools.Michael Zolotukhin1-2/+0
llvm-svn: 320631
2017-11-16[Support] Support NetBSD PaX MPROTECT in sys::Memory.Lang Hames1-12/+26
Removes AllocateRWX, setWritable and setExecutable from sys::Memory and standardizes on allocateMappedMemory / protectMappedMemory. The allocateMappedMemory method is updated to request full permissions for memory blocks so that they can be marked executable later. llvm-svn: 318464
2017-07-19Use delegation instead of inheritance.Rafael Espindola1-2/+2
This changes DwarfContext to delegate to DwarfObject instead of having pure virtual methods. With this DwarfContextInMemory is replaced with an implementation of DwarfObject that is local to a .cpp file. llvm-svn: 308543
2017-05-09[ExecutionEngine] Make RuntimeDyld::MemoryManager responsible for tracking EHLang Hames1-2/+1
frames. RuntimeDyld was previously responsible for tracking allocated EH frames, but it makes more sense to have the RuntimeDyld::MemoryManager track them (since the frames are allocated through the memory manager, and written to memory owned by the memory manager). This patch moves the frame tracking into RTDyldMemoryManager, and changes the deregisterFrames method on RuntimeDyld::MemoryManager from: void deregisterEHFrames(uint8_t *Addr, uint64_t LoadAddr, size_t Size); to: void deregisterEHFrames(); Separating this responsibility will allow ORC to continue to throw the RuntimeDyld instances away post-link (saving a few dozen bytes per lazy function) while properly deregistering frames when modules are unloaded. This patch also updates ORC to call deregisterEHFrames when modules are unloaded. This fixes a bug where an exception that tears down the JIT can then unwind through dangling EH frames that have been deallocated but not deregistered, resulting in UB. For people using SectionMemoryManager this should be pretty much a no-op. For people with custom allocators that override registerEHFrames/deregisterEHFrames, you will now be responsible for tracking allocated EH frames. Reviewed in https://reviews.llvm.org/D32829 llvm-svn: 302589