Skip to content

Commit

Permalink
Add symtab/relocationEntry.h
Browse files Browse the repository at this point in the history
  • Loading branch information
hainest committed Apr 3, 2024
1 parent d3fa6dc commit eec21e9
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 16 deletions.
1 change: 1 addition & 0 deletions docs/symtabAPI/developer/API.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ SymtabAPI
Object.h
Object-nt.h
Region.h
relocationEntry.h
Type-mem.h
59 changes: 59 additions & 0 deletions docs/symtabAPI/developer/relocationEntry.h.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
.. _`sec:relocationEntry.h`:

relocationEntry.h
#################

.. cpp:namespace:: Dyninst::SymtabAPI

.. cpp:class:: relocationEntry : public AnnotatableSparse

.. cpp:member:: private Offset target_addr_

Target address of call instruction

.. cpp:member:: private Offset rel_addr_

Address of corresponding relocation entry

.. cpp:member:: private Offset addend_

Addend (from RELA entries)

.. cpp:member:: private Region::RegionType rtype_

RT_REL vs. RT_RELA

.. cpp:function:: relocationEntry()
.. cpp:function:: relocationEntry(Offset ta, Offset ra, Offset add, std::string n, Symbol *dynref = NULL, unsigned long relType = 0)
.. cpp:function:: relocationEntry(Offset ta, Offset ra, std::string n, Symbol *dynref = NULL, unsigned long relType = 0)
.. cpp:function:: relocationEntry(Offset ra, std::string n, Symbol *dynref = NULL, unsigned long relType = 0, Region::RegionType rtype = Region::RT_REL)
.. cpp:function:: relocationEntry(Offset ta, Offset ra, Offset add, std::string n, Symbol *dynref = NULL, unsigned long relType = 0, Region::RegionType rtype = Region::RT_REL)
.. cpp:function:: Offset target_addr() const
.. cpp:function:: Offset rel_addr() const
.. cpp:function:: Offset addend() const
.. cpp:function:: Region::RegionType regionType() const
.. cpp:function:: const std::string &name() const
.. cpp:function:: Symbol *getDynSym() const
.. cpp:function:: bool addDynSym(Symbol *dynref)
.. cpp:function:: unsigned long getRelType() const
.. cpp:function:: void setTargetAddr(const Offset)
.. cpp:function:: void setRelAddr(const Offset)
.. cpp:function:: void setAddend(const Offset)
.. cpp:function:: void setRegionType(const Region::RegionType)
.. cpp:function:: void setName(const std::string &newName)
.. cpp:function:: void setRelType(unsigned long relType)
.. cpp:function:: bool operator==(const relocationEntry &) const
.. cpp:function:: static unsigned long getGlobalRelType(unsigned addressWidth, Symbol *sym = NULL)
.. cpp:function:: static const char *relType2Str(unsigned long r, unsigned addressWidth = sizeof(Address))
.. cpp:function:: category getCategory( unsigned addressWidth )

.. cpp:enum:: relocationEntry::@rel

.. cpp:enumerator:: pltrel = 1
.. cpp:enumerator:: dynrel = 2

.. cpp:enum:: category

.. cpp:enumerator:: relative
.. cpp:enumerator:: jump_slot
.. cpp:enumerator:: absolute
1 change: 0 additions & 1 deletion docs/symtabAPI/public/API.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ SymtabAPI
Module.h
RangeLookup.h
Region.h
relocationEntry.h
Statement.h
StringTable.h
Symbol.h
Expand Down
7 changes: 0 additions & 7 deletions docs/symtabAPI/public/relocationEntry.h.rst

This file was deleted.

12 changes: 4 additions & 8 deletions symtabAPI/h/relocationEntry.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ class SYMTAB_EXPORT relocationEntry : public AnnotatableSparse {
void setName(const std::string &newName);
void setRelType(unsigned long relType) { relType_ = relType; }

// dump output. Currently setup as a debugging aid, not really
// for object persistance....
//std::ostream & operator<<(std::ostream &s) const;
friend SYMTAB_EXPORT std::ostream & operator<<(std::ostream &os, const relocationEntry &q);

Expand All @@ -88,24 +86,22 @@ class SYMTAB_EXPORT relocationEntry : public AnnotatableSparse {

enum category { relative, jump_slot, absolute };

// Architecture-specific functions
static unsigned long getGlobalRelType(unsigned addressWidth, Symbol *sym = NULL);
static const char *relType2Str(unsigned long r, unsigned addressWidth = sizeof(Address));
category getCategory( unsigned addressWidth );

private:
Offset target_addr_; // target address of call instruction
Offset rel_addr_; // address of corresponding relocation entry
Offset addend_; // addend (from RELA entries)
Region::RegionType rtype_; // RT_REL vs. RT_RELA
Offset target_addr_;
Offset rel_addr_;
Offset addend_;
Region::RegionType rtype_;
std::string name_;
Symbol *dynref_;
unsigned long relType_;
Offset rel_struct_addr_;
};


// relocation information for calls to functions not in this image
SYMTAB_EXPORT std::ostream &operator<<(std::ostream &os, const relocationEntry &q);

}//namespace SymtabAPI
Expand Down

0 comments on commit eec21e9

Please sign in to comment.