aboutsummaryrefslogtreecommitdiff
path: root/elfcpp
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@google.com>2006-09-07 21:21:41 +0000
committerIan Lance Taylor <iant@google.com>2006-09-07 21:21:41 +0000
commit1564db8db6620560889dd5baeae801623c00a595 (patch)
tree0d169f6071a1a4307765bd42f6d8576ce52d6e15 /elfcpp
parent466bbf939d6756d579cb499f19654ac39b923d05 (diff)
downloadgdb-1564db8db6620560889dd5baeae801623c00a595.zip
gdb-1564db8db6620560889dd5baeae801623c00a595.tar.gz
gdb-1564db8db6620560889dd5baeae801623c00a595.tar.bz2
More symbol resolution code.
Diffstat (limited to 'elfcpp')
-rw-r--r--elfcpp/elfcpp.h57
1 files changed, 57 insertions, 0 deletions
diff --git a/elfcpp/elfcpp.h b/elfcpp/elfcpp.h
index 9af0b8d..4f2a4ab 100644
--- a/elfcpp/elfcpp.h
+++ b/elfcpp/elfcpp.h
@@ -437,6 +437,13 @@ elf_st_nonvis(unsigned char other)
return static_cast<STV>(other >> 2);
}
+inline unsigned char
+elf_st_other(STV vis, unsigned char nonvis)
+{
+ return ((nonvis << 2)
+ + (static_cast<unsigned char>(vis) & 3));
+}
+
} // End namespace elfcpp.
// Include internal details after defining the types.
@@ -641,6 +648,56 @@ class Sym
const internal::Sym_data<size>* p_;
};
+// Writer class for an ELF symbol table entry.
+
+template<int size, bool big_endian>
+class Sym_write
+{
+ public:
+ Sym_write(unsigned char* p)
+ : p_(reinterpret_cast<internal::Sym_data<size>*>(p))
+ { }
+
+ void
+ put_st_name(Elf_Word v)
+ { this->p_->st_name = internal::convert_word<big_endian>(v); }
+
+ void
+ put_st_value(typename Elf_types<size>::Elf_Addr v)
+ { this->p_->st_value = internal::convert_addr<size, big_endian>(v); }
+
+ void
+ put_st_size(typename Elf_types<size>::Elf_WXword v)
+ { this->p_->st_size = internal::convert_wxword<size, big_endian>(v); }
+
+ void
+ put_st_info(unsigned char v)
+ { this->p_->st_info = v; }
+
+ void
+ put_st_info(STB bind, STT type)
+ { this->p_->st_info = elf_st_info(bind, type); }
+
+ void
+ put_st_other(unsigned char v)
+ { this->p_->st_other = v; }
+
+ void
+ put_st_other(STV vis, unsigned char nonvis)
+ { this->p_->st_other = elf_st_other(vis, nonvis); }
+
+ void
+ put_st_shndx(Elf_Half v)
+ { this->p_->st_shndx = internal::convert_half<big_endian>(v); }
+
+ Sym<size, big_endian>
+ sym()
+ { return Sym<size, big_endian>(reinterpret_cast<unsigned char*>(this->p_)); }
+
+ private:
+ internal::Sym_data<size>* p_;
+};
+
} // End namespace elfcpp.
#endif // !defined(ELFPCP_H)