llvm-6502/include/llvm/Support
Ulrich Weigand 5ee5fc4c47 [PowerPC] ELFv2 MC support for .localentry directive
A second binutils feature needed to support ELFv2 is the .localentry
directive.  In the ELFv2 ABI, functions may have two entry points:
one for calling the routine locally via "bl", and one for calling the
function via function pointer (either at the source level, or implicitly
via a PLT stub for global calls).  The two entry points share a single
ELF symbol, where the ELF symbol address identifies the global entry
point address, while the local entry point is found by adding a delta
offset to the symbol address.  That offset is encoded into three
platform-specific bits of the ELF symbol st_other field.

The .localentry directive instructs the assembler to set those fields
to encode a particular offset.  This is typically used by a function
prologue sequence like this:

func:
        addis r2, r12, (.TOC.-func)@ha
        addi r2, r2, (.TOC.-func)@l
        .localentry func, .-func

Note that according to the ABI, when calling the global entry point,
r12 must be set to point the global entry point address itself; while
when calling the local entry point, r2 must be set to point to the TOC
base.  The two instructions between the global and local entry point in
the above example translate the first requirement into the second.

This patch implements support in the PowerPC MC streamers to emit the
.localentry directive (both into assembler and ELF object output), as
well as support in the assembler parser to parse that directive.

In addition, there is another change required in MC fixup/relocation
handling to properly deal with relocations targeting function symbols
with two entry points: When the target function is known local, the MC
layer would immediately handle the fixup by inserting the target
address -- this is wrong, since the call may need to go to the local
entry point instead.  The GNU assembler handles this case by *not*
directly resolving fixups targeting functions with two entry points,
but always emits the relocation and relies on the linker to handle
this case correctly.  This patch changes LLVM MC to do the same (this
is done via the processFixupValue routine).

Similarly, there are cases where the assembler would normally emit a
relocation, but "simplify" it to a relocation targeting a *section*
instead of the actual symbol.  For the same reason as above, this
may be wrong when the target symbol has two entry points.  The GNU
assembler again handles this case by not performing this simplification
in that case, but leaving the relocation targeting the full symbol,
which is then resolved by the linker.  This patch changes LLVM MC
to do the same (via the needsRelocateWithSymbol routine).
NOTE: The method used in this patch is overly pessimistic, since the
needsRelocateWithSymbol routine currently does not have access to the
actual target symbol, and thus must always assume that it might have
two entry points.  This will be improved upon by a follow-on patch
that modifies common code to pass the target symbol when calling
needsRelocateWithSymbol.

