aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm
diff options
context:
space:
mode:
authorAkira Hatanaka <ahatanaka@mips.com>2012-03-23 23:06:45 +0000
committerAkira Hatanaka <ahatanaka@mips.com>2012-03-23 23:06:45 +0000
commit00ca888cccd130dd3ebcfc02cf2b9187b54d116e (patch)
treea51008a729525e86a7ce882922549caa88a4137a /include/llvm
parent6fedb3c4016b8f706c472280a3a9b22430c73ef4 (diff)
downloadexternal_llvm-00ca888cccd130dd3ebcfc02cf2b9187b54d116e.zip
external_llvm-00ca888cccd130dd3ebcfc02cf2b9187b54d116e.tar.gz
external_llvm-00ca888cccd130dd3ebcfc02cf2b9187b54d116e.tar.bz2
Add a hook in MCELFObjectTargetWriter to allow targets to sort relocation
entries in the relocation table before they are written out to the file. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153345 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm')
-rw-r--r--include/llvm/MC/MCELFObjectWriter.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/include/llvm/MC/MCELFObjectWriter.h b/include/llvm/MC/MCELFObjectWriter.h
index 6e9f5d8..452f8bd 100644
--- a/include/llvm/MC/MCELFObjectWriter.h
+++ b/include/llvm/MC/MCELFObjectWriter.h
@@ -13,8 +13,35 @@
#include "llvm/MC/MCObjectWriter.h"
#include "llvm/Support/DataTypes.h"
#include "llvm/Support/ELF.h"
+#include <vector>
namespace llvm {
+/// @name Relocation Data
+/// @{
+
+struct ELFRelocationEntry {
+ // Make these big enough for both 32-bit and 64-bit
+ uint64_t r_offset;
+ int Index;
+ unsigned Type;
+ const MCSymbol *Symbol;
+ uint64_t r_addend;
+ const MCFixup *Fixup;
+
+ ELFRelocationEntry()
+ : r_offset(0), Index(0), Type(0), Symbol(0), r_addend(0), Fixup(0) {}
+
+ ELFRelocationEntry(uint64_t RelocOffset, int Idx, unsigned RelType,
+ const MCSymbol *Sym, uint64_t Addend, const MCFixup &Fixup)
+ : r_offset(RelocOffset), Index(Idx), Type(RelType), Symbol(Sym),
+ r_addend(Addend), Fixup(&Fixup) {}
+
+ // Support lexicographic sorting.
+ bool operator<(const ELFRelocationEntry &RE) const {
+ return RE.r_offset < r_offset;
+ }
+};
+
class MCELFObjectTargetWriter {
const uint8_t OSABI;
const uint16_t EMachine;
@@ -52,6 +79,8 @@ public:
virtual void adjustFixupOffset(const MCFixup &Fixup,
uint64_t &RelocOffset);
+ virtual void sortRelocs(const MCAssembler &Asm,
+ std::vector<ELFRelocationEntry> &Relocs);
/// @name Accessors
/// @{