From 1564db8db6620560889dd5baeae801623c00a595 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Thu, 7 Sep 2006 21:21:41 +0000 Subject: More symbol resolution code. --- elfcpp/elfcpp.h | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) (limited to 'elfcpp') 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(other >> 2); } +inline unsigned char +elf_st_other(STV vis, unsigned char nonvis) +{ + return ((nonvis << 2) + + (static_cast(vis) & 3)); +} + } // End namespace elfcpp. // Include internal details after defining the types. @@ -641,6 +648,56 @@ class Sym const internal::Sym_data* p_; }; +// Writer class for an ELF symbol table entry. + +template +class Sym_write +{ + public: + Sym_write(unsigned char* p) + : p_(reinterpret_cast*>(p)) + { } + + void + put_st_name(Elf_Word v) + { this->p_->st_name = internal::convert_word(v); } + + void + put_st_value(typename Elf_types::Elf_Addr v) + { this->p_->st_value = internal::convert_addr(v); } + + void + put_st_size(typename Elf_types::Elf_WXword v) + { this->p_->st_size = internal::convert_wxword(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(v); } + + Sym + sym() + { return Sym(reinterpret_cast(this->p_)); } + + private: + internal::Sym_data* p_; +}; + } // End namespace elfcpp. #endif // !defined(ELFPCP_H) -- cgit v1.1