1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-20 03:23:01 +02:00
llvm-mirror/lib/MC
Alex Bradbury ebc93587cb [RISCV] Add symbol diff relocation support for RISC-V
For RISC-V it is desirable to have relaxation happen in the linker once 
addresses are known, and as such the size between two instructions/byte 
sequences in a section could change.

For most assembler expressions, this is fine, as the absolute address results 
in the expression being converted to a fixup, and finally relocations. 
However, for expressions such as .quad .L2-.L1, the assembler folds this down 
to a constant once fragments are laid out, under the assumption that the 
difference can no longer change, although in the case of linker relaxation the 
differences can change at link time, so the constant is incorrect. One place 
where this commonly appears is in debug information, where the size of a 
function expression is in a form similar to the above.

This patch extends the assembler to allow an AsmBackend to declare that it 
does not want the assembler to fold down this expression, and instead generate 
a pair of relocations that allow the linker to carry out the calculation. In 
this case, the expression is not folded, but when it comes to emitting a 
fixup, the generic FK_Data_* fixups are converted into a pair, one for the 
addition half, one for the subtraction, and this is passed to the relocation 
generating methods as usual. I have named these FK_Data_Add_* and 
FK_Data_Sub_* to indicate which half these are for.

For RISC-V, which supports this via e.g. the R_RISCV_ADD64, R_RISCV_SUB64 pair 
of relocations, these are also set to always emit relocations relative to 
local symbols rather than section offsets. This is to deal with the fact that 
if relocations were calculated on e.g. .text+8 and .text+4, the result 12 
would be stored rather than 4 as both addends are added in the linker.

Differential Revision: https://reviews.llvm.org/D45181
Patch by Simon Cook.

