[DWARF][RISCV] Add support for RISC-V relocations needed for debug info
authorAlex Bradbury <asb@lowrisc.org>
Thu, 18 Jul 2019 05:22:55 +0000 (05:22 +0000)
committerAlex Bradbury <asb@lowrisc.org>
Thu, 18 Jul 2019 05:22:55 +0000 (05:22 +0000)
commit44deaf7e54ef55a55965f0c5cf41d4436120f75f
tree1c78acf506f8a30b7c074f79ded76d7e525223fe
parent1d5cbb7557a18ea9e467993264155ce3b538b572
[DWARF][RISCV] Add support for RISC-V relocations needed for debug info

When code relaxation is enabled many RISC-V fixups are not resolved but
instead relocations are emitted. This happens even for DWARF debug
sections. Therefore, to properly support the parsing of DWARF debug info
we need to be able to resolve RISC-V relocations. This patch adds:

* Support for RISC-V relocations in RelocationResolver
* DWARF support for two relocations per object file offset
* DWARF changes to support relocations in more DIE fields

The two relocations per offset change is needed because some RISC-V
relocations (used for label differences) come in pairs.

Relocations can also be emitted for DWARF fields where relocations were
not yet evaluated. Adding relocation support for some of these fields is
essencial. On the other hand, LLVM currently emits RISC-V relocations
for fixups that could be safely evaluated, since they can never be
affected by code relaxations. This patch also adds relocation support
for the fields affected by those extraneous relocations (the DWARF unit
entry Length, and the DWARF debug line entry TotalLength and
PrologueLength), for testing purposes.

Differential Revision: https://reviews.llvm.org/D62062
Patch by Luís Marques.

llvm-svn: 366402
lld/ELF/DWARF.cpp
llvm/include/llvm/DebugInfo/DWARF/DWARFRelocMap.h
llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
llvm/lib/DebugInfo/DWARF/DWARFDataExtractor.cpp
llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp
llvm/lib/DebugInfo/DWARF/DWARFListTable.cpp
llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
llvm/lib/Object/RelocationResolver.cpp
llvm/test/DebugInfo/RISCV/dwarf-riscv-relocs.ll [new file with mode: 0644]