Reviewed by Hal Finkel.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213485 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-20 23:06:03 +00:00
..
AIXDataTypesFix.h
AlignOf.h Extend llvm::AlignedCharArrayUnion to support up to 10 arguments, as required by Clang's APValue. 2014-01-09 03:28:55 +00:00
Allocator.h Allocator: Remove ReferenceAdder hack. 2014-04-18 14:54:51 +00:00
ARMBuildAttributes.h Emit the ARM build attributes ABI_PCS_wchar_t and ABI_enum_size. 2014-06-20 10:08:11 +00:00
ARMEHABI.h Support: add reference for ARM EHABI 2014-01-06 04:14:03 +00:00
ARMWinEH.h Avoid non-ascii character in the source code. 2014-06-27 17:25:54 +00:00
ArrayRecycler.h [C++11] More 'nullptr' conversion. In some cases just using a boolean check instead of comparing to nullptr. 2014-04-14 00:51:57 +00:00
Atomic.h
BlockFrequency.h blockfreq: Defer to BranchProbability::scale() (again) 2014-04-29 16:31:29 +00:00
BranchProbability.h BranchProb: Simplify printing code 2014-04-29 17:07:42 +00:00
Capacity.h
Casting.h [C++11] More 'nullptr' conversion or in some cases just using a boolean check instead of comparing to nullptr. 2014-04-09 06:08:46 +00:00
CBindingWrapping.h Fix file header comment. 2013-05-01 21:01:06 +00:00
circular_raw_ostream.h [C++11] Make use of 'nullptr' in the Support library. 2014-04-07 04:17:22 +00:00
CodeGen.h This exposes more MCJIT options via the C API: 2013-05-01 22:58:00 +00:00
COFF.h Support: update DLLCharacteristics enumeration 2014-06-27 03:11:18 +00:00
CommandLine.h Support: Fix option handling when using cl::Required with aliasopt 2014-07-14 20:53:57 +00:00
Compiler.h Add a LLVM_NOEXCEPT to Compiler.h. 2014-06-10 20:45:52 +00:00
Compression.h Simplify compression API by compressing into a SmallVector rather than a MemoryBuffer 2014-04-05 21:53:04 +00:00
ConvertUTF.h Support/ConvertUTF: implement U+FFFD insertion according to the recommendation 2014-06-16 11:09:46 +00:00
CrashRecoveryContext.h For CrashRecoveryContext::RunSafelyOnThread, propagate Darwin's PRIO_DARWIN_BG to the new thread if it is 2014-06-25 23:54:50 +00:00
DataExtractor.h Be consistent about the field name - AddressSize, not PointerSize. Add 2013-02-05 23:26:02 +00:00
DataStream.h
DataTypes.h.cmake Fix standard integer definitions for MSVC in DataTypes.h 2014-05-28 18:19:55 +00:00
DataTypes.h.in Fix standard integer definitions for MSVC in DataTypes.h 2014-05-28 18:19:55 +00:00
Debug.h [Modules] Make Support/Debug.h modular. This requires it to not change 2014-04-21 22:55:11 +00:00
DOTGraphTraits.h
Dwarf.h Emit DWARF3 call frame information when DWARF3+ debug info is requested 2014-06-19 15:39:33 +00:00
DynamicLibrary.h [C++11] Make use of 'nullptr' in the Support library. 2014-04-07 04:17:22 +00:00
ELF.h [PowerPC] ELFv2 MC support for .localentry directive 2014-07-20 23:06:03 +00:00
Endian.h Using llvm::sys::swapByteOrder() for the common case of byte-swapping a value in place 2014-06-14 13:18:07 +00:00
EndianStream.h Support: Functions for writing endian specific data to streams. 2014-03-28 19:14:43 +00:00
Errc.h Finishing touch for the std::error_code transition. 2014-06-13 17:20:48 +00:00
Errno.h
ErrorHandling.h Make the error-handling functions thread-safe. 2014-06-13 21:20:44 +00:00
ErrorOr.h Finishing touch for the std::error_code transition. 2014-06-13 17:20:48 +00:00
FileOutputBuffer.h Don't use 'using std::error_code' in include/llvm. 2014-06-12 21:46:39 +00:00
FileSystem.h Fix 'platform-specific' hyphenations 2014-06-30 18:57:16 +00:00
FileUtilities.h [C++11] Make use of 'nullptr' in the Support library. 2014-04-07 04:17:22 +00:00
Format.h Support: style/documentation cleanup for format 2014-06-04 15:47:07 +00:00
FormattedStream.h [C++11] Make use of 'nullptr' in the Support library. 2014-04-07 04:17:22 +00:00
GCOV.h llvm-cov: Fix some funny indentation (NFC) 2014-05-07 21:50:43 +00:00
GenericDomTree.h Move operator[] to DomTreeNodeBase 2014-07-02 06:50:48 +00:00
GenericDomTreeConstruction.h [C++11] More 'nullptr' conversion. In some cases just using a boolean check instead of comparing to nullptr. 2014-04-14 00:51:57 +00:00
GraphWriter.h Revert "Introduce a string_ostream string builder facilty" 2014-06-26 22:52:05 +00:00
Host.h Return a StringRef from getHostCPUName. 2013-12-12 15:45:32 +00:00
IncludeFile.h
LEB128.h [C++11] Make use of 'nullptr' in the Support library. 2014-04-07 04:17:22 +00:00
LICENSE.TXT
LineIterator.h LineIterator: Add DataTypes.h for int64_t on MSVC. 2014-04-18 16:57:01 +00:00
Locale.h
LockFileManager.h Don't use 'using std::error_code' in include/llvm. 2014-06-12 21:46:39 +00:00
MachO.h extracting swapStruct into include/llvm/Support/MachO.h (no functional change) 2014-07-18 09:26:16 +00:00
ManagedStatic.h Re-apply r211287: Remove support for LLVM runtime multi-threading. 2014-06-27 15:13:01 +00:00
MathExtras.h Undefine R2, R4, R6 after use. 2014-07-02 14:40:35 +00:00
MD5.h Actually include the ArrayRef header rather than rely on the forward 2014-03-07 21:30:49 +00:00
Memory.h Don't use 'using std::error_code' in include/llvm. 2014-06-12 21:46:39 +00:00
MemoryBuffer.h Update the MemoryBuffer API to use ErrorOr. 2014-07-06 17:43:13 +00:00
MemoryObject.h Remove the Copied parameter from MemoryObject::readBytes. 2013-05-24 10:54:58 +00:00
Mutex.h Include Threading.h instead of forward declaring a function. 2014-06-19 20:20:03 +00:00
MutexGuard.h
OnDiskHashTable.h Let OnDiskHashTable call the destructor of its Items. 2014-05-07 19:55:38 +00:00
OutputBuffer.h
Path.h Fix hardcoded slash to native path seperator which was exposed from llvm::sys::path. 2014-05-16 13:16:30 +00:00
PluginLoader.h
PointerLikeTypeTraits.h
PrettyStackTrace.h [C++11] Remove 'virtual' keyword from methods marked with 'override' keyword. 2014-03-10 03:53:12 +00:00
Process.h Refactor the code in clang to find a file in a PATH like environment variable into a helper function 2014-06-30 19:54:20 +00:00
Program.h Don't use 'using std::error_code' in include/llvm. 2014-06-12 21:46:39 +00:00
RandomNumberGenerator.h Fix the build. 2014-06-25 15:47:36 +00:00
raw_os_ostream.h [C++11] Remove 'virtual' keyword from methods marked with 'override' keyword. 2014-03-10 03:53:12 +00:00
raw_ostream.h Revert "Introduce a string_ostream string builder facilty" 2014-06-26 22:52:05 +00:00
Recycler.h [Allocator] Stop forward-declaring BumpPtrAllocator in a few places. 2014-03-30 11:36:29 +00:00
RecyclingAllocator.h Add an assertion to the fixed-size allocator to ensure that we don't request 2013-08-27 11:20:13 +00:00
Regex.h [C++11] Make use of 'nullptr' in the Support library. 2014-04-07 04:17:22 +00:00
Registry.h Use unique_ptr for the result of Registry entries. 2014-04-15 05:53:26 +00:00
RegistryParser.h
RWMutex.h
SaveAndRestore.h SaveAndRestore: fix coding style and Doxygenify comments 2014-04-10 09:44:32 +00:00
ScaledNumber.h Include <tuple> for std::tie 2014-06-24 05:59:52 +00:00
Signals.h [C++11] Make use of 'nullptr' in the Support library. 2014-04-07 04:17:22 +00:00
SMLoc.h [C++11] Make use of 'nullptr' in the Support library. 2014-04-07 04:17:22 +00:00
Solaris.h Define BYTE_ORDER on Solaris. 2013-05-21 20:36:13 +00:00
SourceMgr.h SourceMgr: consistently use 'unsigned' for the memory buffer ID type 2014-07-09 08:30:15 +00:00
SpecialCaseList.h SpecialCaseList.h: Fix -Wdocumentation with \code. 2014-07-10 11:39:59 +00:00
StreamableMemoryObject.h Convert some assert(0) to llvm_unreachable or fold an 'if' condition into the assert. 2014-06-19 06:10:58 +00:00
StringPool.h Fix breakage from r211244 by using LLVM_EXPLICIT to avoid using explicit operators under MSVC where they're not supported. 2014-06-19 01:09:49 +00:00
StringRefMemoryObject.h Switch all uses of LLVM_OVERRIDE to just use 'override' directly. 2014-03-02 09:09:27 +00:00
SwapByteOrder.h Adding llvm::sys::swapByteOrder() for the common use-case of byte-swapping a value in place 2014-06-14 12:52:55 +00:00
SystemUtils.h Move PrependMainExecutablePath next to its only user. 2013-06-14 15:12:13 +00:00
TargetRegistry.h Remove obsolete function TargetRegistry::getClosestTargetForJIT() 2014-07-01 10:47:13 +00:00
TargetSelect.h
Threading.h Re-apply r211287: Remove support for LLVM runtime multi-threading. 2014-06-27 15:13:01 +00:00
ThreadLocal.h
Timer.h [C++11] More 'nullptr' conversion. In some cases just using a boolean check instead of comparing to nullptr. 2014-04-14 00:51:57 +00:00
TimeValue.h Remove TimeValue::toPosixTime() -- it is buggy, semantics are unclear, and its 2014-02-11 09:11:18 +00:00
ToolOutputFile.h Don't make F_None the default. 2014-02-24 15:07:20 +00:00
type_traits.h [C++11] Now that the users are gone, rip out the duplicated traits from type_traits.h 2014-03-07 15:54:23 +00:00
Unicode.h include/llvm/Support/Unicode.h didn't have re-include guards 2014-05-13 10:11:29 +00:00
UnicodeCharRanges.h [Modules] Make Support/Debug.h modular. This requires it to not change 2014-04-21 22:55:11 +00:00
Valgrind.h Don't mark the declarations of the TSan annotation functions as weak. 2014-03-30 11:20:25 +00:00
Watchdog.h Add a new watchdog timer interface. The interface does not permit handling timeouts, so 2013-03-26 01:27:52 +00:00
Win64EH.h Partially roll back r202915. 2014-03-05 00:43:02 +00:00
WindowsError.h Try to fix the mingw build. 2014-06-12 00:24:39 +00:00
YAMLParser.h [Allocator] Pass the size to the deallocation function. This, on some 2014-04-15 08:59:52 +00:00
YAMLTraits.h Revert "Introduce a string_ostream string builder facilty" 2014-06-26 22:52:05 +00:00