llvm-svn: 333079
2018-05-23 12:36:18 +00:00
..
MCDisassembler Remove \brief commands from doxygen comments. 2018-05-01 15:54:18 +00:00
MCParser Remove \brief commands from doxygen comments. 2018-05-01 15:54:18 +00:00
CMakeLists.txt [Asm] Add debug printing for assembler macros 2018-03-06 14:07:01 +00:00
ConstantPools.cpp Re-apply r302416: [ARM] Clear the constant pool cache on explicit .ltorg directives 2017-05-22 09:42:07 +00:00
ELFObjectWriter.cpp MC: Introduce an ELF dwo object writer and teach llvm-mc about it. 2018-05-21 19:44:54 +00:00
LLVMBuild.txt [WebAssembly] Move toString helpers to BinaryFormat 2018-05-14 22:42:07 +00:00
MachObjectWriter.cpp MC: Have the object writers return the number of bytes written. NFCI. 2018-05-21 18:23:50 +00:00
MCAsmBackend.cpp [RISCV] Add symbol diff relocation support for RISC-V 2018-05-23 12:36:18 +00:00
MCAsmInfo.cpp [DEBUGINFO] Add option that allows to disable emission of flags in .loc directives. 2018-04-03 17:28:55 +00:00
MCAsmInfoCOFF.cpp [MC] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC). 2017-02-11 00:27:28 +00:00
MCAsmInfoDarwin.cpp Move Object format code to lib/BinaryFormat. 2017-06-07 03:48:56 +00:00
MCAsmInfoELF.cpp Move Object format code to lib/BinaryFormat. 2017-06-07 03:48:56 +00:00
MCAsmInfoWasm.cpp Remove redundant includes from lib/MC. 2017-12-13 21:30:54 +00:00
MCAsmMacro.cpp [Asm] Fix another layering violation in assmebly macro dumping 2018-03-06 16:51:17 +00:00
MCAsmStreamer.cpp [MC] Change AsmParser to leverage Assembler during evaluation 2018-04-30 19:22:40 +00:00
MCAssembler.cpp [RISCV] Add symbol diff relocation support for RISC-V 2018-05-23 12:36:18 +00:00
MCCodeEmitter.cpp [MC] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC). 2017-02-08 22:23:19 +00:00
MCCodePadder.cpp [MC] Adding code padding for performance stability - infrastructure. NFC. 2017-10-24 06:16:03 +00:00
MCCodeView.cpp Support: Simplify endian stream interface. NFCI. 2018-05-18 19:46:24 +00:00
MCContext.cpp [WebAssembly] Create section start symbols automatically for all sections 2018-05-10 17:38:35 +00:00
MCDwarf.cpp Support: Simplify endian stream interface. NFCI. 2018-05-18 19:46:24 +00:00
MCELFObjectTargetWriter.cpp [mips] Do not pass redundant IsN64 flag to MCELFObjectTargetWriter. NFC 2017-09-21 14:04:47 +00:00
MCELFStreamer.cpp MC: Remove dead code. NFCI. 2018-05-22 01:20:46 +00:00
MCExpr.cpp [RISCV] Add symbol diff relocation support for RISC-V 2018-05-23 12:36:18 +00:00
MCFragment.cpp [MC] Relax .fill size requirements 2018-05-18 17:45:48 +00:00
MCInst.cpp IWYU for llvm-config.h in llvm, additions. 2018-04-30 14:59:11 +00:00
MCInstPrinter.cpp Sort the remaining #include lines in include/... and lib/.... 2017-06-06 11:49:48 +00:00
MCInstrAnalysis.cpp Sort the remaining #include lines in include/... and lib/.... 2017-06-06 11:49:48 +00:00
MCInstrDesc.cpp
MCLabel.cpp IWYU for llvm-config.h in llvm, additions. 2018-04-30 14:59:11 +00:00
MCLinkerOptimizationHint.cpp MC: Change object writers to use endian::Writer. NFCI. 2018-05-21 18:17:42 +00:00
MCMachObjectTargetWriter.cpp [MC] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC). 2017-02-11 00:27:28 +00:00
MCMachOStreamer.cpp MC: Change the streamer ctors to take an object writer instead of a stream. NFCI. 2018-05-18 18:26:45 +00:00
MCNullStreamer.cpp Remove redundant includes from lib/MC. 2017-12-13 21:30:54 +00:00
MCObjectFileInfo.cpp [WebAssembly] Create section start symbols automatically for all sections 2018-05-10 17:38:35 +00:00
MCObjectStreamer.cpp MC: Change the streamer ctors to take an object writer instead of a stream. NFCI. 2018-05-18 18:26:45 +00:00
MCObjectWriter.cpp Sort the remaining #include lines in include/... and lib/.... 2017-06-06 11:49:48 +00:00
MCRegisterInfo.cpp [MC] Handle unknown literal register numbers in .cfi_* directives 2017-12-01 21:44:27 +00:00
MCSchedule.cpp [MC] Moved all the remaining logic that computed instruction latency and reciprocal throughput from TargetSchedModel to MCSchedModel. 2018-04-15 17:32:17 +00:00
MCSection.cpp IWYU for llvm-config.h in llvm, additions. 2018-04-30 14:59:11 +00:00
MCSectionCOFF.cpp Move Object format code to lib/BinaryFormat. 2017-06-07 03:48:56 +00:00
MCSectionELF.cpp CodeGen: support an extension to pass linker options on ELF 2018-01-30 16:29:29 +00:00
MCSectionMachO.cpp Fix the GCC build. 2017-01-30 19:05:09 +00:00
MCSectionWasm.cpp Remove redundant includes from lib/MC. 2017-12-13 21:30:54 +00:00
MCStreamer.cpp [MC] Change AsmParser to leverage Assembler during evaluation 2018-04-30 19:22:40 +00:00
MCSubtargetInfo.cpp [MC] fix documentation comments; NFC 2018-03-22 15:23:21 +00:00
MCSymbol.cpp IWYU for llvm-config.h in llvm, additions. 2018-04-30 14:59:11 +00:00
MCSymbolELF.cpp Remove redundant includes from lib/MC. 2017-12-13 21:30:54 +00:00
MCTargetOptions.cpp Sort the remaining #include lines in include/... and lib/.... 2017-06-06 11:49:48 +00:00
MCValue.cpp IWYU for llvm-config.h in llvm, additions. 2018-04-30 14:59:11 +00:00
MCWasmObjectTargetWriter.cpp [WebAssembly] Remove unused headers in MCWasmObjectWriter 2018-05-16 22:13:18 +00:00
MCWasmStreamer.cpp MC: Change the streamer ctors to take an object writer instead of a stream. NFCI. 2018-05-18 18:26:45 +00:00
MCWin64EH.cpp Remove redundant includes from lib/MC. 2017-12-13 21:30:54 +00:00
MCWinCOFFStreamer.cpp MC: Change the streamer ctors to take an object writer instead of a stream. NFCI. 2018-05-18 18:26:45 +00:00
MCWinEH.cpp Move Object format code to lib/BinaryFormat. 2017-06-07 03:48:56 +00:00
StringTableBuilder.cpp [DWARFv5] Emit .debug_line_str (in a non-DWO file). 2018-02-06 20:29:21 +00:00
SubtargetFeature.cpp IWYU for llvm-config.h in llvm, additions. 2018-04-30 14:59:11 +00:00
WasmObjectWriter.cpp MC: Remove stream and output functions from MCObjectWriter. NFCI. 2018-05-21 18:28:57 +00:00
WinCOFFObjectWriter.cpp MC: Remove stream and output functions from MCObjectWriter. NFCI. 2018-05-21 18:28:57 +00:00